picomatch
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Picomatch is a blazing fast and accurate glob matcher written in JavaScript with no dependencies. It extends full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions. This makes it suitable for matching inputs against certain patterns or conditions, which could be leveraged to perform variety of tasks. For instance, it could be used as a file matcher for a task runner, or to match routes in a web application.
To use Picomatch, you would first need to install it via npm by running npm install --save picomatch
. After successful installation, you can import it in your JavaScript file using const pm = require('picomatch');
.
With Picomatch imported, you can take advantage of its primary function that takes a glob pattern and returns a matcher function. For example:
const pm = require('picomatch');
// Create a matcher function using glob pattern '*.js'
const isMatch = pm('*.js');
// Test with different strings
console.log(isMatch('abcd')); // Output: false
console.log(isMatch('a.js')); // Output: true
console.log(isMatch('a.md')); // Output: false
console.log(isMatch('a/b.js')); // Output: false
In the above example, isMatch
is a matcher function that checks if a string ends with '.js'. Therefore, it would return true
for 'a.js' and false
for others.
Picomatch's full documentation is included in its readme, which lays out its API, globbing features, options, and benchmarks for comparison with other libraries. You can find additional information and get deeper insights about advanced features such as brace expansion, POSIX brackets, and extglobs directly from the readme content. For more detailed glob pattern matching guides, you can check out the bash documentation referred in the readme.
To refer to Picomatch's documentation, visit its GitHub repository at https://github.com/micromatch/picomatch.