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.2.7 to 1.2.8

lib/compiler2.js

23

index.js

@@ -532,9 +532,8 @@ 'use strict';

var fn = test(re);
Object.defineProperty(fn, 'result', {
configurable: true,
enumerable: false,
value: re.result
});
return fn;
// create matcher function
var matcherFn = test(re);
// set result object from compiler on matcher function,
// as a non-enumerable property. useful for debugging
utils.define(matcherFn, 'result', re.result);
return matcherFn;
};

@@ -612,9 +611,5 @@

var opts = utils.extend({wrap: false}, options);
var res = nanomatch.create(pattern, opts);
var regex = toRegex(res.output, opts);
Object.defineProperty(regex, 'result', {
configurable: true,
enumerable: false,
value: res
});
var result = nanomatch.create(pattern, opts);
var regex = toRegex(result.output, opts);
utils.define(regex, 'result', result);
return regex;

@@ -621,0 +616,0 @@ }

'use strict';
/**
* Nanomatch compilers
*/
* Nanomatch compilers
*/
module.exports = function(nanomatch, options) {
var star = '[^/]*?';
function slash() {
return (options && options.slash) || '\\\\/';
}
function star() {
return (options && options.star) || '[^' + slash() + ']*?';
}
var ast = nanomatch.ast = nanomatch.parser.ast;

@@ -27,3 +33,3 @@ ast.state = nanomatch.parser.state;

.set('escape', function(node) {
if (this.options.unescape && /^[\w_.-]/.test(node.val)) {
if (this.options.unescape && /^[-\w_.]/.test(node.val)) {
return this.emit(node.val, node);

@@ -65,3 +71,3 @@ }

.set('slash', function(node, nodes, i) {
var val = '\\' + node.val;
var val = '[' + slash() + ']';
var parent = node.parent;

@@ -134,3 +140,3 @@ var prev = this.prev();

.set('square', function(node) {
var val = !/^\w/.test(node.val) ? '\\' + node.val : node.val;
var val = (/^\W/.test(node.val) ? '\\' : '') + node.val;
return this.emit(val, node);

@@ -145,2 +151,4 @@ })

var prev = this.prev();
// don't use "slash" variable so that we always avoid
// matching backslashes and slashes with a qmark
var val = '[^.\\\\/]';

@@ -192,6 +200,6 @@ if (this.options.dot || (prev.type !== 'bos' && prev.type !== 'slash')) {

var prev = this.prev();
var before = this.prev(2);
var next = this.next();
var prev = this.prev();
var next2 = this.next(2);
var prev2 = this.prev(2);
var after = this.next(2);
var type = prev.type;

@@ -201,6 +209,6 @@ var val = node.val;

if (prev.type === 'slash' && next.type === 'slash') {
if (prev2.type === 'text') {
if (before.type === 'text') {
this.output += '?';
if (next2.type !== 'text') {
if (after.type !== 'text') {
this.output += '\\b';

@@ -218,7 +226,7 @@ }

if (parsed && type !== 'slash' && type !== 'bos' && !isInside) {
val = star;
val = star();
} else {
val = this.options.dot !== true
? '(?:(?!(?:\\/|^)\\.).)*?'
: '(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/))(?!\\.{2}).)*?';
? '(?:(?!(?:[' + slash() + ']|^)\\.).)*?'
: '(?:(?!(?:[' + slash() + ']|^)(?:\\.{1,2})($|[' + slash() + ']))(?!\\.{2}).)*?';
}

@@ -230,4 +238,4 @@

if (prev.type === 'slash' && next.type === 'slash' && prev2.type !== 'text') {
if (next2.type === 'text' || next2.type === 'star') {
if (prev.type === 'slash' && next.type === 'slash' && before.type !== 'text') {
if (after.type === 'text' || after.type === 'star') {
node.addQmark = true;

@@ -259,7 +267,7 @@ }

if (this.output === '' && this.options.contains !== true) {
this.output = '(?!\\/)';
this.output = '(?![' + slash() + '])';
}
if (type === 'bracket' && this.options.bash === false) {
var str = next && next.type === 'bracket' ? star : '*?';
var str = next && next.type === 'bracket' ? star() : '*?';
if (!prev.nodes || prev.nodes[1].type !== 'posix') {

@@ -271,3 +279,3 @@ return this.emit(str, node);

var prefix = !this.dotfiles && type !== 'text' && type !== 'escape'
? (this.options.dot ? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' : '(?!\\.)')
? (this.options.dot ? '(?!(?:^|[' + slash() + '])\\.{1,2}(?:$|[' + slash() + ']))' : '(?!\\.)')
: '';

@@ -277,3 +285,3 @@

if (prefix !== '(?!\\.)') {
prefix += '(?!(\\.{2}|\\.\\/))(?=.)';
prefix += '(?!(\\.{2}|\\.[' + slash() + ']))(?=.)';
} else {

@@ -290,3 +298,3 @@ prefix += '(?=.)';

var output = prefix + star;
var output = prefix + star();
if (this.options.capture) {

@@ -315,5 +323,5 @@ output = '(' + output + ')';

this.output = '(?:(?:\\.(?:\\/|\\\\))(?=.))?' + this.output;
this.output = '(?:\\.[' + slash() + '](?=.))?' + this.output;
if (this.state.metachar && prev.type !== 'qmark' && prev.type !== 'slash') {
val += (this.options.contains ? '(?:\\/|\\\\)?' : '(?:(?:\\/|\\\\)|$)');
val += (this.options.contains ? '[' + slash() + ']?' : '(?:[' + slash() + ']|$)');
}

@@ -320,0 +328,0 @@

@@ -13,3 +13,3 @@ 'use strict';

var cached;
var NOT_REGEX = '[!*+?$^"\'.\\\\/\\[]+';
var NOT_REGEX = '[\\[!*+?$^"\'.\\\\/]+';
var not = createTextRegex(NOT_REGEX);

@@ -39,3 +39,2 @@

if (this.parsed) return;
var pos = this.position();
var m = this.match(/^\.[\\/]/);

@@ -96,3 +95,3 @@ if (!m) return;

var pos = this.position();
var m = this.match(this.notRegex || /^\!+/);
var m = this.match(this.notRegex || /^!+/);
if (!m) return;

@@ -172,3 +171,3 @@ var val = m[0];

var pos = this.position();
var m = this.match(/^\*{2}(?![*(])(?=[,\/)]|$)/);
var m = this.match(/^\*{2}(?![*(])(?=[,)/]|$)/);
if (!m) return;

@@ -178,2 +177,3 @@

var node = pos({type: type, parsed: parsed});
this.state.metachar = true;

@@ -198,3 +198,2 @@ while (this.input.slice(0, 4) === '/**/') {

this.state.metachar = true;
return node;

@@ -209,3 +208,3 @@ })

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

@@ -283,3 +282,3 @@ if (!m) return;

var pos = this.position();
var m = this.match(/^(?:\[([!^]?)([^\]]+|\]\-)(\]|[^*+?]+)|\[)/);
var m = this.match(/^(?:\[([!^]?)([^\]]+|\]-)(\]|[^*+?]+)|\[)/);
if (!m) return;

@@ -388,3 +387,3 @@

var not = regexNot.create(pattern, opts);
var re = toRegex('^(?:[*]\\(|' + not + ')', opts);
var re = toRegex('^(?:[*]\\((?=.)|' + not + ')', opts);
return (cached = re);

@@ -391,0 +390,0 @@ }

@@ -10,2 +10,3 @@ 'use strict';

var isWindows = require('is-windows')();
var Snapdragon = require('snapdragon');

@@ -35,3 +36,3 @@ utils.define = require('define-property');

utils.isWindows = function() {
return path.sep === '\\' || process.platform === 'win32';
return path.sep === '\\' || isWindows === true;
};

@@ -65,3 +66,3 @@

utils.define(snapdragon, 'parse', function(str, options) {
var parsed = Snapdragon.prototype.parse.apply(this, arguments);
var parsed = Snapdragon.prototype.parse.call(this, str, options);
parsed.input = str;

@@ -154,3 +155,3 @@

utils.escapeRegex = function(str) {
return str.replace(/[-[\]{}()^$|*+?.\\\/\s]/g, '\\$&');
return str.replace(/[-[\]{}()^$|*+?.\\/\s]/g, '\\$&');
};

@@ -179,3 +180,3 @@

utils.hasSpecialChars = function(str) {
return /(?:(?:(^|\/)[!.])|[*?+()|\[\]{}]|[+@]\()/.test(str);
return /(?:(?:(^|\/)[!.])|[*?+()|[\]{}]|[+@]\()/.test(str);
};

@@ -212,3 +213,3 @@

utils.stripDrive = function(fp) {
return utils.isWindows() ? fp.replace(/^[a-z]:[\\\/]+?/i, '/') : fp;
return utils.isWindows() ? fp.replace(/^[a-z]:[\\/]+?/i, '/') : fp;
};

@@ -237,3 +238,3 @@

utils.isSimpleChar = function(str) {
return str === '' || str === ' ' || str === '.';
return str.trim() === '' || str === '.';
};

@@ -240,0 +241,0 @@

{
"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.2.7",
"version": "1.2.8",
"homepage": "https://github.com/micromatch/nanomatch",

@@ -30,7 +30,8 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"array-unique": "^0.3.2",
"define-property": "^1.0.0",
"extend-shallow": "^2.0.1",
"define-property": "^2.0.2",
"extend-shallow": "^3.0.2",
"fragment-cache": "^0.2.1",
"is-odd": "^1.0.0",
"kind-of": "^5.0.2",
"is-odd": "^2.0.0",
"is-windows": "^1.0.2",
"kind-of": "^6.0.2",
"object.pick": "^1.3.0",

@@ -46,10 +47,8 @@ "regex-not": "^1.0.0",

"gulp-format-md": "^1.0.0",
"gulp-istanbul": "^1.1.2",
"gulp-mocha": "^3.0.1",
"gulp-unused": "^0.2.1",
"gulp-istanbul": "^1.1.3",
"gulp-mocha": "^5.0.0",
"helper-changelog": "^0.3.0",
"is-windows": "^1.0.1",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"mocha": "^3.5.0",
"mocha": "^3.5.3",
"multimatch": "^2.1.0"

@@ -56,0 +55,0 @@ },

@@ -42,3 +42,3 @@ # 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)

* [Running benchmarks](#running-benchmarks)
* [Latest results](#latest-results)
* [Nanomatch vs. Minimatch vs. Multimatch](#nanomatch-vs-minimatch-vs-multimatch)
- [About](#about)

@@ -540,3 +540,3 @@

### [.create](index.js#L662)
### [.create](index.js#L658)

@@ -583,3 +583,3 @@ Parses the given glob `pattern` and returns an object with the compiled `output` and optional source `map`.

### [.parse](index.js#L701)
### [.parse](index.js#L697)

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

### [.compile](index.js#L749)
### [.compile](index.js#L745)

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

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

@@ -1012,46 +1012,46 @@ Clear the regex cache.

### Latest results
### Nanomatch vs. Minimatch vs. Multimatch
```bash
# globstar-basic (182 bytes)
minimatch x 70,508 ops/sec ±0.44% (92 runs sampled)
multimatch x 63,220 ops/sec ±0.76% (94 runs sampled)
nanomatch x 377,146 ops/sec ±0.45% (89 runs sampled)
minimatch x 69,512 ops/sec ±1.92% (88 runs sampled)
multimatch x 63,376 ops/sec ±1.41% (89 runs sampled)
nanomatch x 432,451 ops/sec ±0.92% (88 runs sampled)
fastest is nanomatch (by 564% avg)
fastest is nanomatch (by 651% avg)
# large-list-globstar (485686 bytes)
minimatch x 35.67 ops/sec ±0.47% (61 runs sampled)
multimatch x 34.80 ops/sec ±1.77% (60 runs sampled)
nanomatch x 509 ops/sec ±0.43% (90 runs sampled)
minimatch x 34.02 ops/sec ±1.42% (59 runs sampled)
multimatch x 33.58 ops/sec ±1.97% (58 runs sampled)
nanomatch x 483 ops/sec ±1.06% (86 runs sampled)
fastest is nanomatch (by 1445% avg)
fastest is nanomatch (by 1429% avg)
# long-list-globstar (194085 bytes)
minimatch x 397 ops/sec ±0.96% (89 runs sampled)
multimatch x 400 ops/sec ±0.32% (90 runs sampled)
nanomatch x 843 ops/sec ±0.40% (92 runs sampled)
minimatch x 383 ops/sec ±0.74% (90 runs sampled)
multimatch x 378 ops/sec ±0.59% (89 runs sampled)
nanomatch x 990 ops/sec ±1.14% (85 runs sampled)
fastest is nanomatch (by 212% avg)
fastest is nanomatch (by 260% avg)
# negation-basic (132 bytes)
minimatch x 224,342 ops/sec ±1.07% (90 runs sampled)
multimatch x 68,071 ops/sec ±0.80% (89 runs sampled)
nanomatch x 442,204 ops/sec ±1.09% (91 runs sampled)
minimatch x 242,145 ops/sec ±1.17% (89 runs sampled)
multimatch x 76,403 ops/sec ±0.78% (92 runs sampled)
nanomatch x 537,253 ops/sec ±1.44% (86 runs sampled)
fastest is nanomatch (by 302% avg)
fastest is nanomatch (by 337% avg)
# not-glob-basic (93 bytes)
minimatch x 222,156 ops/sec ±0.98% (89 runs sampled)
multimatch x 179,724 ops/sec ±1.04% (91 runs sampled)
nanomatch x 1,446,098 ops/sec ±0.45% (92 runs sampled)
minimatch x 252,402 ops/sec ±1.33% (89 runs sampled)
multimatch x 209,954 ops/sec ±1.30% (90 runs sampled)
nanomatch x 1,716,468 ops/sec ±1.13% (86 runs sampled)
fastest is nanomatch (by 720% avg)
fastest is nanomatch (by 742% avg)
# star-basic (93 bytes)
minimatch x 165,049 ops/sec ±1.22% (91 runs sampled)
multimatch x 132,553 ops/sec ±0.57% (90 runs sampled)
nanomatch x 522,080 ops/sec ±1.20% (92 runs sampled)
minimatch x 182,780 ops/sec ±1.41% (91 runs sampled)
multimatch x 153,210 ops/sec ±0.72% (89 runs sampled)
nanomatch x 599,621 ops/sec ±1.22% (90 runs sampled)
fastest is nanomatch (by 351% avg)
fastest is nanomatch (by 357% avg)

@@ -1108,3 +1108,3 @@ ```

| --- | --- |
| 144 | [jonschlinkert](https://github.com/jonschlinkert) |
| 159 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [devongovett](https://github.com/devongovett) |

@@ -1116,2 +1116,3 @@

* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)

@@ -1122,3 +1123,3 @@ * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

@@ -1128,2 +1129,2 @@

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on October 20, 2017._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 18, 2018._

Sorry, the diff of this file is not supported yet

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