Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raeesbhatti/strip-ansi-control-characters
Strips ANSI Control Characters from string or stream
https://github.com/raeesbhatti/strip-ansi-control-characters
Last synced: 4 days ago
JSON representation
Strips ANSI Control Characters from string or stream
- Host: GitHub
- URL: https://github.com/raeesbhatti/strip-ansi-control-characters
- Owner: RaeesBhatti
- License: mit
- Created: 2020-04-13T22:26:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-08T17:42:35.000Z (over 4 years ago)
- Last Synced: 2024-09-27T06:48:27.129Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# strip-ansi-control-characters
Strips ANSI Control Characters from string or stream.## Use cases
If you spawn a child process in NodeJS with `inherit` or
`pipe` -> `process.std{out,err}` as `stdio`, the child process can clear
terminal screen or mangle information printed by your application.
This package allows you to show output from child process with all colors
and formatting but without those pesky clear screen or clear line
control characters.## API
```js
function stripFromString(input: string): string
function stripFromStream(bufferEncoding: string = 'utf8'): stream.Duplex
```## Usage
```js
const stripAnsiCc = require('strip-ansi-control-characters');
const child_process = require('child_process');const ps = child_process.spawn('vuepress', ['dev'], {
env: process.env,
stdio: 'pipe',
});ps.stdout.pipe(stripAnsiCc.stream()).pipe(process.stdout);
ps.stderr.pipe(stripAnsiCc.stream()).pipe(process.stderr);
```## License
MIT license - file included in repo