File tree 5 files changed +20
-10
lines changed
@isaacs/cliui/node_modules/strip-ansi
wrap-ansi/node_modules/strip-ansi
5 files changed +20
-10
lines changed Original file line number Diff line number Diff line change 1
1
import ansiRegex from 'ansi-regex' ;
2
2
3
+ const regex = ansiRegex ( ) ;
4
+
3
5
export default function stripAnsi ( string ) {
4
6
if ( typeof string !== 'string' ) {
5
7
throw new TypeError ( `Expected a \`string\`, got \`${ typeof string } \`` ) ;
6
8
}
7
9
8
- return string . replace ( ansiRegex ( ) , '' ) ;
10
+ // Even though the regex is global, we don't need to reset the `.lastIndex`
11
+ // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
12
+ // and doing it manually has a performance penalty.
13
+ return string . replace ( regex , '' ) ;
9
14
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " strip-ansi" ,
3
- "version" : " 7.0.1 " ,
3
+ "version" : " 7.1.0 " ,
4
4
"description" : " Strip ANSI escape codes from a string" ,
5
5
"license" : " MIT" ,
6
6
"repository" : " chalk/strip-ansi" ,
Original file line number Diff line number Diff line change 1
1
import ansiRegex from 'ansi-regex' ;
2
2
3
+ const regex = ansiRegex ( ) ;
4
+
3
5
export default function stripAnsi ( string ) {
4
6
if ( typeof string !== 'string' ) {
5
7
throw new TypeError ( `Expected a \`string\`, got \`${ typeof string } \`` ) ;
6
8
}
7
9
8
- return string . replace ( ansiRegex ( ) , '' ) ;
10
+ // Even though the regex is global, we don't need to reset the `.lastIndex`
11
+ // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
12
+ // and doing it manually has a performance penalty.
13
+ return string . replace ( regex , '' ) ;
9
14
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " strip-ansi" ,
3
- "version" : " 7.0.1 " ,
3
+ "version" : " 7.1.0 " ,
4
4
"description" : " Strip ANSI escape codes from a string" ,
5
5
"license" : " MIT" ,
6
6
"repository" : " chalk/strip-ansi" ,
Original file line number Diff line number Diff line change 1329
1329
}
1330
1330
},
1331
1331
"node_modules/@isaacs/cliui/node_modules/strip-ansi": {
1332
- "version": "7.0.1 ",
1333
- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1 .tgz",
1334
- "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw ==",
1332
+ "version": "7.1.0 ",
1333
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0 .tgz",
1334
+ "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ ==",
1335
1335
"inBundle": true,
1336
1336
"dependencies": {
1337
1337
"ansi-regex": "^6.0.1"
15231
15231
}
15232
15232
},
15233
15233
"node_modules/wrap-ansi/node_modules/strip-ansi": {
15234
- "version": "7.0.1 ",
15235
- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1 .tgz",
15236
- "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw ==",
15234
+ "version": "7.1.0 ",
15235
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0 .tgz",
15236
+ "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ ==",
15237
15237
"inBundle": true,
15238
15238
"dependencies": {
15239
15239
"ansi-regex": "^6.0.1"
You can’t perform that action at this time.
0 commit comments