-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
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}\``); | ||
} | ||
|
||
return string.replace(ansiRegex(), ''); | ||
// 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, ''); | ||
} |
2 changes: 1 addition & 1 deletion
2
node_modules/@isaacs/cliui/node_modules/strip-ansi/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
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}\``); | ||
} | ||
|
||
return string.replace(ansiRegex(), ''); | ||
// 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, ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters