Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Enterprise Open source

ansicolor class

Represents an ANSI-escaped string.

Signature

typescript
export default class Colors 

Import

typescript
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

typescript
constructor(s?: string);

Parameters

ParameterTypeDescription
sstringa string containing ANSI escape codes.

asChromeConsoleLogArguments property

Signature

typescript
get asChromeConsoleLogArguments(): any[];

browserConsoleArguments property

Signature

typescript
get browserConsoleArguments(): any[];

names property

Signature

typescript
static names: (string | number)[];

nice property

installs String prototype extensions

Signature

typescript
static get nice(): typeof Colors;

Example

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

parsed property

Signature

typescript
get parsed(): Colors & {
        spans: any[];
    };

rgb property

Signature

typescript
static rgb: {
        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[];
    };

spans property

Signature

typescript
spans: any[];

str property

Signature

typescript
get str(): any;

[Symbol.iterator] method

Signature

typescript
[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

typescript
static parse(s: string): Colors & {
        spans: any[];
    };

Parameters

ParameterTypeDescription
sstring

Returns:

Colors & { spans: any[]; }

{Colors} parsed representation.

strip method

strips ANSI codes from a string

Signature

typescript
static strip(s: string): string;

Parameters

ParameterTypeDescription
sstringa string containing ANSI escape codes.

Returns:

string

{string} clean string.