Socket
Socket
Sign inDemoInstall

anymatch

Package Overview
Dependencies
3
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.2.0

test/readme.js

14

lib/index.js

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

// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
'use strict';
var anymatch, minimatch;

@@ -6,9 +7,12 @@

anymatch = function(criteria, string, returnIndex) {
anymatch = function(criteria, string, returnIndex, startIndex, endIndex) {
var matchIndex, matched;
if ('[object Array]' !== toString.call(criteria)) {
if (startIndex == null) {
startIndex = 0;
}
if (!Array.isArray(criteria)) {
criteria = [criteria];
}
matchIndex = -1;
matched = criteria.some(function(criterion, index) {
matched = criteria.slice(startIndex, endIndex).some(function(criterion, index) {
var result;

@@ -28,3 +32,3 @@ result = (function() {

if (result) {
matchIndex = index;
matchIndex = index + startIndex;
}

@@ -31,0 +35,0 @@ return result;

{
"name": "anymatch",
"version": "0.1.1",
"version": "0.2.0",
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",

@@ -36,5 +36,11 @@ "author": {

"scripts": {
"prepublish": "rm -rf lib && coffee --bare --output lib/ src/"
"prepublish": "rm -rf lib && coffee --bare --output lib/ src/",
"test": "rm -rf lib && coffee --bare --output lib/ src/ && istanbul test _mocha -- test/test.* --compilers coffee:coffee-script/register"
},
"license": "MIT"
"license": "MIT",
"devDependencies": {
"coffee-script": "~1.7.1",
"mocha": "~1.17.1",
"istanbul": "~0.2.4"
}
}

@@ -12,4 +12,4 @@ anymatch

#### anymatch (matchers, testString, [returnIndex])
* __matchers__: (_Array_|_String_|_RegExp_|_Function_)
#### anymatch (matchers, testString, [returnIndex], [startIndex], [endIndex])
* __matchers__: (_Array|String|RegExp|Function_)
String to be directly matched, string with glob patterns, regular expression

@@ -19,4 +19,10 @@ test, function that takes the testString as an argument and returns a truthy

* __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.
* __returnIndex__: (_Boolean [optional]_) If true, return the array index of
the first matcher that that testString matched, or -1 if no match, instead of a
boolean result.
* __startIndex, endIndex__: (_Integer [optional]_) Can be used to define a
subset out of the array of provided matchers to test against. Can be useful
with bound matcher functions (see below). When used with `returnIndex = true`
preserves original indexing. Behaves the same as `Array.prototype.slice` (i.e.
includes array members up to, but not including endIndex).

@@ -43,6 +49,14 @@ ```js

anymatch(matchers, 'foo.js', true); // 2
anymatch(matchers, 'path/anyjs/foo.js', true); // 1
// skip matchers
anymatch(matchers, 'path/to/file.js', false, 1); // false
anymatch(matchers, 'path/anyjs/foo.js', true, 2, 3); // 2
anymatch(matchers, 'path/to/bar.js', true, 0, 3); // -1
```
You can also use the `checker` method to get a function that has already been
bound to your matchers.
#### anymatch.matcher (matchers)
You can also use the `matcher` method to get a function that has already been
bound to your matcher(s). This can be used as an `Array.prototype.filter`
callback.

@@ -54,2 +68,5 @@ ```js

matcher('path/anyjs/baz.js', true); // 1
matcher('path/anyjs/baz.js', true, 2); // -1
['foo.js', 'bar.js'].filter(matcher); // ['foo.js']
```

@@ -56,0 +73,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc