Skip to content

Class Ansi ​

Source: ansi.ts

Provides utility functions for wrapping text in ANSI escape codes.

See ​

ANSI

Methods ​

black() ​

static black(text: string): string

Makes text black using ANSI.fg.black.

Parameters ​

text ​

string

Returns ​

string


red() ​

static red(text: string): string

Makes text red using ANSI.fg.red.

Parameters ​

text ​

string

Returns ​

string


green() ​

static green(text: string): string

Makes text green using ANSI.fg.green.

Parameters ​

text ​

string

Returns ​

string


yellow() ​

static yellow(text: string): string

Makes text yellow using ANSI.fg.yellow.

Parameters ​

text ​

string

Returns ​

string


blue() ​

static blue(text: string): string

Makes text blue using ANSI.fg.blue.

Parameters ​

text ​

string

Returns ​

string


magenta() ​

static magenta(text: string): string

Makes text magenta using ANSI.fg.magenta.

Parameters ​

text ​

string

Returns ​

string


cyan() ​

static cyan(text: string): string

Makes text cyan using ANSI.fg.cyan.

Parameters ​

text ​

string

Returns ​

string


white() ​

static white(text: string): string

Makes text white using ANSI.fg.white.

Parameters ​

text ​

string

Returns ​

string


blackBackground() ​

static blackBackground(text: string): string

Sets background to black using ANSI.bg.black.

Parameters ​

text ​

string

Returns ​

string


redBackground() ​

static redBackground(text: string): string

Sets background to red using ANSI.bg.red.

Parameters ​

text ​

string

Returns ​

string


greenBackground() ​

static greenBackground(text: string): string

Sets background to green using ANSI.bg.green.

Parameters ​

text ​

string

Returns ​

string


yellowBackground() ​

static yellowBackground(text: string): string

Sets background to yellow using ANSI.bg.yellow.

Parameters ​

text ​

string

Returns ​

string


blueBackground() ​

static blueBackground(text: string): string

Sets background to blue using ANSI.bg.blue.

Parameters ​

text ​

string

Returns ​

string


magentaBackground() ​

static magentaBackground(text: string): string

Sets background to magenta using ANSI.bg.magenta.

Parameters ​

text ​

string

Returns ​

string


cyanBackground() ​

static cyanBackground(text: string): string

Sets background to cyan using ANSI.bg.cyan.

Parameters ​

text ​

string

Returns ​

string


whiteBackground() ​

static whiteBackground(text: string): string

Sets background to white using ANSI.bg.white.

Parameters ​

text ​

string

Returns ​

string


bold() ​

static bold(text: string): string

Makes text bold using ANSI.decoration.bold.

Parameters ​

text ​

string

Returns ​

string


dim() ​

static dim(text: string): string

Makes text dim using ANSI.decoration.dim.

Parameters ​

text ​

string

Returns ​

string


italic() ​

static italic(text: string): string

Makes text italic using ANSI.decoration.italic.

Parameters ​

text ​

string

Returns ​

string


underline() ​

static underline(text: string): string

Underlines text using ANSI.decoration.underline.

Parameters ​

text ​

string

Returns ​

string


invert() ​

static invert(text: string): string

Inverts foreground and background colors using ANSI.decoration.invert.

Parameters ​

text ​

string

Returns ​

string


strike() ​

static strike(text: string): string

Makes text strike through using ANSI.decoration.strike.

Parameters ​

text ​

string

Returns ​

string


strip() ​

static strip(text: string): string

Removes all ANSI escape sequences.

Parameters ​

text ​

string

Returns ​

string


stripColors() ​

static stripColors(text: string): string

Removes ANSI escape sequences for colors and background colors (SGR).

Parameters ​

text ​

string

Returns ​

string

Built by Prozilla