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.

{\bfseries{Note\+: This module has Bash-\/parity, please be aware that Windows-\/style backslashes are not supported as separators. See \href{https://github.com/micromatch/micromatch\#backslashes}{\texttt{ https\+://github.\+com/micromatch/micromatch\#backslashes}} for more information.}}

\href{https://nodei.co/npm/anymatch/}{\texttt{ }} \href{https://nodei.co/npm-dl/anymatch/}{\texttt{ }}\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31837}{}\doxysection{Usage}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31837}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install anymatch -\/-\/save }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31838}{}\doxysubsubsection{anymatch (matchers, test\+String, \mbox{[}return\+Index\mbox{]}, \mbox{[}start\+Index\mbox{]}, \mbox{[}end\+Index\mbox{]})}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31838}

\begin{DoxyItemize}
\item {\bfseries{matchers}}\+: ({\itshape Array$\vert$\+String$\vert$\+Reg\+Exp$\vert$\+Function}) String to be directly matched, string with glob patterns, regular expression test, function that takes the test\+String as an argument and returns a truthy value if it should be matched, or an array of any number and mix of these types.
\item {\bfseries{test\+String}}\+: ({\itshape String$\vert$\+Array}) The string to test against the matchers. If passed as an array, the first element of the array will be used as the {\ttfamily test\+String} for non-\/function matchers, while the entire array will be applied as the arguments for function matchers.
\item {\bfseries{return\+Index}}\+: ({\itshape Boolean \mbox{[}optional\mbox{]}}) If true, return the array index of the first matcher that that test\+String matched, or -\/1 if no match, instead of a boolean result.
\item {\bfseries{start\+Index, end\+Index}}\+: ({\itshape Integer \mbox{[}optional\mbox{]}}) 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 {\ttfamily return\+Index = true} preserves original indexing. Behaves the same as {\ttfamily Array.\+prototype.\+slice} (i.\+e. includes array members up to, but not including end\+Index).
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{var anymatch = require('anymatch');}
\DoxyCodeLine{}
\DoxyCodeLine{var matchers = [}
\DoxyCodeLine{    'path/to/file.js',}
\DoxyCodeLine{    'path/anyjs/**/*.js',}
\DoxyCodeLine{    /foo\(\backslash\).js\$/,}
\DoxyCodeLine{    function (string) \{}
\DoxyCodeLine{        return string.indexOf('bar') !== -\/1 \&\& string.length > 10}
\DoxyCodeLine{    \}}
\DoxyCodeLine{];}
\DoxyCodeLine{}
\DoxyCodeLine{anymatch(matchers, 'path/to/file.js'); // true}
\DoxyCodeLine{anymatch(matchers, 'path/anyjs/baz.js'); // true}
\DoxyCodeLine{anymatch(matchers, 'path/to/foo.js'); // true}
\DoxyCodeLine{anymatch(matchers, 'path/to/bar.js'); // true}
\DoxyCodeLine{anymatch(matchers, 'bar.js'); // false}
\DoxyCodeLine{}
\DoxyCodeLine{// returnIndex = true}
\DoxyCodeLine{anymatch(matchers, 'foo.js', true); // 2}
\DoxyCodeLine{anymatch(matchers, 'path/anyjs/foo.js', true); // 1}
\DoxyCodeLine{}
\DoxyCodeLine{// skip matchers}
\DoxyCodeLine{anymatch(matchers, 'path/to/file.js', false, 1); // false}
\DoxyCodeLine{anymatch(matchers, 'path/anyjs/foo.js', true, 2, 3); // 2}
\DoxyCodeLine{anymatch(matchers, 'path/to/bar.js', true, 0, 3); // -\/1}
\DoxyCodeLine{}
\DoxyCodeLine{// using globs to match directories and their children}
\DoxyCodeLine{anymatch('node\_modules', 'node\_modules'); // true}
\DoxyCodeLine{anymatch('node\_modules', 'node\_modules/somelib/index.js'); // false}
\DoxyCodeLine{anymatch('node\_modules/**', 'node\_modules/somelib/index.js'); // true}
\DoxyCodeLine{anymatch('node\_modules/**', '/absolute/path/to/node\_modules/somelib/index.js'); // false}
\DoxyCodeLine{anymatch('**/node\_modules/**', '/absolute/path/to/node\_modules/somelib/index.js'); // true }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31839}{}\doxysubsubsection{anymatch (matchers)}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31839}
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 {\ttfamily Array.\+prototype.\+filter} callback.


\begin{DoxyCode}{0}
\DoxyCodeLine{var matcher = anymatch(matchers);}
\DoxyCodeLine{}
\DoxyCodeLine{matcher('path/to/file.js'); // true}
\DoxyCodeLine{matcher('path/anyjs/baz.js', true); // 1}
\DoxyCodeLine{matcher('path/anyjs/baz.js', true, 2); // -\/1}
\DoxyCodeLine{}
\DoxyCodeLine{['foo.js', 'bar.js'].filter(matcher); // ['foo.js'] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31840}{}\doxysection{Change Log}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31840}
\href{https://github.com/micromatch/anymatch/releases}{\texttt{ See release notes page on Git\+Hub}}

NOTE\+: As of v2.\+0.\+0, \href{https://github.com/jonschlinkert/micromatch}{\texttt{ micromatch}} moves away from minimatch-\/parity and inline with Bash. This includes handling backslashes differently (see \href{https://github.com/micromatch/micromatch\#backslashes}{\texttt{ https\+://github.\+com/micromatch/micromatch\#backslashes}} for more information).

NOTE\+: As of v1.\+2.\+0, anymatch uses \href{https://github.com/jonschlinkert/micromatch}{\texttt{ micromatch}} for glob pattern matching. Issues with glob pattern matching should be reported directly to the \href{https://github.com/jonschlinkert/micromatch/issues}{\texttt{ micromatch issue tracker}}.\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31841}{}\doxysection{License}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_anymatch_README_autotoc_md31841}
\href{https://raw.github.com/micromatch/anymatch/master/LICENSE}{\texttt{ ISC}} 