ANSICode
Index
Functions
color
- color('red')('foo') // '\x1b[31mfoo\x1b[39m'
fontStyle
Retrieves the ANSI escape code for a given font style.
fontStyle('italic')('foo');// '\u001B[3mfoo\u001B[22m');
fontWeight
Retrieves the ANSI escape code for a given font weight.
fontWeight('bold')('foo') // '\x1b[1mfoo\x1b[22m'
format
- ANSICode.format([1, 2], 'm');// '\u001b[1;2m'
See more at https://en.wikipedia.org/wiki/ANSI_escape_code
strip
Strip ANSI escape codes from the string.
ANSICode.strip(red("Hello, world!"));// == "Hello, world!"
style
Apply ANSI styles to a string.
ANSICode.style({ color: 'red', fontWeight: 'bold' })('foo');
wrap
Wraps a given string with ANSI escape codes for styling.
ANSICode.wrap([1, 4, 42], 0, 'm')('foo'); // '\u001B[1;4;42mfoo\u001B[0m'
Return the ANSI escape sequence for the given color.