anymatch / 1.3.0 last updated a year ago created on Nov 25th 2013
Install
npm install --save anymatch
Clone
git clone git@github.com:es128/anymatch.git
dependencies
show all 37
| main |
|
arrify | 1.0.1 | MIT |
|
|
micromatch | 2.3.7 | MIT |
maintainers
versions
8 total
| 1.3.0 | a year ago | es128 |
| 1.2.1 | a year ago | es128 |
| 1.2.0 | a year ago | es128 |
| 1.1.0 | a year ago | es128 |
| 1.0.0 | a year ago | es128 |
| 0.2.0 | 2 years ago | es128 |
| 0.1.1 | 2 years ago | es128 |
| 0.1.0 | 2 years ago | es128 |
readme
anymatch

Javascript module to match a string against a regular expression, glob, string, or function that takes the string as an argument and returns a truthy or falsy value. The matcher can also be an array of any or all of these. Useful for allowing a very flexible user-defined config to define things like file paths.
Usage
anymatch (matchers, testString, [returnIndex], [startIndex], [endIndex])
- 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|Array) The string to test against the matchers. If
passed as an array, the first element of the array will be used as the
testStringfor non-function matchers, while the entire array will be applied as the arguments for function matchers. - 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 = truepreserves original indexing. Behaves the same asArray.prototype.slice(i.e. includes array members up to, but not including endIndex).
anymatch (matchers)
You can also pass in only your matcher(s) to get a curried function that has
already been bound to the provided matching criteria. This can be used as an
Array.prototype.filter callback.
Change Log
See release notes page on GitHub
NOTE: As of v1.2.0, anymatch uses micromatch for glob pattern matching. The glob matching behavior should be functionally equivalent to the commonly used 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.

