Skip to main content

ANSICode

Index

Functions

color

  • color(value: Color): ANSIWrapper
  • Return the ANSI escape sequence for the given color.

    @example
    color('red')('foo') // '\x1b[31mfoo\x1b[39m'

fontStyle

  • fontStyle(value: FontStyle): ANSIWrapper
  • Retrieves the ANSI escape code for a given font style.

    @example
    fontStyle('italic')('foo');// '\u001B[3mfoo\u001B[22m');

fontWeight

  • fontWeight(value: FontWeight): ANSIWrapper
  • Retrieves the ANSI escape code for a given font weight.

    @example
    fontWeight('bold')('foo') // '\x1b[1mfoo\x1b[22m'

format

  • format(args: number[], code: string): string

strip

  • strip(expression: string): string
  • Strip ANSI escape codes from the string.

    @example
    ANSICode.strip(red("Hello, world!"));// == "Hello, world!"

style

  • style(value: Partial<Style>): (_: string) => string
  • Apply ANSI styles to a string.

    @example
    ANSICode.style({ color: 'red', fontWeight: 'bold' })('foo');

wrap

  • wrap(open: number[], close: number, code: string): ANSIWrapper
  • Wraps a given string with ANSI escape codes for styling.

    @example