https://github.com/chalk/strip-ansi-stream
Strip ANSI escape codes
https://github.com/chalk/strip-ansi-stream
ansi ansi-escape-codes color command-line console javascript nodejs streaming strip-ansi terminal
Last synced: 16 days ago
JSON representation
Strip ANSI escape codes
- Host: GitHub
- URL: https://github.com/chalk/strip-ansi-stream
- Owner: chalk
- License: mit
- Created: 2017-09-20T04:22:59.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2021-09-13T18:30:19.000Z (over 3 years ago)
- Last Synced: 2025-03-13T18:52:09.350Z (about 1 month ago)
- Topics: ansi, ansi-escape-codes, color, command-line, console, javascript, nodejs, streaming, strip-ansi, terminal
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 34
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# strip-ansi-stream
> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```
$ npm install strip-ansi-stream
```## Usage
```js
import stripAnsiStream from 'strip-ansi-stream';const stream = stripAnsiStream();
stream.on('data', data => {
console.log(data);
//=> 'Unicorn'
//=> 'bar'
})stream.write('\u001B[4mUnicorn\u001B[0m');
stream.end('\u001B[0;33;49;3;9;4mbar\u001B[0m');
```## API
### stripAnsiStream()
Returns a [`Transform` stream](https://nodejs.org/api/stream.html#stream_class_stream_transform) that strips ANSI escape codes.
## Related
- [strip-ansi](https://github.com/chalk/strip-ansi) - Non-streaming version of this module
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right