strip-ansi
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
ansi-regex | 2.1.1 | 2.29 kB | MIT | prod |
Strip-ansi is an essential JavaScript package utilized for removing ANSI escape codes from strings. ANSI escape codes are characters embedded in the text used to control color, cursor position, and other options on video text terminals. Hence, if you want your strings free from these control characters, strip-ansi is your tool of choice.
To use strip-ansi, follow the steps below:
$ npm install strip-ansi
import stripAnsi from 'strip-ansi';
// Apply strip-ansi
let plainText = stripAnsi('\u001B[4mUnicorn\u001B[0m');
console.log(plainText); // Output: 'Unicorn'
let websiteLink = stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007');
console.log(websiteLink); // Output: 'Click'
The stripAnsi()
function is used to transform ANSI escape codes in strings into readable text/strings.
The documentation for strip-ansi is not separately maintained but can be found in the README file within the project's GitHub repository. Additional information and examples may also be available within the repository itself: git+https://github.com/chalk/strip-ansi.git. As a community-driven project, updates and changes are potentially frequent, and the repository often serves as the best and most current resource for developers.