micromatch 3.0.5 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of micromatch might be problematic. Click here for more details.
- package/README.md +114 -58
- package/index.js +38 -0
- package/package.json +2 -2
package/README.md
CHANGED
@@ -398,7 +398,30 @@ console.log(isMatch('a.b'));
|
|
398
398
|
//=> true
|
399
399
|
```
|
400
400
|
|
401
|
-
### [.
|
401
|
+
### [.capture](index.js#L536)
|
402
|
+
|
403
|
+
Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
|
404
|
+
|
405
|
+
**Params**
|
406
|
+
|
407
|
+
* `pattern` **{String}**: Glob pattern to use for matching.
|
408
|
+
* `string` **{String}**: String to match
|
409
|
+
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
|
410
|
+
* `returns` **{Boolean}**: Returns an array of captures if the string matches the glob pattern, otherwise `null`.
|
411
|
+
|
412
|
+
**Example**
|
413
|
+
|
414
|
+
```js
|
415
|
+
var mm = require('micromatch');
|
416
|
+
mm.capture(pattern, string[, options]);
|
417
|
+
|
418
|
+
console.log(mm.capture('test/*.js', 'test/foo.js));
|
419
|
+
//=> ['foo']
|
420
|
+
console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
421
|
+
//=> null
|
422
|
+
```
|
423
|
+
|
424
|
+
### [.makeRe](index.js#L571)
|
402
425
|
|
403
426
|
Create a regular expression from the given glob `pattern`.
|
404
427
|
|
@@ -418,7 +441,7 @@ console.log(mm.makeRe('*.js'));
|
|
418
441
|
//=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
|
419
442
|
```
|
420
443
|
|
421
|
-
### [.braces](index.js#
|
444
|
+
### [.braces](index.js#L618)
|
422
445
|
|
423
446
|
Expand the given brace `pattern`.
|
424
447
|
|
@@ -439,7 +462,7 @@ console.log(mm.braces('foo/{a,b}/bar', {expand: true}));
|
|
439
462
|
//=> ['foo/(a|b)/bar']
|
440
463
|
```
|
441
464
|
|
442
|
-
### [.create](index.js#
|
465
|
+
### [.create](index.js#L685)
|
443
466
|
|
444
467
|
Parses the given glob `pattern` and returns an array of abstract syntax trees (ASTs), with the compiled `output` and optional source `map` on each AST.
|
445
468
|
|
@@ -481,7 +504,7 @@ console.log(mm.create('abc/*.js'));
|
|
481
504
|
// idx: 6 }]
|
482
505
|
```
|
483
506
|
|
484
|
-
### [.parse](index.js#
|
507
|
+
### [.parse](index.js#L732)
|
485
508
|
|
486
509
|
Parse the given `str` with the given `options`.
|
487
510
|
|
@@ -514,7 +537,7 @@ console.log(ast);
|
|
514
537
|
// { type: 'eos', val: '' } ] }
|
515
538
|
```
|
516
539
|
|
517
|
-
### [.compile](index.js#
|
540
|
+
### [.compile](index.js#L785)
|
518
541
|
|
519
542
|
Compile the given `ast` or string with the given `options`.
|
520
543
|
|
@@ -548,7 +571,7 @@ console.log(mm.compile(ast));
|
|
548
571
|
// parsingErrors: [] }
|
549
572
|
```
|
550
573
|
|
551
|
-
### [.clearCache](index.js#
|
574
|
+
### [.clearCache](index.js#L806)
|
552
575
|
|
553
576
|
Clear the regex cache.
|
554
577
|
|
@@ -957,59 +980,92 @@ npm i -d && npm run benchmark
|
|
957
980
|
|
958
981
|
### Latest results
|
959
982
|
|
960
|
-
As of September
|
983
|
+
As of September 11, 2017 (longer bars are better):
|
961
984
|
|
962
985
|
```sh
|
963
|
-
# braces-globstar-large-list
|
964
|
-
micromatch ██████████████████████████████████████████████████ (
|
965
|
-
minimatch █ (
|
966
|
-
multimatch █ (
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
micromatch
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
#
|
999
|
-
micromatch ██████████████████████████████████████████████████ (
|
1000
|
-
minimatch
|
1001
|
-
multimatch
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
986
|
+
# braces-globstar-large-list (485691 bytes)
|
987
|
+
micromatch ██████████████████████████████████████████████████ (517 ops/sec ±0.49%)
|
988
|
+
minimatch █ (18.92 ops/sec ±0.54%)
|
989
|
+
multimatch █ (18.94 ops/sec ±0.62%)
|
990
|
+
|
991
|
+
micromatch is faster by an avg. of 2,733%
|
992
|
+
|
993
|
+
# braces-multiple (3362 bytes)
|
994
|
+
micromatch ██████████████████████████████████████████████████ (33,625 ops/sec ±0.45%)
|
995
|
+
minimatch (2.92 ops/sec ±3.26%)
|
996
|
+
multimatch (2.90 ops/sec ±2.76%)
|
997
|
+
|
998
|
+
micromatch is faster by an avg. of 1,156,935%
|
999
|
+
|
1000
|
+
# braces-range (727 bytes)
|
1001
|
+
micromatch █████████████████████████████████████████████████ (155,220 ops/sec ±0.56%)
|
1002
|
+
minimatch ██████ (20,186 ops/sec ±1.27%)
|
1003
|
+
multimatch ██████ (19,809 ops/sec ±0.60%)
|
1004
|
+
|
1005
|
+
micromatch is faster by an avg. of 776%
|
1006
|
+
|
1007
|
+
# braces-set (2858 bytes)
|
1008
|
+
micromatch █████████████████████████████████████████████████ (24,354 ops/sec ±0.92%)
|
1009
|
+
minimatch █████ (2,566 ops/sec ±0.56%)
|
1010
|
+
multimatch ████ (2,431 ops/sec ±1.25%)
|
1011
|
+
|
1012
|
+
micromatch is faster by an avg. of 975%
|
1013
|
+
|
1014
|
+
# globstar-large-list (485686 bytes)
|
1015
|
+
micromatch █████████████████████████████████████████████████ (504 ops/sec ±0.45%)
|
1016
|
+
minimatch ███ (33.36 ops/sec ±1.08%)
|
1017
|
+
multimatch ███ (33.19 ops/sec ±1.35%)
|
1018
|
+
|
1019
|
+
micromatch is faster by an avg. of 1,514%
|
1020
|
+
|
1021
|
+
# globstar-long-list (90647 bytes)
|
1022
|
+
micromatch ██████████████████████████████████████████████████ (2,694 ops/sec ±1.08%)
|
1023
|
+
minimatch ████████████████ (870 ops/sec ±1.09%)
|
1024
|
+
multimatch ████████████████ (862 ops/sec ±0.84%)
|
1025
|
+
|
1026
|
+
micromatch is faster by an avg. of 311%
|
1027
|
+
|
1028
|
+
# globstar-short-list (182 bytes)
|
1029
|
+
micromatch ██████████████████████████████████████████████████ (328,921 ops/sec ±1.06%)
|
1030
|
+
minimatch █████████ (64,808 ops/sec ±1.42%)
|
1031
|
+
multimatch ████████ (57,991 ops/sec ±2.11%)
|
1032
|
+
|
1033
|
+
micromatch is faster by an avg. of 536%
|
1034
|
+
|
1035
|
+
# no-glob (701 bytes)
|
1036
|
+
micromatch █████████████████████████████████████████████████ (415,935 ops/sec ±0.36%)
|
1037
|
+
minimatch ███████████ (92,730 ops/sec ±1.44%)
|
1038
|
+
multimatch █████████ (81,958 ops/sec ±2.13%)
|
1039
|
+
|
1040
|
+
micromatch is faster by an avg. of 476%
|
1041
|
+
|
1042
|
+
# star-basename-long (12339 bytes)
|
1043
|
+
micromatch █████████████████████████████████████████████████ (7,963 ops/sec ±0.36%)
|
1044
|
+
minimatch ███████████████████████████████ (5,072 ops/sec ±0.83%)
|
1045
|
+
multimatch ███████████████████████████████ (5,028 ops/sec ±0.40%)
|
1046
|
+
|
1047
|
+
micromatch is faster by an avg. of 158%
|
1048
|
+
|
1049
|
+
# star-basename-short (349 bytes)
|
1050
|
+
micromatch ██████████████████████████████████████████████████ (269,552 ops/sec ±0.70%)
|
1051
|
+
minimatch ██████████████████████ (122,457 ops/sec ±1.39%)
|
1052
|
+
multimatch ████████████████████ (110,788 ops/sec ±1.99%)
|
1053
|
+
|
1054
|
+
micromatch is faster by an avg. of 231%
|
1055
|
+
|
1056
|
+
# star-folder-long (19207 bytes)
|
1057
|
+
micromatch █████████████████████████████████████████████████ (3,806 ops/sec ±0.38%)
|
1058
|
+
minimatch ████████████████████████████ (2,204 ops/sec ±0.32%)
|
1059
|
+
multimatch ██████████████████████████ (2,020 ops/sec ±1.07%)
|
1060
|
+
|
1061
|
+
micromatch is faster by an avg. of 180%
|
1062
|
+
|
1063
|
+
# star-folder-short (551 bytes)
|
1064
|
+
micromatch ██████████████████████████████████████████████████ (249,077 ops/sec ±0.40%)
|
1065
|
+
minimatch ███████████ (59,431 ops/sec ±1.67%)
|
1066
|
+
multimatch ███████████ (55,569 ops/sec ±1.43%)
|
1012
1067
|
|
1068
|
+
micromatch is faster by an avg. of 433%
|
1013
1069
|
```
|
1014
1070
|
|
1015
1071
|
## About
|
@@ -1034,7 +1090,7 @@ Please read the [contributing guide](.github/contributing.md) for advice on open
|
|
1034
1090
|
|
1035
1091
|
| **Commits** | **Contributor** |
|
1036
1092
|
| --- | --- |
|
1037
|
-
|
|
1093
|
+
| 439 | [jonschlinkert](https://github.com/jonschlinkert) |
|
1038
1094
|
| 12 | [es128](https://github.com/es128) |
|
1039
1095
|
| 8 | [doowb](https://github.com/doowb) |
|
1040
1096
|
| 3 | [paulmillr](https://github.com/paulmillr) |
|
@@ -1079,4 +1135,4 @@ Released under the [MIT License](LICENSE).
|
|
1079
1135
|
|
1080
1136
|
***
|
1081
1137
|
|
1082
|
-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September
|
1138
|
+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 11, 2017._
|
package/index.js
CHANGED
@@ -514,6 +514,44 @@ micromatch.matcher = function matcher(pattern, options) {
|
|
514
514
|
return fn;
|
515
515
|
};
|
516
516
|
|
517
|
+
/**
|
518
|
+
* Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
|
519
|
+
*
|
520
|
+
* ```js
|
521
|
+
* var mm = require('micromatch');
|
522
|
+
* mm.capture(pattern, string[, options]);
|
523
|
+
*
|
524
|
+
* console.log(mm.capture('test/*.js', 'test/foo.js));
|
525
|
+
* //=> ['foo']
|
526
|
+
* console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
527
|
+
* //=> null
|
528
|
+
* ```
|
529
|
+
* @param {String} `pattern` Glob pattern to use for matching.
|
530
|
+
* @param {String} `string` String to match
|
531
|
+
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
532
|
+
* @return {Boolean} Returns an array of captures if the string matches the glob pattern, otherwise `null`.
|
533
|
+
* @api public
|
534
|
+
*/
|
535
|
+
|
536
|
+
micromatch.capture = function(pattern, str, options) {
|
537
|
+
var re = micromatch.makeRe(pattern, extend({capture: true}, options));
|
538
|
+
var unixify = utils.unixify(options);
|
539
|
+
|
540
|
+
function match() {
|
541
|
+
return function(string) {
|
542
|
+
var match = re.exec(unixify(string));
|
543
|
+
if (!match) {
|
544
|
+
return null;
|
545
|
+
}
|
546
|
+
|
547
|
+
return match.slice(1);
|
548
|
+
};
|
549
|
+
}
|
550
|
+
|
551
|
+
var capture = memoize('capture', pattern, options, match);
|
552
|
+
return capture(str);
|
553
|
+
};
|
554
|
+
|
517
555
|
/**
|
518
556
|
* Create a regular expression from the given glob `pattern`.
|
519
557
|
*
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "micromatch",
|
3
3
|
"description": "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.",
|
4
|
-
"version": "3.0
|
4
|
+
"version": "3.1.0",
|
5
5
|
"homepage": "https://github.com/micromatch/micromatch",
|
6
6
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
7
7
|
"contributors": [
|
@@ -40,7 +40,7 @@
|
|
40
40
|
"braces": "^2.2.2",
|
41
41
|
"define-property": "^1.0.0",
|
42
42
|
"extend-shallow": "^2.0.1",
|
43
|
-
"extglob": "^2.0.
|
43
|
+
"extglob": "^2.0.2",
|
44
44
|
"fragment-cache": "^0.2.1",
|
45
45
|
"kind-of": "^5.0.2",
|
46
46
|
"nanomatch": "^1.2.1",
|