Skip to content

Commit

Permalink
remark: perf penalty for reset
Browse files Browse the repository at this point in the history
  • Loading branch information
gtm-nayan committed May 27, 2023
1 parent c16c6bc commit 70aa357
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Expand Up @@ -7,5 +7,8 @@ export default function stripAnsi(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/test, replace does it automatically and doing it manually
// has a perf penalty.
return string.replace(regex, '');
}

0 comments on commit 70aa357

Please sign in to comment.