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
1 parent
5cb7e20
commit 89dc7f6
Showing
4 changed files
with
18 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). | ||
*/ | ||
export default function stripAnsi(str: string): string; |
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,4 +1,7 @@ | ||
'use strict'; | ||
const ansiRegex = require('ansi-regex'); | ||
|
||
module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; | ||
const stripAnsi = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; | ||
|
||
module.exports = stripAnsi; | ||
module.exports.default = stripAnsi; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {expectType} from 'tsd-check'; | ||
import stripAnsi from '.'; | ||
|
||
expectType<string>(stripAnsi('\u001b[4mcake\u001b[0m')); |
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