anymatch
Advanced tools
Comparing version 1.1.0 to 1.2.0
22
index.js
'use strict'; | ||
var minimatch = require('minimatch'); | ||
var micromatch = require('micromatch'); | ||
var arrify = require('arrify'); | ||
var anymatch = function(criteria, value, returnIndex, startIndex, endIndex) { | ||
if (!Array.isArray(criteria)) { criteria = [criteria]; } | ||
if (arguments.length === 1) { return anymatch.bind(null, criteria); } | ||
var string = Array.isArray(value) ? value[0] : value; | ||
if (!startIndex) { startIndex = 0; } | ||
criteria = arrify(criteria); | ||
value = arrify(value); | ||
if (arguments.length === 1) { | ||
return criteria.length === 1 ? | ||
micromatch.matcher(criteria[0]) : | ||
anymatch.bind(null, criteria.map(function(criterion) { | ||
return micromatch.matcher(criterion); | ||
})); | ||
} | ||
startIndex = startIndex || 0; | ||
var string = value[0]; | ||
var matchIndex = -1; | ||
@@ -15,3 +23,3 @@ function testCriteria (criterion, index) { | ||
case '[object String]': | ||
result = string === criterion || minimatch(string, criterion); | ||
result = string === criterion || micromatch.isMatch(string, criterion); | ||
break; | ||
@@ -22,3 +30,3 @@ case '[object RegExp]': | ||
case '[object Function]': | ||
result = criterion.apply(null, Array.isArray(value) ? value : [value]); | ||
result = criterion.apply(null, value); | ||
break; | ||
@@ -25,0 +33,0 @@ default: |
{ | ||
"name": "anymatch", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions", | ||
@@ -40,3 +40,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"minimatch": "~1.0.0" | ||
"arrify": "^1.0.0", | ||
"micromatch": "^2.1.0" | ||
}, | ||
@@ -43,0 +44,0 @@ "devDependencies": { |
@@ -82,4 +82,11 @@ anymatch [![Build Status](https://travis-ci.org/es128/anymatch.svg)](https://travis-ci.org/es128/anymatch) [![Coverage Status](https://img.shields.io/coveralls/es128/anymatch.svg)](https://coveralls.io/r/es128/anymatch?branch=master) | ||
NOTE: As of v1.2.0, anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch) | ||
for glob pattern matching. The glob matching behavior should be functionally | ||
equivalent to the commonly used [minimatch](https://github.com/isaacs/minimatch) | ||
library (aside from some fixed bugs and greater performance), so a major | ||
version bump wasn't merited. Issues with glob pattern matching should be | ||
reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues). | ||
License | ||
------- | ||
[ISC](https://raw.github.com/es128/anymatch/master/LICENSE) |
6782
4
38
92
2
+ Addedarrify@^1.0.0
+ Addedmicromatch@^2.1.0
+ Addedarr-diff@2.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarray-unique@0.2.1(transitive)
+ Addedarrify@1.0.1(transitive)
+ Addedbraces@1.8.5(transitive)
+ Addedexpand-brackets@0.1.5(transitive)
+ Addedexpand-range@1.8.2(transitive)
+ Addedextglob@0.3.2(transitive)
+ Addedfilename-regex@2.0.1(transitive)
+ Addedfill-range@2.2.4(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfor-own@0.1.5(transitive)
+ Addedglob-base@0.3.0(transitive)
+ Addedglob-parent@2.0.0(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-dotfile@1.0.3(transitive)
+ Addedis-equal-shallow@0.1.3(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedis-number@2.1.04.0.0(transitive)
+ Addedis-posix-bracket@0.1.1(transitive)
+ Addedis-primitive@2.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.0(transitive)
+ Addedkind-of@3.2.26.0.3(transitive)
+ Addedmath-random@1.0.4(transitive)
+ Addedmicromatch@2.3.11(transitive)
+ Addednormalize-path@2.1.1(transitive)
+ Addedobject.omit@2.0.1(transitive)
+ Addedparse-glob@3.0.4(transitive)
+ Addedpreserve@0.2.0(transitive)
+ Addedrandomatic@3.1.1(transitive)
+ Addedregex-cache@0.4.4(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
- Removedminimatch@~1.0.0
- Removedlru-cache@2.7.3(transitive)
- Removedminimatch@1.0.0(transitive)
- Removedsigmund@1.0.1(transitive)