Skip to content

Commit

Permalink
Document returnIndex; Add detail
Browse files Browse the repository at this point in the history
  • Loading branch information
es128 committed Nov 26, 2013
1 parent 6c6e309 commit bb28eb3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,15 @@ Usage
-----
`npm install anymatch --save`

#### 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
var anymatch = require('anymatch');

Expand All @@ -26,6 +35,9 @@ anymatch(matchers, 'path/anyjs/baz.js'); // true
anymatch(matchers, 'path/to/foo.js'); // true
anymatch(matchers, 'path/to/bar.js'); // true
anymatch(matchers, 'bar.js'); // false

// returnIndex = true
anymatch(matchers, 'foo.js', true); // 2
```

You can also use the `checker` method to get a function that has already been
Expand All @@ -35,6 +47,7 @@ bound to your matchers.
var matcher = anymatch.matcher(matchers);

matcher('path/to/file.js'); // true
matcher('path/anyjs/baz.js', true); // 1
```

License
Expand Down

0 comments on commit bb28eb3

Please sign in to comment.