ansicolor class

Represents an ANSI-escaped string.

Signature

  1. export default class Colors

Import

  1. import { ansicolor } from '@grafana/ui';

Constructors

ConstructorModifiersDescription
constructor(s)Constructs a new instance of the Colors class

Properties

PropertyModifiersTypeDescription
asChromeConsoleLogArgumentsany[]
browserConsoleArgumentsany[]
namesstatic(string | number)[]
nicestatictypeof Colorsinstalls String prototype extensions
parsedColors & {
spans: any[];
}
rgbstatic{
black: number[];
darkGray: number[];
lightGray: number[];
white: number[];
red: number[];
lightRed: number[];
green: number[];
lightGreen: number[];
yellow: number[];
lightYellow: number[];
blue: number[];
lightBlue: number[];
magenta: number[];
lightMagenta: number[];
cyan: number[];
lightCyan: number[];
}
spansany[]
strany

Methods

MethodModifiersDescription
Symbol.iterator
parse(s)staticparses a string containing ANSI escape codes
strip(s)staticstrips ANSI codes from a string

constructor(s)

Constructs a new instance of the Colors class

Signature

  1. constructor(s?: string);

Parameters

ParameterTypeDescription
sstringa string containing ANSI escape codes.

asChromeConsoleLogArguments property

Signature

  1. get asChromeConsoleLogArguments(): any[];

browserConsoleArguments property

Signature

  1. get browserConsoleArguments(): any[];

names property

Signature

  1. static names: (string | number)[];

nice property

installs String prototype extensions

Signature

  1. static get nice(): typeof Colors;

Example

require (‘ansicolor’).nice console.log (‘foo’.bright.red)

parsed property

Signature

  1. get parsed(): Colors & {
  2. spans: any[];
  3. };

rgb property

Signature

  1. static rgb: {
  2. black: number[];
  3. darkGray: number[];
  4. lightGray: number[];
  5. white: number[];
  6. red: number[];
  7. lightRed: number[];
  8. green: number[];
  9. lightGreen: number[];
  10. yellow: number[];
  11. lightYellow: number[];
  12. blue: number[];
  13. lightBlue: number[];
  14. magenta: number[];
  15. lightMagenta: number[];
  16. cyan: number[];
  17. lightCyan: number[];
  18. };

spans property

Signature

  1. spans: any[];

str property

Signature

  1. get str(): any;

[Symbol.iterator] method

Signature

  1. [Symbol.iterator](): IterableIterator<any>;

Returns:

IterableIterator<any>

Example

const spans = […ansi.parse (‘\u001b[7m\u001b[7mfoo\u001b[7mbar\u001b[27m’)]

parse method

parses a string containing ANSI escape codes

Signature

  1. static parse(s: string): Colors & {
  2. spans: any[];
  3. };

Parameters

ParameterTypeDescription
sstring

Returns:

Colors & { spans: any[]; }

{Colors} parsed representation.

strip method

strips ANSI codes from a string

Signature

  1. static strip(s: string): string;

Parameters

ParameterTypeDescription
sstringa string containing ANSI escape codes.

Returns:

string

{string} clean string.