Socket
Socket
Sign inDemoInstall

micromatch

Package Overview
Dependencies
70
Maintainers
3
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.5 to 3.1.0

38

index.js

@@ -518,2 +518,40 @@ 'use strict';

/**
* Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
*
* ```js
* var mm = require('micromatch');
* mm.capture(pattern, string[, options]);
*
* console.log(mm.capture('test/*.js', 'test/foo.js));
* //=> ['foo']
* console.log(mm.capture('test/*.js', 'foo/bar.css'));
* //=> null
* ```
* @param {String} `pattern` Glob pattern to use for matching.
* @param {String} `string` String to match
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns an array of captures if the string matches the glob pattern, otherwise `null`.
* @api public
*/
micromatch.capture = function(pattern, str, options) {
var re = micromatch.makeRe(pattern, extend({capture: true}, options));
var unixify = utils.unixify(options);
function match() {
return function(string) {
var match = re.exec(unixify(string));
if (!match) {
return null;
}
return match.slice(1);
};
}
var capture = memoize('capture', pattern, options, match);
return capture(str);
};
/**
* Create a regular expression from the given glob `pattern`.

@@ -520,0 +558,0 @@ *

4

package.json
{
"name": "micromatch",
"description": "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.",
"version": "3.0.5",
"version": "3.1.0",
"homepage": "https://github.com/micromatch/micromatch",

@@ -43,3 +43,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"extend-shallow": "^2.0.1",
"extglob": "^2.0.0",
"extglob": "^2.0.2",
"fragment-cache": "^0.2.1",

@@ -46,0 +46,0 @@ "kind-of": "^5.0.2",

@@ -401,4 +401,27 @@ # micromatch [![NPM version](https://img.shields.io/npm/v/micromatch.svg?style=flat)](https://www.npmjs.com/package/micromatch) [![NPM monthly downloads](https://img.shields.io/npm/dm/micromatch.svg?style=flat)](https://npmjs.org/package/micromatch) [![NPM total downloads](https://img.shields.io/npm/dt/micromatch.svg?style=flat)](https://npmjs.org/package/micromatch) [![Linux Build Status](https://img.shields.io/travis/micromatch/micromatch.svg?style=flat&label=Travis)](https://travis-ci.org/micromatch/micromatch) [![Windows Build Status](https://img.shields.io/appveyor/ci/micromatch/micromatch.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/micromatch/micromatch)

### [.makeRe](index.js#L533)
### [.capture](index.js#L536)
Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
**Params**
* `pattern` **{String}**: Glob pattern to use for matching.
* `string` **{String}**: String to match
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns an array of captures if the string matches the glob pattern, otherwise `null`.
**Example**
```js
var mm = require('micromatch');
mm.capture(pattern, string[, options]);
console.log(mm.capture('test/*.js', 'test/foo.js));
//=> ['foo']
console.log(mm.capture('test/*.js', 'foo/bar.css'));
//=> null
```
### [.makeRe](index.js#L571)
Create a regular expression from the given glob `pattern`.

@@ -422,3 +445,3 @@

### [.braces](index.js#L580)
### [.braces](index.js#L618)

@@ -444,3 +467,3 @@ Expand the given brace `pattern`.

### [.create](index.js#L647)
### [.create](index.js#L685)

@@ -487,3 +510,3 @@ 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.

### [.parse](index.js#L694)
### [.parse](index.js#L732)

@@ -521,3 +544,3 @@ Parse the given `str` with the given `options`.

### [.compile](index.js#L747)
### [.compile](index.js#L785)

@@ -556,3 +579,3 @@ Compile the given `ast` or string with the given `options`.

### [.clearCache](index.js#L768)
### [.clearCache](index.js#L806)

@@ -966,55 +989,88 @@ Clear the regex cache.

As of September 07, 2017 (longer bars are better):
As of September 11, 2017 (longer bars are better):
```sh
# braces-globstar-large-list
micromatch ██████████████████████████████████████████████████ (595 ops/sec)
minimatch █ (13.95 ops/sec)
multimatch █ (14.09 ops/sec)
# braces-globstar-large-list (485691 bytes)
micromatch ██████████████████████████████████████████████████ (517 ops/sec ±0.49%)
minimatch █ (18.92 ops/sec ±0.54%)
multimatch █ (18.94 ops/sec ±0.62%)
# braces-multiple
micromatch ██████████████████████████████████████████████████ (48,362 ops/sec)
minimatch (2.18 ops/sec)
multimatch (2.15 ops/sec)
micromatch is faster by an avg. of 2,733%
# braces-range
micromatch ██████████████████████████████████████████████████ (187,481 ops/sec)
minimatch ███ (12,366 ops/sec)
multimatch ███ (11,841 ops/sec)
# braces-multiple (3362 bytes)
micromatch ██████████████████████████████████████████████████ (33,625 ops/sec ±0.45%)
minimatch (2.92 ops/sec ±3.26%)
multimatch (2.90 ops/sec ±2.76%)
# braces-set
micromatch ██████████████████████████████████████████████████ (24,344 ops/sec)
minimatch ████ (2,255 ops/sec)
multimatch ████ (2,199 ops/sec)
micromatch is faster by an avg. of 1,156,935%
# globstar-large-list
micromatch ██████████████████████████████████████████████████ (561 ops/sec)
minimatch ██ (25.43 ops/sec)
multimatch ██ (25.27 ops/sec)
# braces-range (727 bytes)
micromatch █████████████████████████████████████████████████ (155,220 ops/sec ±0.56%)
minimatch ██████ (20,186 ops/sec ±1.27%)
multimatch ██████ (19,809 ops/sec ±0.60%)
# globstar-long-list
micromatch ██████████████████████████████████████████████████ (3,257 ops/sec)
minimatch ███████ (485 ops/sec)
multimatch ███████ (485 ops/sec)
micromatch is faster by an avg. of 776%
# globstar-short-list
micromatch ██████████████████████████████████████████████████ (359,991 ops/sec)
minimatch ██████ (44,763 ops/sec)
multimatch █████ (39,977 ops/sec)
# braces-set (2858 bytes)
micromatch █████████████████████████████████████████████████ (24,354 ops/sec ±0.92%)
minimatch █████ (2,566 ops/sec ±0.56%)
multimatch ████ (2,431 ops/sec ±1.25%)
# no-glob
micromatch ██████████████████████████████████████████████████ (443,740 ops/sec)
minimatch ████ (44,152 ops/sec)
multimatch ████ (41,077 ops/sec)
micromatch is faster by an avg. of 975%
# star-basename
micromatch ██████████████████████████████████████████████████ (10,286 ops/sec)
minimatch ██████████████ (3,059 ops/sec)
multimatch ███████████████ (3,129 ops/sec)
# globstar-large-list (485686 bytes)
micromatch █████████████████████████████████████████████████ (504 ops/sec ±0.45%)
minimatch ███ (33.36 ops/sec ±1.08%)
multimatch ███ (33.19 ops/sec ±1.35%)
# star
micromatch ██████████████████████████████████████████████████ (9,756 ops/sec)
minimatch ███████████████ (2,978 ops/sec)
multimatch ███████████████ (2,970 ops/sec)
micromatch is faster by an avg. of 1,514%
# globstar-long-list (90647 bytes)
micromatch ██████████████████████████████████████████████████ (2,694 ops/sec ±1.08%)
minimatch ████████████████ (870 ops/sec ±1.09%)
multimatch ████████████████ (862 ops/sec ±0.84%)
micromatch is faster by an avg. of 311%
# globstar-short-list (182 bytes)
micromatch ██████████████████████████████████████████████████ (328,921 ops/sec ±1.06%)
minimatch █████████ (64,808 ops/sec ±1.42%)
multimatch ████████ (57,991 ops/sec ±2.11%)
micromatch is faster by an avg. of 536%
# no-glob (701 bytes)
micromatch █████████████████████████████████████████████████ (415,935 ops/sec ±0.36%)
minimatch ███████████ (92,730 ops/sec ±1.44%)
multimatch █████████ (81,958 ops/sec ±2.13%)
micromatch is faster by an avg. of 476%
# star-basename-long (12339 bytes)
micromatch █████████████████████████████████████████████████ (7,963 ops/sec ±0.36%)
minimatch ███████████████████████████████ (5,072 ops/sec ±0.83%)
multimatch ███████████████████████████████ (5,028 ops/sec ±0.40%)
micromatch is faster by an avg. of 158%
# star-basename-short (349 bytes)
micromatch ██████████████████████████████████████████████████ (269,552 ops/sec ±0.70%)
minimatch ██████████████████████ (122,457 ops/sec ±1.39%)
multimatch ████████████████████ (110,788 ops/sec ±1.99%)
micromatch is faster by an avg. of 231%
# star-folder-long (19207 bytes)
micromatch █████████████████████████████████████████████████ (3,806 ops/sec ±0.38%)
minimatch ████████████████████████████ (2,204 ops/sec ±0.32%)
multimatch ██████████████████████████ (2,020 ops/sec ±1.07%)
micromatch is faster by an avg. of 180%
# star-folder-short (551 bytes)
micromatch ██████████████████████████████████████████████████ (249,077 ops/sec ±0.40%)
minimatch ███████████ (59,431 ops/sec ±1.67%)
multimatch ███████████ (55,569 ops/sec ±1.43%)
micromatch is faster by an avg. of 433%
```

@@ -1044,3 +1100,3 @@

| --- | --- |
| 430 | [jonschlinkert](https://github.com/jonschlinkert) |
| 439 | [jonschlinkert](https://github.com/jonschlinkert) |
| 12 | [es128](https://github.com/es128) |

@@ -1090,2 +1146,2 @@ | 8 | [doowb](https://github.com/doowb) |

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 07, 2017._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 11, 2017._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc