JSPM

strip-ansi-control-characters

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 86739
  • Score
    100M100P100Q177098F
  • License MIT

Strips ANSI Control Characters from string or stream

Package Exports

  • strip-ansi-control-characters

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (strip-ansi-control-characters) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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

function stripFromString(input: string): string
function stripFromStream(bufferEncoding: string = 'utf8'): stream.Duplex

Usage

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