Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nanomatch

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanomatch - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

299

index.js
'use strict';
/**
* Module dependencies
*/
var util = require('util');
var toRegex = require('to-regex');
var extend = require('extend-shallow');
/**
* Local dependencies

@@ -26,4 +34,5 @@ */

* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` Any [options](#options) to change how matches are performed
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Array} Returns an array of matches
* @summary false
* @api public

@@ -35,4 +44,4 @@ */

list = utils.arrayify(list);
var len = patterns.length;
if (list.length === 0 || len === 0) {

@@ -68,4 +77,2 @@ return [];

var unixify = utils.unixify(options);
keep = [];
for (var i = 0; i < list.length; i++) {

@@ -97,3 +104,3 @@ keep.push(unixify(list[i]));

* @param {String} `pattern` Glob pattern to use for matching.
* @param {Object} `options` Any [options](#options) to change how matches are performed
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Array} Returns an array of matches

@@ -110,2 +117,3 @@ * @api public

var isMatch = memoize('match', pattern, options, nanomatch.matcher);
var matches = [];

@@ -115,10 +123,7 @@ list = utils.arrayify(list);

var idx = -1;
var matches = [];
while (++idx < len) {
var origPath = list[idx];
if (origPath === pattern || isMatch(origPath)) {
var unixPath = unixify(origPath);
matches.push(utils.value(origPath, unixPath, options, pattern));
var ele = list[idx];
if (ele === pattern || isMatch(ele)) {
matches.push(utils.value(ele, unixify, options));
}

@@ -163,3 +168,3 @@ }

* @param {String} `pattern` Glob pattern to use for matching.
* @param {Object} `options` Any [options](#options) to change how matches are performed
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if the string matches the glob pattern.

@@ -171,5 +176,9 @@ * @api public

if (typeof str !== 'string') {
throw new TypeError('expected a string');
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
}
if (isEmptyString(str) || isEmptyString(pattern)) {
return false;
}
var equals = utils.equalsPattern(options);

@@ -185,35 +194,76 @@ if (equals(str)) {

/**
* Returns a list of strings that _DO NOT MATCH_ any of the given `patterns`.
* Returns true if some of the elements in the given `list` match any of the
* given glob `patterns`.
*
* ```js
* var nm = require('nanomatch');
* nm.not(list, patterns[, options]);
* nm.some(list, patterns[, options]);
*
* console.log(nm.not(['a.a', 'b.b', 'c.c'], '*.a'));
* //=> ['b.b', 'c.c']
* console.log(nm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
* // true
* console.log(nm.some(['foo.js'], ['*.js', '!foo.js']));
* // false
* ```
* @param {Array} `list` Array of strings to match.
* @param {String|Array} `patterns` One or more glob pattern to use for matching.
* @param {Object} `options` Any [options](#options) to change how matches are performed
* @return {Array} Returns an array of strings that **do not match** the given patterns.
* @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
nanomatch.not = function(list, patterns, options) {
var opts = utils.extend({}, options);
var ignore = opts.ignore;
delete opts.ignore;
nanomatch.some = function(list, patterns, options) {
if (typeof list === 'string') {
list = [list];
}
list = utils.arrayify(list);
for (var i = 0; i < list.length; i++) {
if (nanomatch(list[i], patterns, options).length === 1) {
return true;
}
}
var matches = utils.diff(list, nanomatch(list, patterns, opts));
if (ignore) {
matches = utils.diff(matches, nanomatch(list, ignore));
return false;
};
/**
* Returns true if every element in the given `list` matches
* at least one of the given glob `patterns`.
*
* ```js
* var nm = require('nanomatch');
* nm.every(list, patterns[, options]);
*
* console.log(nm.every('foo.js', ['foo.js']));
* // true
* console.log(nm.every(['foo.js', 'bar.js'], ['*.js']));
* // true
* console.log(nm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
* // false
* console.log(nm.every(['foo.js'], ['*.js', '!foo.js']));
* // false
* ```
* @param {String|Array} `list` The string or array of strings to test.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
nanomatch.every = function(list, patterns, options) {
if (typeof list === 'string') {
list = [list];
}
return opts.nodupes !== false ? utils.unique(matches) : matches;
for (var i = 0; i < list.length; i++) {
if (nanomatch(list[i], patterns, options).length !== 1) {
return false;
}
}
return true;
};
/**
* Returns true if the given `string` matches any of the given glob `patterns`.
* Returns true if **any** of the given glob `patterns`
* match the specified `string`.
*

@@ -229,5 +279,5 @@ * ```js

* ```
* @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
* @param {String|Array} `str` The string to test.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` Any [options](#options) to change how matches are performed
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if any patterns match `str`

@@ -237,17 +287,17 @@ * @api public

nanomatch.any = function(list, patterns, options) {
var isMatch = memoize('any', patterns, options, nanomatch.matcher);
nanomatch.any = function(str, patterns, options) {
if (typeof str !== 'string') {
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
}
list = utils.arrayify(list);
var len = list.length;
var idx = -1;
if (isEmptyString(str) || isEmptyString(patterns)) {
return false;
}
while (++idx < len) {
var ele = list[idx];
if (ele === './' || ele === '') continue;
if (typeof patterns === 'string') {
patterns = [patterns];
}
if (isMatch(ele)) {
if (options && options.ignore && nanomatch.not(ele, options.ignored)) {
continue;
}
for (var i = 0; i < patterns.length; i++) {
if (nanomatch.isMatch(str, patterns[i], options)) {
return true;

@@ -260,2 +310,78 @@ }

/**
* Returns true if **all** of the given `patterns`
* match the specified string.
*
* ```js
* var nm = require('nanomatch');
* nm.all(string, patterns[, options]);
*
* console.log(nm.all('foo.js', ['foo.js']));
* // true
*
* console.log(nm.all('foo.js', ['*.js', '!foo.js']));
* // false
*
* console.log(nm.all('foo.js', ['*.js', 'foo.js']));
* // true
*
* console.log(nm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
* // true
* ```
* @param {String|Array} `str` The string to test.
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if any patterns match `str`
* @api public
*/
nanomatch.all = function(str, patterns, options) {
if (typeof str !== 'string') {
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
}
if (typeof patterns === 'string') {
patterns = [patterns];
}
for (var i = 0; i < patterns.length; i++) {
if (!nanomatch.isMatch(str, patterns[i], options)) {
return false;
}
}
return true;
};
/**
* Returns a list of strings that _**do not match any**_ of the given `patterns`.
*
* ```js
* var nm = require('nanomatch');
* nm.not(list, patterns[, options]);
*
* console.log(nm.not(['a.a', 'b.b', 'c.c'], '*.a'));
* //=> ['b.b', 'c.c']
* ```
* @param {Array} `list` Array of strings to match.
* @param {String|Array} `patterns` One or more glob pattern to use for matching.
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Array} Returns an array of strings that **do not match** the given patterns.
* @api public
*/
nanomatch.not = function(list, patterns, options) {
var opts = extend({}, options);
var ignore = opts.ignore;
delete opts.ignore;
list = utils.arrayify(list);
var matches = utils.diff(list, nanomatch(list, patterns, opts));
if (ignore) {
matches = utils.diff(matches, nanomatch(list, ignore));
}
return opts.nodupes !== false ? utils.unique(matches) : matches;
};
/**
* Returns true if the given `string` contains the given pattern. Similar

@@ -275,3 +401,3 @@ * to [.isMatch](#isMatch) but the pattern can match any part of the string.

* @param {String|Array} `patterns` Glob pattern to use for matching.
* @param {Object} `options` Any [options](#options) to change how matches are performed
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Boolean} Returns true if the patter matches any part of `str`.

@@ -282,4 +408,8 @@ * @api public

nanomatch.contains = function(str, patterns, options) {
if (typeof str !== 'string') {
throw new TypeError('expected a string: "' + util.inspect(str) + '"');
}
if (typeof patterns === 'string') {
if (patterns === '') {
if (isEmptyString(str) || isEmptyString(patterns)) {
return false;

@@ -298,7 +428,4 @@ }

var opts = utils.extend({}, options);
opts.strictClose = false;
opts.strictOpen = false;
opts.contains = true;
return nanomatch(str, patterns, opts).length > 0;
var opts = extend({}, options, {contains: true});
return nanomatch.any(str, patterns, opts);
};

@@ -333,3 +460,3 @@

* @param {String|Array} `patterns` One or more glob patterns to use for matching.
* @param {Object} `options` Any [options](#options) to change how matches are performed
* @param {Object} `options` See available [options](#options) for changing how matches are performed
* @return {Object} Returns an object with only keys that match the given patterns.

@@ -363,3 +490,3 @@ * @api public

* @param {String} `pattern` Glob pattern
* @param {Object} `options` Any [options](#options) to change how matches are performed.
* @param {Object} `options` See available [options](#options) for changing how matches are performed.
* @return {Function} Returns a matcher function.

@@ -370,4 +497,10 @@ * @api public

nanomatch.matcher = function matcher(pattern, options) {
if (isEmptyString(pattern)) {
return function() {
return false;
}
}
if (Array.isArray(pattern)) {
return utils.compose(pattern, options, matcher);
return compose(pattern, options, matcher);
}

@@ -382,3 +515,3 @@

if (!utils.isString(pattern)) {
throw new TypeError('expected pattern to be a string or regex');
throw new TypeError('expected pattern to be an array, string or regex');
}

@@ -418,3 +551,5 @@

return test(re);
var fn = test(re);
fn.result = re.result;
return fn;
};

@@ -433,3 +568,3 @@

* @param {String} `pattern` A glob pattern to convert to regex.
* @param {Object} `options` Any [options](#options) to change how matches are performed.
* @param {Object} `options` See available [options](#options) for changing how matches are performed.
* @return {RegExp} Returns a regex created from the given pattern.

@@ -455,3 +590,5 @@ * @api public

var opts = utils.extend({wrap: false}, options);
return utils.toRegex(res.output, opts);
var regex = toRegex(res.output, opts);
regex.result = res;
return regex;
}

@@ -549,7 +686,2 @@

if (pattern.slice(0, 2) === './') {
pattern = pattern.slice(2);
}
pattern = utils.combineDuplicates(pattern, '\\*\\*\\/|\\/\\*\\*');
var ast = snapdragon.parse(pattern, options);

@@ -622,2 +754,41 @@ utils.define(ast, 'snapdragon', snapdragon);

/**
* Returns true if the given value is effectively an empty string
*/
function isEmptyString(val) {
return String(val) === '' || String(val) === './';
}
/**
* Compose a matcher function with the given patterns.
* This allows matcher functions to be compiled once and
* called multiple times.
*/
function compose(patterns, options, matcher) {
var matchers;
return memoize('compose', String(patterns), options, function() {
return function(file) {
// delay composition until it's invoked the first time,
// after that it won't be called again
if (!matchers) {
matchers = [];
for (var i = 0; i < patterns.length; i++) {
matchers.push(matcher(patterns[i], options));
}
}
var len = matchers.length;
while (len--) {
if (matchers[len](file) === true) {
return true;
}
}
return false;
};
});
}
/**
* Memoize a generated regex or function. A unique key is generated

@@ -624,0 +795,0 @@ * from the `type` (usually method name), the `pattern`, and

@@ -12,3 +12,6 @@ 'use strict';

nanomatch.state = nanomatch.state || {};
var ast = nanomatch.ast = nanomatch.parser.ast;
ast.state = nanomatch.parser.state;
nanomatch.compiler.state = ast.state;
nanomatch.compiler

@@ -100,2 +103,7 @@

if (node.escaped === true) {
inner = inner.replace(/\\?(\W)/g, '\\$1');
negated = '';
}
if (inner === ']-') {

@@ -274,3 +282,3 @@ inner = '\\]\\-';

var val = node.val;
if (nanomatch.state.metachar && prev.type !== 'qmark' && prev.type !== 'slash') {
if (this.state.metachar && prev.type !== 'qmark' && prev.type !== 'slash') {
val += (this.options.contains ? '\\/?' : '(\\/|$)');

@@ -277,0 +285,0 @@ }

@@ -21,5 +21,13 @@ 'use strict';

module.exports = function(nanomatch, options) {
nanomatch.state = nanomatch.state || {};
nanomatch.parser
var parser = nanomatch.parser;
var opts = parser.options;
parser.state = {
slashes: 0,
paths: []
};
parser.ast.state = parser.state;
parser
/**

@@ -150,3 +158,6 @@ * Beginning-of-string

if (!m) return;
nanomatch.state.metachar = true;
this.state.metachar = true;
this.state.qmark = true;
return pos({

@@ -164,2 +175,3 @@ type: 'qmark',

.capture('globstar', function() {
var parsed = this.parsed;
var pos = this.position();

@@ -169,12 +181,19 @@ var m = this.match(/^\*{2}(?![*(])(?=[,\/)]|$)/);

nanomatch.state.metachar = true;
var node = pos({
type: 'globstar',
val: '**'
});
var type = opts.noglobstar !== true ? 'globstar': 'star';
var node = pos({type: type, parsed: parsed});
if (this.options.noglobstar === true) {
node.type = 'star';
if (this.input.slice(0, 4) === '/**/') {
this.input = this.input.slice(3);
}
if (type === 'globstar') {
this.state.globstar = true;
node.val = '**';
} else {
this.state.star = true;
node.val = '*';
}
this.state.metachar = true;
return node;

@@ -189,6 +208,8 @@ })

var pos = this.position();
var m = this.match(/^(?:\*(?![*(])|[*]{3,}(?!\()|[*]{2}(?![(\/]|$)|\*(?=\*\())/);
var starRe = /^(?:\*(?![*(])|[*]{3,}(?!\()|[*]{2}(?![(\/]|$)|\*(?=\*\())/;
var m = this.match(starRe);
if (!m) return;
nanomatch.state.metachar = true;
this.state.metachar = true;
this.state.star = true;
return pos({

@@ -204,4 +225,14 @@ type: 'star',

.capture('slash', /^\//)
.capture('slash', function() {
var pos = this.position();
var m = this.match(/^\//);
if (!m) return;
this.state.slashes++;
return pos({
type: 'slash',
val: m[0]
});
})
/**

@@ -212,13 +243,12 @@ * Backslash: "\\"

.capture('backslash', function() {
if (this.isInside('bracket')) return;
var pos = this.position();
var m = this.match(/^\\(?![*+?(){}\[\]'"])/);
var m = this.match(/^\\(?![*+?(){}[\]'"])/);
if (!m) return;
var match = /^\\{2,}/.exec(this.input);
var val = m[0];
if (match) {
this.consume(match[0].length);
val += '\\';
if (this.isInside('bracket')) {
val = '\\';
} else if (val.length > 1) {
val = '\\\\';
}

@@ -259,5 +289,9 @@

var negated = m[1] ? '^' : '';
var inner = m[2] || '';
var inner = (m[2] || '').replace(/\\\\+/, '\\\\');
var close = m[3] || '';
if (m[2] && inner.length < m[2].length) {
val = val.replace(/\\\\+/, '\\\\');
}
var esc = this.input.slice(0, 2);

@@ -264,0 +298,0 @@ if (inner === '' && esc === '\\]') {

'use strict';
var utils = module.exports;
var path = require('path');
var Snapdragon = require('snapdragon');
var utils = module.exports;

@@ -11,2 +10,3 @@ /**

var Snapdragon = require('snapdragon');
utils.define = require('define-property');

@@ -16,3 +16,2 @@ utils.diff = require('arr-diff');

utils.pick = require('object.pick');
utils.toRegex = require('to-regex');
utils.typeOf = require('kind-of');

@@ -41,18 +40,2 @@ utils.unique = require('array-unique');

/**
* Compose a matcher function with the given patterns
*/
utils.compose = function(patterns, options, matcher) {
var fns = patterns.map(function(pattern) {
return matcher(pattern, options);
});
return function(file) {
var len = fns.length;
while (len--) if (fns[len](file)) return true;
return false;
};
};
/**
* Get the `Snapdragon` instance to use

@@ -112,6 +95,6 @@ */

utils.createKey = function(pattern, options) {
var key = pattern;
if (typeof options === 'undefined') {
return key;
return pattern;
}
var key = pattern;
for (var prop in options) {

@@ -362,7 +345,7 @@ if (options.hasOwnProperty(prop)) {

utils.value = function(origPath, unixPath, options) {
if (typeof options === 'undefined' || options.unixify !== false) {
return unixPath;
utils.value = function(str, unixify, options) {
if (options && options.unixify === false) {
return str;
}
return origPath;
return unixify(str);
};

@@ -380,5 +363,3 @@

return function(filepath) {
if (options.unescape === true) {
filepath = utils.unescape(filepath);
} else if (utils.isWindows() || options.unixify === true) {
if (utils.isWindows() || options.unixify === true) {
filepath = utils.toPosixPath(filepath);

@@ -389,4 +370,7 @@ }

}
if (options.unescape === true) {
filepath = utils.unescape(filepath);
}
return filepath;
};
};
{
"name": "nanomatch",
"description": "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)",
"version": "1.1.1",
"homepage": "https://github.com/jonschlinkert/nanomatch",
"version": "1.2.0",
"homepage": "https://github.com/micromatch/nanomatch",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/nanomatch",
"repository": "micromatch/nanomatch",
"bugs": {
"url": "https://github.com/jonschlinkert/nanomatch/issues"
"url": "https://github.com/micromatch/nanomatch/issues"
},

@@ -24,10 +24,10 @@ "license": "MIT",

"dependencies": {
"arr-diff": "^3.0.0",
"arr-diff": "^4.0.0",
"array-unique": "^0.3.2",
"define-property": "^0.2.5",
"define-property": "^1.0.0",
"extend-shallow": "^2.0.1",
"fragment-cache": "^0.2.1",
"is-extglob": "^2.1.1",
"is-odd": "^0.1.1",
"kind-of": "^3.1.0",
"is-odd": "^1.0.0",
"kind-of": "^4.0.0",
"object.pick": "^1.2.0",

@@ -114,7 +114,16 @@ "regex-not": "^1.0.0",

"reflinks": [
"a-c",
"bash-braces",
"bash-brackets",
"bash-extglobs",
"bash-globs",
"bash-tilde",
"braces",
"expand-brackets",
"expand-tilde",
"extglob",
"glob-object",
"micromatch",
"minimatch",
"options",
"snapdragon"

@@ -121,0 +130,0 @@ ],

@@ -1,2 +0,2 @@

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

@@ -63,3 +63,3 @@ > Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)

### [1.1.0](https://github.com/jonschlinkert/nanomatch/compare/1.0.4...1.1.0) - 2017-04-11
### [1.1.0](https://github.com/micromatch/nanomatch/compare/1.0.4...1.1.0) - 2017-04-11

@@ -74,7 +74,7 @@ **Fixed**

### [1.0.4](https://github.com/jonschlinkert/nanomatch/compare/1.0.3...1.0.4) - 2017-04-06
### [1.0.4](https://github.com/micromatch/nanomatch/compare/1.0.3...1.0.4) - 2017-04-06
Housekeeping updates. Adds documentation section about escaping, cleans up utils.
### [1.0.3](https://github.com/jonschlinkert/nanomatch/compare/1.0.1...1.0.3) - 2017-04-06
### [1.0.3](https://github.com/micromatch/nanomatch/compare/1.0.1...1.0.3) - 2017-04-06

@@ -91,3 +91,3 @@ This release includes fixes for windows path edge cases and other improvements for stricter adherence to bash spec.

### [1.0.1](https://github.com/jonschlinkert/nanomatch/compare/1.0.0...1.0.1) - 2016-12-12
### [1.0.1](https://github.com/micromatch/nanomatch/compare/1.0.0...1.0.1) - 2016-12-12

@@ -98,3 +98,3 @@ **Added**

### [1.0.0](https://github.com/jonschlinkert/nanomatch/compare/0.1.0...1.0.0) - 2016-12-12
### [1.0.0](https://github.com/micromatch/nanomatch/compare/0.1.0...1.0.0) - 2016-12-12

@@ -121,3 +121,3 @@ Stable release.

<details>
<summary><strong>How is this different from [minimatch](https://github.com/isaacs/minimatch)?</strong></summary>
<summary><strong>How is this different?</strong></summary>

@@ -129,4 +129,4 @@ **Speed and accuracy**

* Granular control over the entire conversion process in a way that is easy to understand, reason about, and customize.
* Faster matching, from a combination of optimized glob patterns and (optional) caching.
* Much greater accuracy than minimatch. In fact, nanomatch passes _all of the spec tests_ from bash, including some that bash still fails. However, since there is no real specification for globs, if you encounter a pattern that yields unexpected match results [after researching previous issues](../../issues), [please let us know](../../issues/new).
* Faster matching, from a combination of optimized glob patterns and (optional) caching.

@@ -237,3 +237,3 @@ **Basic globbing only**

### [nanomatch](index.js#L31)
### [nanomatch](index.js#L40)

@@ -246,3 +246,3 @@ The main function takes a list of strings and one or more glob patterns to use for matching.

* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: Any [options](#options) to change how matches are performed
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Array}**: Returns an array of matches

@@ -260,7 +260,4 @@

<details>
<summary><strong>.match</strong></summary>
### [.match](index.js#L106)
### [.match](index.js#L99)
Similar to the main function, but `pattern` must be a string.

@@ -272,3 +269,3 @@

* `pattern` **{String}**: Glob pattern to use for matching.
* `options` **{Object}**: Any [options](#options) to change how matches are performed
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Array}**: Returns an array of matches

@@ -286,9 +283,4 @@

</details>
### [.isMatch](index.js#L167)
<details>
<summary><strong>.isMatch</strong></summary>
### [.isMatch](index.js#L162)
Returns true if the specified `string` matches the given glob `pattern`.

@@ -300,3 +292,3 @@

* `pattern` **{String}**: Glob pattern to use for matching.
* `options` **{Object}**: Any [options](#options) to change how matches are performed
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if the string matches the glob pattern.

@@ -316,17 +308,35 @@

</details>
### [.some](index.js#L205)
<details>
<summary><strong>.not</strong></summary>
Returns true if some of the elements in the given `list` match any of the given glob `patterns`.
### [.not](index.js#L193)
**Params**
Returns a list of strings that _DO NOT MATCH_ any of the given `patterns`.
* `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found.
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if any patterns match `str`
**Example**
```js
var nm = require('nanomatch');
nm.some(list, patterns[, options]);
console.log(nm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
// true
console.log(nm.some(['foo.js'], ['*.js', '!foo.js']));
// false
```
### [.every](index.js#L243)
Returns true if every element in the given `list` matches at least one of the given glob `patterns`.
**Params**
* `list` **{Array}**: Array of strings to match.
* `patterns` **{String|Array}**: One or more glob pattern to use for matching.
* `options` **{Object}**: Any [options](#options) to change how matches are performed
* `returns` **{Array}**: Returns an array of strings that **do not match** the given patterns.
* `list` **{String|Array}**: The string or array of strings to test.
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if any patterns match `str`

@@ -337,22 +347,23 @@ **Example**

var nm = require('nanomatch');
nm.not(list, patterns[, options]);
nm.every(list, patterns[, options]);
console.log(nm.not(['a.a', 'b.b', 'c.c'], '*.a'));
//=> ['b.b', 'c.c']
console.log(nm.every('foo.js', ['foo.js']));
// true
console.log(nm.every(['foo.js', 'bar.js'], ['*.js']));
// true
console.log(nm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
// false
console.log(nm.every(['foo.js'], ['*.js', '!foo.js']));
// false
```
</details>
### [.any](index.js#L277)
<details>
<summary><strong>.any</strong></summary>
Returns true if **any** of the given glob `patterns` match the specified `string`.
### [.any](index.js#L227)
Returns true if the given `string` matches any of the given glob `patterns`.
**Params**
* `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found.
* `str` **{String|Array}**: The string to test.
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: Any [options](#options) to change how matches are performed
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if any patterns match `str`

@@ -372,9 +383,55 @@

</details>
### [.all](index.js#L325)
<details>
<summary><strong>.contains</strong></summary>
Returns true if **all** of the given `patterns` match the specified string.
### [.contains](index.js#L268)
**Params**
* `str` **{String|Array}**: The string to test.
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if any patterns match `str`
**Example**
```js
var nm = require('nanomatch');
nm.all(string, patterns[, options]);
console.log(nm.all('foo.js', ['foo.js']));
// true
console.log(nm.all('foo.js', ['*.js', '!foo.js']));
// false
console.log(nm.all('foo.js', ['*.js', 'foo.js']));
// true
console.log(nm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
// true
```
### [.not](index.js#L359)
Returns a list of strings that _**do not match any**_ of the given `patterns`.
**Params**
* `list` **{Array}**: Array of strings to match.
* `patterns` **{String|Array}**: One or more glob pattern to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Array}**: Returns an array of strings that **do not match** the given patterns.
**Example**
```js
var nm = require('nanomatch');
nm.not(list, patterns[, options]);
console.log(nm.not(['a.a', 'b.b', 'c.c'], '*.a'));
//=> ['b.b', 'c.c']
```
### [.contains](index.js#L394)
Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string.

@@ -386,3 +443,3 @@

* `patterns` **{String|Array}**: Glob pattern to use for matching.
* `options` **{Object}**: Any [options](#options) to change how matches are performed
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if the patter matches any part of `str`.

@@ -402,9 +459,4 @@

</details>
### [.matchKeys](index.js#L450)
<details>
<summary><strong>.matchKeys</strong></summary>
### [.matchKeys](index.js#L323)
Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead.

@@ -416,3 +468,3 @@

* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: Any [options](#options) to change how matches are performed
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Object}**: Returns an object with only keys that match the given patterns.

@@ -431,9 +483,4 @@

</details>
### [.matcher](index.js#L479)
<details>
<summary><strong>.matcher</strong></summary>
### [.matcher](index.js#L352)
Returns a memoized matcher function from the given glob `pattern` and `options`. The returned function takes a string to match as its only argument and returns true if the string is a match.

@@ -444,3 +491,3 @@

* `pattern` **{String}**: Glob pattern
* `options` **{Object}**: Any [options](#options) to change how matches are performed.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed.
* `returns` **{Function}**: Returns a matcher function.

@@ -461,9 +508,4 @@

</details>
### [.makeRe](index.js#L553)
<details>
<summary><strong>.makeRe</strong></summary>
### [.makeRe](index.js#L418)
Create a regular expression from the given glob `pattern`.

@@ -474,3 +516,3 @@

* `pattern` **{String}**: A glob pattern to convert to regex.
* `options` **{Object}**: Any [options](#options) to change how matches are performed.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed.
* `returns` **{RegExp}**: Returns a regex created from the given pattern.

@@ -488,9 +530,4 @@

</details>
### [.create](index.js#L616)
<details>
<summary><strong>.create</strong></summary>
### [.create](index.js#L479)
Parses the given glob `pattern` and returns an object with the compiled `output` and optional source `map`.

@@ -536,9 +573,4 @@

</details>
### [.parse](index.js#L655)
<details>
<summary><strong>.parse</strong></summary>
### [.parse](index.js#L518)
Parse the given `str` with the given `options`.

@@ -575,9 +607,4 @@

</details>
### [.compile](index.js#L703)
<details>
<summary><strong>.compile</strong></summary>
### [.compile](index.js#L571)
Compile the given `ast` or string with the given `options`.

@@ -615,9 +642,4 @@

</details>
### [.clearCache](index.js#L726)
<details>
<summary><strong>.clearCache</strong></summary>
### [.clearCache](index.js#L594)
Clear the regex cache.

@@ -631,4 +653,2 @@

</details>
## Options

@@ -859,3 +879,3 @@

``` js
```js
var nm = require('nanomatch');

@@ -969,3 +989,3 @@

| [expand-brackets](https://github.com/jonschlinkert/expand-brackets) | Brackets | `[[:alpha:]]` | [POSIX character classes](https://www.gnu.org/software/grep/manual/html_node/Character-Classes-and-Bracket-Expressions.html) (also referred to as POSIX brackets, or POSIX character classes) |
| [extglob](https://github.com/jonschlinkert/extglob) | Parens | `!(a\|b)` | [Extglobs](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html#Pattern-Matching) |
| [extglob](https://github.com/jonschlinkert/extglob) | Parens | `!(a\ | b)` | [Extglobs](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html#Pattern-Matching) |
| [micromatch](https://github.com/jonschlinkert/micromatch) | All | all | Micromatch is built on top of the other libraries. |

@@ -1075,2 +1095,2 @@

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

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc