Skip to content

Commit

Permalink
Merge branch 'perf-cache-regex' of https://github.com/gtm-nayan/strip…
Browse files Browse the repository at this point in the history
…-ansi into perf-cache-regex
  • Loading branch information
gtm-nayan committed May 27, 2023
2 parents 0078ce6 + d54a07a commit d1dc91d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
@@ -1,11 +1,12 @@
import ansiRegex from 'ansi-regex';

const re = ansiRegex();
const regex = ansiRegex();

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

re.lastIndex = 0;
return string.replace(re, '');
regex.lastIndex = 0;
return string.replace(regex, '');
}

0 comments on commit d1dc91d

Please sign in to comment.