multimatch
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@types/minimatch | 3.0.5 | 2.88 kB | MIT | prod | |
array-differ | 4.0.0 | 1.8 kB | MIT | prod | |
array-union | 3.0.1 | 1.81 kB | MIT | prod | |
minimatch | 3.1.2 | 11.66 kB | ISC | prod |
Multimatch is a powerful npm package that extends the functionality of the minimatch.match()
method with support for multiple patterns. It is essentially an advanced path (strings) matching tool that utilizes globbing patterns to precisely find path correspondences within your JavaScript code. Positive patterns (like *
) will add to the results, while negative patterns (e.g., !foo
) subtract from the results.
Multimatch is simple to use. First, install the package using npm by running npm install multimatch
in your terminal or command line interface. Then, in your JavaScript code, import multimatch and provide it with two arrays: one of the paths you want to match against and one for the globbing patterns to use. Here is an example usage:
import multimatch from 'multimatch';
const matches = multimatch(['unicorn', 'cake', 'rainbows'], ['*', '!cake']);
console.log(matches); //=> ['unicorn', 'rainbows']
In this case, matches
will be an array of matching paths in the order of input paths. As seen in the example, the multimatch function returns ['unicorn', 'rainbows']
because it matches all paths (*
) except 'cake' (!cake
).
Detailed documentation for multimatch is available on the package's GitHub Page: https://github.com/sindresorhus/multimatch. Here you can find a comprehensive breakdown of how multiple patterns work, a quick overview of globbing patterns, additional usage examples, as well as further information about the API and available options. For more detailed usage examples with expected matches, be sure to check out the Pattern examples and minimatch patterns as well.