Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / anymatch / README.md
1 anymatch [![Build Status](https://travis-ci.org/es128/anymatch.svg?branch=master)](https://travis-ci.org/es128/anymatch) [![Coverage Status](https://img.shields.io/coveralls/es128/anymatch.svg?branch=master)](https://coveralls.io/r/es128/anymatch?branch=master)
2 ======
3 Javascript module to match a string against a regular expression, glob, string,
4 or function that takes the string as an argument and returns a truthy or falsy
5 value. The matcher can also be an array of any or all of these. Useful for
6 allowing a very flexible user-defined config to define things like file paths.
7
8 [![NPM](https://nodei.co/npm/anymatch.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/anymatch/)
9 [![NPM](https://nodei.co/npm-dl/anymatch.png?height=3&months=9)](https://nodei.co/npm-dl/anymatch/)
10
11 Usage
12 -----
13 ```sh
14 npm install anymatch --save
15 ```
16
17 #### anymatch (matchers, testString, [returnIndex], [startIndex], [endIndex])
18 * __matchers__: (_Array|String|RegExp|Function_)
19 String to be directly matched, string with glob patterns, regular expression
20 test, function that takes the testString as an argument and returns a truthy
21 value if it should be matched, or an array of any number and mix of these types.
22 * __testString__: (_String|Array_) The string to test against the matchers. If
23 passed as an array, the first element of the array will be used as the
24 `testString` for non-function matchers, while the entire array will be applied
25 as the arguments for function matchers.
26 * __returnIndex__: (_Boolean [optional]_) If true, return the array index of
27 the first matcher that that testString matched, or -1 if no match, instead of a
28 boolean result.
29 * __startIndex, endIndex__: (_Integer [optional]_) Can be used to define a
30 subset out of the array of provided matchers to test against. Can be useful
31 with bound matcher functions (see below). When used with `returnIndex = true`
32 preserves original indexing. Behaves the same as `Array.prototype.slice` (i.e.
33 includes array members up to, but not including endIndex).
34
35 ```js
36 var anymatch = require('anymatch');
37
38 var matchers = [
39         'path/to/file.js',
40         'path/anyjs/**/*.js',
41         /foo.js$/,
42         function (string) {
43                 return string.indexOf('bar') !== -1 && string.length > 10
44         }
45 ];
46
47 anymatch(matchers, 'path/to/file.js'); // true
48 anymatch(matchers, 'path/anyjs/baz.js'); // true
49 anymatch(matchers, 'path/to/foo.js'); // true
50 anymatch(matchers, 'path/to/bar.js'); // true
51 anymatch(matchers, 'bar.js'); // false
52
53 // returnIndex = true
54 anymatch(matchers, 'foo.js', true); // 2
55 anymatch(matchers, 'path/anyjs/foo.js', true); // 1
56
57 // skip matchers
58 anymatch(matchers, 'path/to/file.js', false, 1); // false
59 anymatch(matchers, 'path/anyjs/foo.js', true, 2, 3); // 2
60 anymatch(matchers, 'path/to/bar.js', true, 0, 3); // -1
61 ```
62
63 #### anymatch (matchers)
64 You can also pass in only your matcher(s) to get a curried function that has
65 already been bound to the provided matching criteria. This can be used as an
66 `Array.prototype.filter` callback.
67
68 ```js
69 var matcher = anymatch(matchers);
70
71 matcher('path/to/file.js'); // true
72 matcher('path/anyjs/baz.js', true); // 1
73 matcher('path/anyjs/baz.js', true, 2); // -1
74
75 ['foo.js', 'bar.js'].filter(matcher); // ['foo.js']
76 ```
77
78 Change Log
79 ----------
80 [See release notes page on GitHub](https://github.com/es128/anymatch/releases)
81
82 NOTE: As of v1.2.0, anymatch uses [micromatch](https://github.com/jonschlinkert/micromatch)
83 for glob pattern matching. The glob matching behavior should be functionally
84 equivalent to the commonly used [minimatch](https://github.com/isaacs/minimatch)
85 library (aside from some fixed bugs and greater performance), so a major
86 version bump wasn't merited. Issues with glob pattern matching should be
87 reported directly to the [micromatch issue tracker](https://github.com/jonschlinkert/micromatch/issues).
88
89 License
90 -------
91 [ISC](https://raw.github.com/es128/anymatch/master/LICENSE)