Options
All
  • Public
  • Public/Protected
  • All
Menu

@vangware/ansi

Index

Common Type aliases

Formatter

Formatter: (input: Readonly<TemplateStringsArray> | string, ...expressions: ReadOnlyArray) => string

Type declaration

    • (input: Readonly<TemplateStringsArray> | string, ...expressions: ReadOnlyArray): string
    • Formatter function that takes a string or a tagged template.

      Parameters

      • input: Readonly<TemplateStringsArray> | string

        Array of strings for template strings or a single string.

      • Rest ...expressions: ReadOnlyArray

        Array of expressions (if any).

      Returns string

      A plain string.

Background Functions

Const backgroundBlack

  • backgroundBlack(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for black background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with black background.

Const backgroundBlue

  • backgroundBlue(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for blue background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with blue background.

Const backgroundBrightBlue

  • backgroundBrightBlue(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bright blue background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright blue background.

Const backgroundBrightCyan

  • backgroundBrightCyan(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bright cyan background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright cyan background.

Const backgroundBrightGreen

  • backgroundBrightGreen(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bright green background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright green background.

Const backgroundBrightMagenta

  • backgroundBrightMagenta(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bright magenta background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright magenta background.

Const backgroundBrightRed

  • backgroundBrightRed(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bright red background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright red background.

Const backgroundBrightWhite

  • backgroundBrightWhite(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bright white background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright white background.

Const backgroundBrightYellow

  • backgroundBrightYellow(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bright yellow background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright yellow background.

Const backgroundColor

  • 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"

    Type parameters

    • Open: number

    Parameters

    • open: Open

    Returns Formatter

    Curried function with close ANSI code for background in context.

Const backgroundCyan

  • backgroundCyan(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for cyan background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with cyan background.

Const backgroundGray

  • backgroundGray(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for gray background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with gray background.

Const backgroundGreen

  • backgroundGreen(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for green background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with green background.

Const backgroundMagenta

  • backgroundMagenta(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for magenta background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with magenta background.

Const backgroundRed

  • backgroundRed(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for red background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with red background.

Const backgroundWhite

  • backgroundWhite(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for white background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with white background.

Const backgroundYellow

  • backgroundYellow(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for yellow background.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with yellow background.

Common Functions

Const ansi

  • ansi<Input>(input: Input): `[${Input}m`
  • Takes an input number and returns the escape ANSI sequence.

    example
    ansi(13); // "\x1b[13m"
    ansi(42); // "\x1b[42m"

    Type parameters

    • Input: number

    Parameters

    • input: Input

      Input to escape.

    Returns `[${Input}m`

    Escaped ANSI sequence.

Const format

  • format<Close>(close: Close): <Open>(open: Open) => Formatter
  • Given an open, a close value 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"

    Type parameters

    • Close: number

    Parameters

    • close: Close

      Close value.

    Returns <Open>(open: Open) => Formatter

    Curried function with close in context.

      • Type parameters

        • Open: number

        Parameters

        • open: Open

        Returns Formatter

Const formattingEnabled

  • formattingEnabled(process?: { env?: ProcessEnv; stdout?: Pick<WriteStream & { fd: 1 }, "isTTY"> }): boolean
  • Given a NodeJS process, return true if colors are enabled.

    example
    formattingEnabled(process); // true if colors enabled, false otherwise
    

    Parameters

    • process: { env?: ProcessEnv; stdout?: Pick<WriteStream & { fd: 1 }, "isTTY"> } = {}

      NodeJS process.

      • Optional Readonly env?: ProcessEnv
      • Optional Readonly stdout?: Pick<WriteStream & { fd: 1 }, "isTTY">

    Returns boolean

    true if colors are enabled.

Const mix

  • Composes formatters.

    example
    const redTextWhiteBackground = mix([foregroundRed, backgroundWhite]);

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

    Parameters

    • formatters: ReadOnlyArray<Formatter>

      Array of formatters to be composed.

    Returns Formatter

    Formatter composed of the given formatters.

Const normalizeString

  • normalizeString(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes a string or a template string and returns a plain string.

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

    Parameters

    • input: string | Readonly<TemplateStringsArray>

      String or template string.

    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    Plain string.

Const optionalFormat

  • optionalFormat<Close>(close: Close): <Open>(open: Open) => Formatter
  • Impure version of format which changes depending on the current NodeJS 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"

    Type parameters

    • Close: number

    Parameters

    • close: Close

    Returns <Open>(open: Open) => Formatter

    Either the formatted string, or just the passed string.

      • Type parameters

        • Open: number

        Parameters

        • open: Open

        Returns Formatter

Foreground Functions

Const foregroundBlack

  • foregroundBlack(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with black foreground.

Const foregroundBlue

  • foregroundBlue(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with blue foreground.

Const foregroundBrightBlue

  • foregroundBrightBlue(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright blue foreground.

Const foregroundBrightCyan

  • foregroundBrightCyan(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright cyan foreground.

Const foregroundBrightGreen

  • foregroundBrightGreen(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright green foreground.

Const foregroundBrightMagenta

  • foregroundBrightMagenta(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright magenta foreground.

Const foregroundBrightRed

  • foregroundBrightRed(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright red foreground.

Const foregroundBrightWhite

  • foregroundBrightWhite(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright white foreground.

Const foregroundBrightYellow

  • foregroundBrightYellow(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bright yellow foreground.

Const foregroundColor

  • Takes an open ANSI code and an input string and adds the open and close ANSI codes to that string (for text 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"

    Type parameters

    • Open: number

    Parameters

    • open: Open

    Returns Formatter

    Curried function with close ANSI code for text color in context.

Const foregroundCyan

  • foregroundCyan(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with cyan foreground.

Const foregroundGray

  • foregroundGray(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with gray foreground.

Const foregroundGreen

  • foregroundGreen(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with green foreground.

Const foregroundMagenta

  • foregroundMagenta(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with magenta foreground.

Const foregroundRed

  • foregroundRed(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with red foreground.

Const foregroundWhite

  • foregroundWhite(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with white foreground.

Const foregroundYellow

  • foregroundYellow(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds 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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with yellow foreground.

Text Functions

Const bold

  • bold(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for bold text.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with bold format.

Const dimmed

  • dimmed(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for dimmed text.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with dimmed format.

Const inverse

  • inverse(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for inverse text.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with inverse format.

Const italic

  • italic(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for italic text.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with italic format.

Const strikethrough

  • strikethrough(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for strikethrough text.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with strikethrough format.

Const underlined

  • underlined(input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
  • Takes an input string and adds the ANSI codes for underlined text.

    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"

    Parameters

    • input: string | Readonly<TemplateStringsArray>
    • Rest ...expressions: ReadOnlyArray<unknown>

    Returns string

    input string with underlined format.