API Reference@grafana/ui › ansicolor

ansicolor class

Represents an ANSI-escaped string.

Signature

export default class Colors 

Import

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

Constructors

Constructor Modifiers Description
constructor(s) Constructs a new instance of the Colors class

Properties

Property Modifiers Type Description
asChromeConsoleLogArguments any[]
browserConsoleArguments any[]
names static (string | number)[]
nice static typeof Colors installs String prototype extensions
parsed Colors & {
spans: any[];
}
rgb static {
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 any[]
str any

Methods

Method Modifiers Description
[Symbol.iterator]()
parse(s) static parses a string containing ANSI escape codes
strip(s) static strips ANSI codes from a string

constructor(s)

Constructs a new instance of the Colors class

Signature

constructor(s?: string);

Parameters

Parameter Type Description
s string a string containing ANSI escape codes.

asChromeConsoleLogArguments property

Signature

get asChromeConsoleLogArguments(): any[];

browserConsoleArguments property

Signature

get browserConsoleArguments(): any[];

names property

Signature

static names: (string | number)[];

nice property

installs String prototype extensions

Signature

static get nice(): typeof Colors;

Example

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

parsed property

Signature

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

rgb property

Signature

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

spans: any[];

str property

Signature

get str(): any;

[Symbol.iterator] method

Signature

[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

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

Parameters

Parameter Type Description
s string

Returns:

Colors & { spans: any[]; }

{Colors} parsed representation.

strip method

strips ANSI codes from a string

Signature

static strip(s: string): string;

Parameters

Parameter Type Description
s string a string containing ANSI escape codes.

Returns:

string

{string} clean string.