Comparing version 0.1.0 to 0.1.1
@@ -6,18 +6,32 @@ // Generated by CoffeeScript 1.6.3 | ||
anymatch = function(criteria, string) { | ||
anymatch = function(criteria, string, returnIndex) { | ||
var matchIndex, matched; | ||
if ('[object Array]' !== toString.call(criteria)) { | ||
criteria = [criteria]; | ||
} | ||
return criteria.some(function(criterion) { | ||
switch (toString.call(criterion)) { | ||
case '[object String]': | ||
return string === criterion || minimatch(string, criterion); | ||
case '[object RegExp]': | ||
return criterion.test(string); | ||
case '[object Function]': | ||
return criterion(string); | ||
default: | ||
return false; | ||
matchIndex = -1; | ||
matched = criteria.some(function(criterion, index) { | ||
var result; | ||
result = (function() { | ||
switch (toString.call(criterion)) { | ||
case '[object String]': | ||
return string === criterion || minimatch(string, criterion); | ||
case '[object RegExp]': | ||
return criterion.test(string); | ||
case '[object Function]': | ||
return criterion(string); | ||
default: | ||
return false; | ||
} | ||
})(); | ||
if (result) { | ||
matchIndex = index; | ||
} | ||
return result; | ||
}); | ||
if (returnIndex === true) { | ||
return matchIndex; | ||
} else { | ||
return matched; | ||
} | ||
}; | ||
@@ -24,0 +38,0 @@ |
{ | ||
"name": "anymatch", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -12,2 +12,11 @@ anymatch | ||
#### anymatch (matchers, testString, [returnIndex]) | ||
* __matchers__: (_Array_|_String_|_RegExp_|_Function_) | ||
String to be directly matched, string with glob patterns, regular expression | ||
test, function that takes the testString as an argument and returns a truthy | ||
value if it should be matched, or an array of any number and mix of these types. | ||
* __testString__: (_String_) The string to test against the matchers. | ||
* __returnIndex__: (_Boolean_, _optional_) If true, return the array index of | ||
the first matcher that that testString matched, instead of a boolean result. | ||
```js | ||
@@ -30,2 +39,5 @@ var anymatch = require('anymatch'); | ||
anymatch(matchers, 'bar.js'); // false | ||
// returnIndex = true | ||
anymatch(matchers, 'foo.js', true); // 2 | ||
``` | ||
@@ -40,2 +52,3 @@ | ||
matcher('path/to/file.js'); // true | ||
matcher('path/anyjs/baz.js', true); // 1 | ||
``` | ||
@@ -42,0 +55,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5312
38
56