Function format

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

    Returns

    Curried function with close in context.

    Type Parameters

    • Close extends number

    Parameters

    • close: Close

      Close value.

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

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

        • Open extends number

        Parameters

        • 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