Sha256: c5bb23b3ca69e97ddefdb76724b1a7936ac18b5e47c3fe3c5391969d6e6d06f8

Contents?: true

Size: 468 Bytes

Versions: 80

Compression:

Stored size: 468 Bytes

Contents

import ansiRegex from 'ansi-regex';

const regex = ansiRegex();

export default function stripAnsi(string) {
	if (typeof string !== 'string') {
		throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
	}

	// Even though the regex is global, we don't need to reset the `.lastIndex`
	// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
	// and doing it manually has a performance penalty.
	return string.replace(regex, '');
}

Version data entries

80 entries across 25 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.47 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.47 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.47 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.47 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.46 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.46 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.46 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.46 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.45 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.45 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.45 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.45 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.44 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.44 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.44 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.44 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.43 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.43 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.43 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.43 node_modules/wrap-ansi/node_modules/strip-ansi/index.js