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

anymatch

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anymatch - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

36

lib/index.js

@@ -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

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