Skip to content
Vangware
GitHubLinkedInYouTube

ANSI by Vangware

Coverage License NPM Version Open Issues

📟 Functional CLI ANSI formatting functions.

Usage

📦 Node

Install @vangware/ansi as a dependency:

pnpm add @vangware/ansi
# or
npm install @vangware/ansi
# or
yarn add @vangware/ansi

Import it and use it:

import { foregroundRed } from "@vangware/ansi";

foregroundRed`Hello world!`; // "Hello world!" in red text.

🦕 Deno

Import @vangware/ansi using the npm: prefix, and use it directly:

import { foregroundRed } from "npm:@vangware/ansi";

foregroundRed`Hello world!`; // "Hello world!" in red text.

🌎 Browser

Import @vangware/ansi using esm.sh, and use it directly:

<script type="module">
	import { foregroundRed } from "https://esm.sh/@vangware/ansi";

	foregroundRed`Hello world!`; // "Hello world!" in red text.
</script>

Background

backgroundBlack

▸ backgroundBlack<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Black background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with black background.

Remarks

Given an input string, it will return a new string with the ANSI codes for black background around it.

Example

backgroundBlack("Vangware"); // "\x1b[40mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBlack`Vangware`; // "\x1b[40mVangware\x1b[49m"

See

View source


backgroundBlue

▸ backgroundBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Blue background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with blue background.

Remarks

Given an input string, it will return a new string with the ANSI codes for blue background around it.

Example

backgroundBlue("Vangware"); // "\x1b[44mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBlue`Vangware`; // "\x1b[44mVangware\x1b[49m"

See

View source


backgroundBrightBlue

▸ backgroundBrightBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright blue background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright blue background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright blue background around it.

Example

backgroundBrightBlue("Vangware"); // "\x1b[104mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBrightBlue`Vangware`; // "\x1b[104mVangware\x1b[49m"

See

View source


backgroundBrightCyan

▸ backgroundBrightCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright cyan background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright cyan background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright cyan background around it.

Example

backgroundBrightCyan("Vangware"); // "\x1b[106mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBrightCyan`Vangware`; // "\x1b[106mVangware\x1b[49m"

See

View source


backgroundBrightGreen

▸ backgroundBrightGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright green background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright green background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright green background around it.

Example

backgroundBrightGreen("Vangware"); // "\x1b[102mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBrightGreen`Vangware`; // "\x1b[102mVangware\x1b[49m"

See

View source


backgroundBrightMagenta

▸ backgroundBrightMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright magenta background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright magenta background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright magenta background around it.

Example

backgroundBrightMagenta("Vangware"); // "\x1b[105mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBrightMagenta`Vangware`; // "\x1b[105mVangware\x1b[49m"

See

View source


backgroundBrightRed

▸ backgroundBrightRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright red background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright red background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright red background around it.

Example

backgroundBrightRed("Vangware"); // "\x1b[101mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBrightRed`Vangware`; // "\x1b[101mVangware\x1b[49m"

See

View source


backgroundBrightWhite

▸ backgroundBrightWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright white background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright white background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright white background around it.

Example

backgroundBrightWhite("Vangware"); // "\x1b[107mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBrightWhite`Vangware`; // "\x1b[107mVangware\x1b[49m"

See

View source


backgroundBrightYellow

▸ backgroundBrightYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright yellow background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright yellow background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright yellow background around it.

Example

backgroundBrightYellow("Vangware"); // "\x1b[103mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundBrightYellow`Vangware`; // "\x1b[103mVangware\x1b[49m"

See

View source


backgroundColor

▸ backgroundColor<Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}`

Background color code wrapper.

Type parameters

NameType
Openextends number

Parameters

NameType
openOpen

Returns

fn

Curried function with close ANSI code for background in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}`

Formatted input string.

See

format

Remarks

Takes an open ANSI code and an input string and adds the open and close ANSI codes to that string (for background color).

Example

backgroundColor(13)("Vangware"); // "\x1b[13mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundColor(13)`Vangware`; // "\x1b[13mVangware\x1b[49m"

See

View source


backgroundCyan

▸ backgroundCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Cyan background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with cyan background.

Remarks

Given an input string, it will return a new string with the ANSI codes for cyan background around it.

Example

backgroundCyan("Vangware"); // "\x1b[46mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundCyan`Vangware`; // "\x1b[46mVangware\x1b[49m"

See

View source


backgroundGray

▸ backgroundGray<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Gray background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with gray background.

Remarks

Given an input string, it will return a new string with the ANSI codes for gray background around it.

Example

backgroundGray("Vangware"); // "\x1b[100mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundGray`Vangware`; // "\x1b[100mVangware\x1b[49m"

See

View source


backgroundGreen

▸ backgroundGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Green background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with green background.

Remarks

Given an input string, it will return a new string with the ANSI codes for green background around it.

Example

backgroundGreen("Vangware"); // "\x1b[42mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundGreen`Vangware`; // "\x1b[42mVangware\x1b[49m"

See

View source


backgroundMagenta

▸ backgroundMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Magenta background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with magenta background.

Remarks

Given an input string, it will return a new string with the ANSI codes for magenta background around it.

Example

backgroundMagenta("Vangware"); // "\x1b[45mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundMagenta`Vangware`; // "\x1b[45mVangware\x1b[49m"

See

View source


backgroundRed

▸ backgroundRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Red background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with red background.

Remarks

Given an input string, it will return a new string with the ANSI codes for red background around it.

Example

backgroundRed("Vangware"); // "\x1b[41mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundRed`Vangware`; // "\x1b[41mVangware\x1b[49m"

See

View source


backgroundWhite

▸ backgroundWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

White background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with white background.

Remarks

Given an input string, it will return a new string with the ANSI codes for white background around it.

Example

backgroundWhite("Vangware"); // "\x1b[47mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundWhite`Vangware`; // "\x1b[47mVangware\x1b[49m"

See

View source


backgroundYellow

▸ backgroundYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Yellow background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with yellow background.

Remarks

Given an input string, it will return a new string with the ANSI codes for yellow background around it.

Example

backgroundYellow("Vangware"); // "\x1b[43mVangware\x1b[49m"
// It can also be used as a tag function for tagged templates:
backgroundYellow`Vangware`; // "\x1b[43mVangware\x1b[49m"

See

View source

Common

Formatter

Ƭ Formatter: Function<readonly [input: TemplateStringsArray | string, expressions: ReadOnlyArray], string>

Formatter function that takes a string or a tagged template.

Remarks

Type to represent a function that works both directly on a string or as a tagged template function.

Example

const formatter: Formatter = (input, ...expressions) =>
	typeof input === "string"
		? input
		: input
				.flatMap((string, index) => [string, expressions[index] ?? ""])
				.join("");

formatter("Vangware"); // "Vangware"
formatter`Vangware`; // "Vangware"

See

Tagged templates

Param

Array of strings for template strings or a single string, followed by an array of expressions (if any).

View source


resetToInitialState

• Const resetToInitialState: "\u001bc"

RIS sequence.

Remarks

Resets the entire screen to initial state.

Example

console.log(resetToInitialState); // "\x1b[c"
stdout.write(resetToInitialState); // Resets the entire screen to initial state.

See

View source


controlSequenceIntroducer

▸ controlSequenceIntroducer<Code>(code): <Input>(input: Input) => `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}${Code}`

CSI sequence generator.

Type parameters

NameTypeDescription
Codeextends stringCSI code generic.

Parameters

NameTypeDescription
codeCodeCSI code.

Returns

fn

Curried function with code in context.

▸ <Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}${Code}`

Takes an input number and returns the CSI sequence.

Type parameters
NameTypeDescription
Inputextends number | readonly [Maybe<number>, Maybe<number>]CSI input generic.
Parameters
NameTypeDescription
inputInputCSI input.
Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}${Code}`

CSI sequence.

See

Remarks

Takes a code and an input number and returns the CSI sequence.

Example

const selectGraphicRendition = controlSequenceIntroducer("m");
selectGraphicRendition(13); // "\x1b[13m"
selectGraphicRendition(42); // "\x1b[42m"

See

View source


escapeSequence

▸ escapeSequence<Input>(input): `${Input}`

Takes an input string and returns an escaped sequence based on it.

Type parameters

NameTypeDescription
Inputextends stringString to escape generic.

Parameters

NameTypeDescription
inputInputString to escape.

Returns

`${Input}`

String with ESC character prepended.

Remarks

Escape sequences are used to control the cursor, change colors, and more in the terminal. They are preceded by the ESC character (ASCII code 27, or 0x1b). This functions prepends any given string with the ESC character.

Example

escapeSequence("Vangware"); // "\x1bVangware"

See

ANSI escape code

View source


format

▸ format<Close>(close): <Open>(open: Open) => <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

Format wrapper function.

Type parameters

NameTypeDescription
Closeextends numberClose string generic.

Parameters

NameTypeDescription
closeCloseClose string.

Returns

fn

Curried function with close in context.

▸ <Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

format function with close set.

Type parameters
NameTypeDescription
Openextends numberOpen string generic.
Parameters
NameTypeDescription
openOpenOpen string.
Returns

fn

Curried function with close and open in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

Formatted input string.

See

format

See

format

Remarks

Given an open, a close string and an input string, return formatted input (surrounded by open and close).

Example

format(13)(42)("Vangware"); // "\x1b[42mVangware\x1b[13m"
// It can also be used as a tag function for tagged templates:
format(13)(42)`Vangware`; // "\x1b[42mVangware\x1b[13m"

See

View source


mix

▸ mix(...formatters): Formatter

Composes formatters.

Parameters

NameTypeDescription
...formattersReadOnlyArray<Formatter>Array of formatters to be composed.

Returns

Formatter

Formatter composed of the given formatters.

Remarks

Given an array of formatters, it will return a new formatter that will apply all of them to the input string.

Example

const redTextWhiteBackground = mix(foregroundRed, backgroundWhite);

redTextWhiteBackground("Vangware");
// It can also be used as a tag function for tagged templates:
redTextWhiteBackground`Vangware`;

See

Formatter

View source


normalizeString

▸ normalizeString<Input>(input, ...expressions): Input extends string ? Input : string

Takes a string or a template string and returns a plain string.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameTypeDescription
inputInputString or template string.
...expressionsReadOnlyArrayPossible values passed to the template string.

Returns

Input extends string ? Input : string

Plain string.

Example

normalizeString(`Hello ${13}!`); // "Hello 13!"
normalizeString`Hello ${13}!`; // "Hello 13!"

See

Tagged templates

View source


optionalFormat

▸ optionalFormat<Close>(close): <Open>(open: Open) => <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

Process dependant format function.

Type parameters

NameType
Closeextends number

Parameters

NameType
closeClose

Returns

fn

Either the formatted string, or just the passed string.

▸ <Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

format function with close set.

Type parameters
NameTypeDescription
Openextends numberOpen string generic.
Parameters
NameTypeDescription
openOpenOpen string.
Returns

fn

Curried function with close and open in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First<Close> : ""};${Second<Close> extends number ? Second<Close> : ""}` : `${Close & number}`}m`

Formatted input string.

See

format

See

format

Remarks

Impure version of format which changes depending on the current NodeJS globalThis.process environment.

Example

// In a environment with color:
optionalFormat(42)(13)("Vangware"); // "\x1b[42mVangware\x1b[13m"
// In an environment without color:
optionalFormat(42)(13)("Vangware"); // "Vangware"
// It also works with tagged templates:
optionalFormat(42)(13)`Vangware`; // "\x1b[42mVangware\x1b[13m"

See

View source


selectGraphicRendition

▸ selectGraphicRendition<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}m`

Takes an input number and returns the a SGR sequence.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputInput to escape.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}m`

SGR sequence.

Example

controlSequenceIntroducer(13); // "\x1b[13m"
controlSequenceIntroducer(42); // "\x1b[42m"

See

View source

Cursor

cursorBack

▸ cursorBack<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}D`

Moves the cursor input cells back.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells back.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}D`

CUB sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

cursorBack(13); // "\x1b[13C"

See

View source


cursorDown

▸ cursorDown<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}B`

Moves the cursor input cells down.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells down.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}B`

CUD sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

cursorDown(13); // "\x1b[13B"

See

View source


cursorForward

▸ cursorForward<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}C`

Moves the cursor input cells forward.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells forward.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}C`

CUF sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

cursorForward(13); // "\x1b[13C"

See

View source


cursorHorizontalAbsolute

▸ cursorHorizontalAbsolute<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}G`

Moves cursor to the column input.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputColumn number.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}G`

CHA sequence.

Example

cursorHorizontalAbsolute(13); // "\x1b[13G"

See

View source


cursorNextLine

▸ cursorNextLine<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}E`

Moves cursor to beginning of the line input lines down.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines down.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}E`

CNL sequence.

Example

cursorNextLine(13); // "\x1b[13E"

See

View source


cursorPosition

▸ cursorPosition<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}H`

Moves the cursor to position input.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputPosition (row, column)

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}H`

CUP sequence.

Example

cursorPosition([13, 42]); // "\x1b[13;42H"
cursorPosition([undefined, 42]); // "\x1b[;42H"
cursorPosition([13, undefined]); // "\x1b[13;H"

See

View source


cursorPreviousLine

▸ cursorPreviousLine<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}F`

Moves cursor to beginning of the line input lines up.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines up.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}F`

CPL sequence.

Example

cursorPreviousLine(13); // "\x1b[13F"

See

View source


cursorUp

▸ cursorUp<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}A`

Moves the cursor input cells up.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells up.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}A`

CUU sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

cursorUp(13); // "\x1b[13A"

See

View source

Erase

eraseInDisplay

▸ eraseInDisplay<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}J`

Clear screen from cursor to beginning, to end of screen, or entire screen.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInput0 (to end of screen), 1 (to beginning of screen), or 2 (entire screen).

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}J`

ED sequence.

Example

eraseInDisplay(0); // "\x1b[0J" Clear from cursor to end of screen.
eraseInDisplay(1); // "\x1b[1J" Clear from cursor to beginning of screen.
eraseInDisplay(2); // "\x1b[2J" Clear entire screen.

See

View source


eraseInLine

▸ eraseInLine<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}K`

Erases the line from cursor to beginning, to end of line, or entire line.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInput0 (to end of line), 1 (to beginning of line), or 2 (entire line).

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}K`

EL sequence.

Remarks

inputerases…
0…to end of line.
1…to beginning of line.
2…entire line.

Example

eraseInLine(0); // "\x1b[0K" Clear from cursor to end of line.
eraseInLine(1); // "\x1b[1K" Clear from cursor to beginning of line.
eraseInLine(2); // "\x1b[2K" Clear entire line.

See

CSI (Control Sequence Introducer) sequences

View source

Foreground

foregroundBlack

▸ foregroundBlack<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Black foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with black foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for black foreground.

Example

foregroundBlack("Vangware"); // "\x1b[30mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBlack`Vangware`; // "\x1b[30mVangware\x1b[39m"

See

View source


foregroundBlue

▸ foregroundBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Blue foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with blue foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for blue foreground.

Example

foregroundBlue("Vangware"); // "\x1b[34mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBlue`Vangware`; // "\x1b[34mVangware\x1b[39m"

See

View source


foregroundBrightBlue

▸ foregroundBrightBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright blue foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright blue foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright blue foreground.

Example

foregroundBrightBlue("Vangware"); // "\x1b[94mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBrightBlue`Vangware`; // "\x1b[94mVangware\x1b[39m"

See

View source


foregroundBrightCyan

▸ foregroundBrightCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright Cyan foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright cyan foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright Cyan foreground.

Example

foregroundBrightCyan("Vangware"); // "\x1b[96mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBrightCyan`Vangware`; // "\x1b[96mVangware\x1b[39m"

See

View source


foregroundBrightGreen

▸ foregroundBrightGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright green foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright green foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright green foreground.

Example

foregroundBrightGreen("Vangware"); // "\x1b[92mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBrightGreen`Vangware`; // "\x1b[92mVangware\x1b[39m"

See

View source


foregroundBrightMagenta

▸ foregroundBrightMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright magenta foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright magenta foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright magenta foreground.

Example

foregroundBrightMagenta("Vangware"); // "\x1b[95mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBrightMagenta`Vangware`; // "\x1b[95mVangware\x1b[39m"

See

View source


foregroundBrightRed

▸ foregroundBrightRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright red foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright red foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright red foreground.

Example

foregroundBrightRed("Vangware"); // "\x1b[91mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBrightRed`Vangware`; // "\x1b[91mVangware\x1b[39m"

See

View source


foregroundBrightWhite

▸ foregroundBrightWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright white foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright white foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright white foreground.

Example

foregroundBrightWhite("Vangware"); // "\x1b[97mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBrightWhite`Vangware`; // "\x1b[97mVangware\x1b[39m"

See

View source


foregroundBrightYellow

▸ foregroundBrightYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright yellow foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright yellow foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright yellow foreground.

Example

foregroundBrightYellow("Vangware"); // "\x1b[93mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundBrightYellow`Vangware`; // "\x1b[93mVangware\x1b[39m"

See

View source


foregroundColor

▸ foregroundColor<Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}`

Foreground color code wrapper.

Type parameters

NameType
Openextends number

Parameters

NameType
openOpen

Returns

fn

Curried function with close ANSI code for foreground in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First<Open> : ""};${Second<Open> extends number ? Second<Open> : ""}` : `${Open & number}`}m${Input extends string ? Input : string}`

Formatted input string.

See

format

Remarks

Takes an open ANSI code and an input string and adds the open and close ANSI codes to that string (for foreground color).

Example

foregroundColor(13)("Vangware"); // "\x1b[13mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundColor(13)`Vangware`; // "\x1b[13mVangware\x1b[39m"

See

View source


foregroundCyan

▸ foregroundCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Cyan foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with cyan foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for cyan foreground.

Example

foregroundCyan("Vangware"); // "\x1b[36mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundCyan`Vangware`; // "\x1b[36mVangware\x1b[39m"

See

View source


foregroundGray

▸ foregroundGray<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Gray foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with gray foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for gray foreground.

Example

foregroundGray("Vangware"); // "\x1b[90mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundGray`Vangware`; // "\x1b[90mVangware\x1b[39m"

See

View source


foregroundGreen

▸ foregroundGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Green foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with green foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for green foreground.

Example

foregroundGreen("Vangware"); // "\x1b[32mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundGreen`Vangware`; // "\x1b[32mVangware\x1b[39m"

See

View source


foregroundMagenta

▸ foregroundMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Magenta foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with magenta foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for magenta foreground.

Example

foregroundMagenta("Vangware"); // "\x1b[35mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundMagenta`Vangware`; // "\x1b[35mVangware\x1b[39m"

See

View source


foregroundRed

▸ foregroundRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Red foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with red foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for red foreground.

Example

foregroundRed("Vangware"); // "\x1b[31mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundRed`Vangware`; // "\x1b[31mVangware\x1b[39m"

See

View source


foregroundWhite

▸ foregroundWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

White foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with white foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for white foreground.

Example

foregroundWhite("Vangware"); // "\x1b[37mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundWhite`Vangware`; // "\x1b[37mVangware\x1b[39m"

See

View source


foregroundYellow

▸ foregroundYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Yellow foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with yellow foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for yellow foreground.

Example

foregroundYellow("Vangware"); // "\x1b[33mVangware\x1b[39m"
// It can also be used as a tag function for tagged templates:
foregroundYellow`Vangware`; // "\x1b[33mVangware\x1b[39m"

See

View source

Scroll

scrollDown

▸ scrollDown<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}S`

Scroll whole page down by input lines. New lines are added at the top.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines down.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}S`

SD sequence.

Example

scrollDown(13); // "\x1b[13S"

See

View source


scrollUp

▸ scrollUp<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}S`

Scroll whole page up by input lines. New lines are added at the bottom.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines up.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First<Input> : ""};${Second<Input> extends number ? Second<Input> : ""}` : `${Input & number}`}S`

SU sequence.

Example

scrollUp(13); // "\x1b[13S"

See

View source

Text

bold

▸ bold<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bold code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bold format.

Remarks

Given an input string, it will return a new string with the ANSI codes for bold around it.

Example

bold("Vangware"); // "\x1b[1mVangware\x1b[22m"
// It can also be used as a tag function for tagged templates:
bold`Vangware`; // "\x1b[1mVangware\x1b[22m"

See

View source


dimmed

▸ dimmed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Dimmed code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with dimmed format.

Remarks

Given an input string, it will return a new string with the ANSI codes for dimmed around it.

Example

dimmed("Vangware"); // "\x1b[2mVangware\x1b[22m"
// It can also be used as a tag function for tagged templates:
dimmed`Vangware`; // "\x1b[2mVangware\x1b[22m"

See

View source


inverse

▸ inverse<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Inverse code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with inverse format.

Remarks

Given an input string, it will return a new string with the ANSI codes for inverse around it.

Example

inverse("Vangware"); // "\x1b[7mVangware\x1b[27m"
// It can also be used as a tag function for tagged templates:
inverse`Vangware`; // "\x1b[7mVangware\x1b[27m"

See

View source


italic

▸ italic<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Italic code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with italic format.

Remarks

Given an input string, it will return a new string with the ANSI codes for italic around it.

Example

italic("Vangware"); // "\x1b[3mVangware\x1b[23m"
// It can also be used as a tag function for tagged templates:
italic`Vangware`; // "\x1b[3mVangware\x1b[23m"

See

View source


strikethrough

▸ strikethrough<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Takes an input string and adds the ANSI codes for strikethrough text.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with strikethrough format.

Example

strikethrough("Vangware"); // "\x1b[9mVangware\x1b[29m"
// It can also be used as a tag function for tagged templates:
strikethrough`Vangware`; // "\x1b[9mVangware\x1b[29m"

See

optionalFormat

View source


underlined

▸ underlined<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Takes an input string and adds the ANSI codes for underlined text.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with underlined format.

Example

underlined("Vangware"); // "\x1b[4mVangware\x1b[24m"
// It can also be used as a tag function for tagged templates:
underlined`Vangware`; // "\x1b[4mVangware\x1b[24m"

See

optionalFormat

View source