Function backgroundColor

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


    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"


    Curried function with close ANSI code for background in context.

    Type Parameters

    • Open extends number


    • open: Open

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

      • (input: string | Readonly<TemplateStringsArray>, ...expressions: ReadOnlyArray<unknown>): string
      • Parameters

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

        Returns string