Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ansi

Hierarchy

  • Ansi

Index

Properties

Methods

Properties

cursor

cursor: Cursor

erase

erase: Erase

keys

keys: Keys

style

style: Style

Methods

format

  • format(str: string, styleArray: Array<string>): string
  • A convenience function, applying the provided styles to the input string and then resetting.

    Inline styling can be applied using the syntax [style-list]{text to format}, where style-list is a space-separated list of styles from style. For example [bold white bg-red]{bold white text on a red background}.

    example

    ansi.format('what?', 'green') '\u001b[32mwhat?\u001b[0m'

    ansi.format('what?', ['green', 'bold']) '\u001b[32;1mwhat?\u001b[0m'

    ansi.format('[green bold]{what?}') '\u001b[32;1mwhat?\u001b[0m'

    Parameters

    • str: string

      the string to format

    • styleArray: Array<string>

      a list of styles to add to the input string

    Returns string

styles

  • styles(effectArray: string | Array<string>): string
  • Returns an ansi sequence setting one or more effects

    example

    ansi.styles('green') '\u001b[32m'

    ansi.styles([ 'green', 'underline' ]) '\u001b[32;4m'

    Parameters

    • effectArray: string | Array<string>

    Returns string

Generated using TypeDoc