Sha256: c5bb23b3ca69e97ddefdb76724b1a7936ac18b5e47c3fe3c5391969d6e6d06f8

Contents?: true

Size: 468 Bytes

Versions: 76

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

76 entries across 24 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.51 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.51 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.51 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.50 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.50 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.50 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.50 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.49 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.49 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.49 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.49 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.48 node_modules/widest-line/node_modules/string-width/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.48 node_modules/@isaacs/cliui/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.48 node_modules/wrap-ansi/node_modules/strip-ansi/index.js
immosquare-cleaner-0.1.48 node_modules/boxen/node_modules/string-width/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/wrap-ansi/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.47 node_modules/boxen/node_modules/string-width/node_modules/strip-ansi/index.js