File tree 3 files changed +46
-2
lines changed
3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change
1
+ declare namespace ansiRegex {
2
+ interface Options {
3
+ /**
4
+ Match only the first ANSI escape.
5
+
6
+ @default false
7
+ */
8
+ onlyFirst : boolean ;
9
+ }
10
+ }
11
+
12
+ /**
13
+ Regular expression for matching ANSI escape codes.
14
+
15
+ @example
16
+ ```
17
+ import ansiRegex = require('ansi-regex');
18
+
19
+ ansiRegex().test('\u001B[4mcake\u001B[0m');
20
+ //=> true
21
+
22
+ ansiRegex().test('cake');
23
+ //=> false
24
+
25
+ '\u001B[4mcake\u001B[0m'.match(ansiRegex());
26
+ //=> ['\u001B[4m', '\u001B[0m']
27
+
28
+ '\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
29
+ //=> ['\u001B[4m']
30
+
31
+ '\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
32
+ //=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
33
+ ```
34
+ */
35
+ declare function ansiRegex ( options ?: ansiRegex . Options ) : RegExp ;
36
+
37
+ export = ansiRegex ;
Original file line number Diff line number Diff line change
1
+ import { expectType } from 'tsd' ;
2
+ import ansiRegex from '.' ;
3
+
4
+ expectType < RegExp > ( ansiRegex ( ) ) ;
5
+ expectType < RegExp > ( ansiRegex ( { onlyFirst : true } ) ) ;
Original file line number Diff line number Diff line change 13
13
"node" : " >=8"
14
14
},
15
15
"scripts" : {
16
- "test" : " xo && ava" ,
16
+ "test" : " xo && ava && tsd " ,
17
17
"view-supported" : " node fixtures/view-codes.js"
18
18
},
19
19
"files" : [
20
- " index.js"
20
+ " index.js" ,
21
+ " index.d.ts"
21
22
],
22
23
"keywords" : [
23
24
" ansi" ,
48
49
],
49
50
"devDependencies" : {
50
51
"ava" : " ^1.4.1" ,
52
+ "tsd" : " ^0.9.0" ,
51
53
"xo" : " ^0.24.0"
52
54
}
53
55
}
You can’t perform that action at this time.
0 commit comments