14
14
npm install anymatchx
15
15
```
16
16
17
- #### anymatch (matchers, testString, [ returnIndex] )
17
+ #### anymatch(matchers, testString, [ returnIndex] )
18
18
* __ matchers__ : (_ Array|String|RegExp|Function_ )
19
19
String to be directly matched, string with glob patterns, regular expression
20
20
test, function that takes the testString as an argument and returns a truthy
@@ -25,15 +25,13 @@ the first matcher that that testString matched, or -1 if no match, instead of a
25
25
boolean result.
26
26
27
27
``` js
28
- var anymatch = require (' anymatch' );
28
+ const anymatch = require (' anymatch' );
29
29
30
- var matchers = [
30
+ const matchers = [
31
31
' path/to/file.js' ,
32
32
' path/anyjs/**/*.js' ,
33
33
/ foo\. js$ / ,
34
- function (string ) {
35
- return string .indexOf (' bar' ) !== - 1 && string .length > 10
36
- }
34
+ (string ) => string .includes (' bar' ) && string .length > 10
37
35
];
38
36
39
37
anymatch (matchers, ' path/to/file.js' ); // true
@@ -48,8 +46,6 @@ anymatch(matchers, 'path/anyjs/foo.js', true); // 1
48
46
49
47
// skip matchers
50
48
anymatch (matchers, ' path/to/file.js' , false , 1 ); // false
51
- anymatch (matchers, ' path/anyjs/foo.js' , true , 2 , 3 ); // 2
52
- anymatch (matchers, ' path/to/bar.js' , true , 0 , 3 ); // -1
53
49
54
50
// using globs to match directories and their children
55
51
anymatch (' node_modules' , ' node_modules' ); // true
@@ -59,7 +55,7 @@ anymatch('node_modules/**', '/absolute/path/to/node_modules/somelib/index.js');
59
55
anymatch (' **/node_modules/**' , ' /absolute/path/to/node_modules/somelib/index.js' ); // true
60
56
```
61
57
62
- #### anymatch (matchers)
58
+ #### anymatch(matchers)
63
59
You can also pass in only your matcher(s) to get a curried function that has
64
60
already been bound to the provided matching criteria. This can be used as an
65
61
` Array#filter ` callback.
0 commit comments