Home > @rushstack/node-core-library > AnsiEscape

AnsiEscape class

Operations for working with text strings that contain ANSI escape codes. The most commonly used escape codes set the foreground/background color for console output.

Signature:

export declare class AnsiEscape 

Methods

Method Modifiers Description
formatForTests(text, options) static Replaces ANSI escape codes with human-readable tokens. This is useful for unit tests that compare text strings in test assertions or snapshot files.
removeCodes(text) static Returns the input text with all ANSI escape codes removed. For example, this is useful when saving colorized console output to a log file.