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.
ansicolor class
Represents an ANSI-escaped string.
Signature
export default class Colors
Import
import { ansicolor } from '@grafana/ui';
Constructors
Properties
Methods
constructor(s)
Constructs a new instance of the Colors
class
Signature
constructor(s?: string);
Parameters
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
Returns:
Colors & {
spans: any[];
}
{Colors} parsed representation.
strip method
strips ANSI codes from a string
Signature
static strip(s: string): string;
Parameters
Returns:
string
{string} clean string.