Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
This package has been deprecated with the following message: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
Generated on Nov 29, 2023 via pnpm

minimatch 0.3.0

a glob matcher in javascript
Package summary
Share
0
issues
0
licenses
Package created
16 Jul 2011
Version published
13 May 2014
Maintainers
1
Total deps
0
Direct deps
0
License
MIT

Issues

0
This package has no issues

Frequently Asked Questions

What does minimatch do?

Minimatch is a minimalist matching utility used by npm internally. It utilizes glob expressions, converting them into JavaScript RegExp objects, to perform matching operations. This makes it an essential tool for a variety of tasks involving pattern matching in JavaScript.

How do you use minimatch?

To use minimatch in your JavaScript project, you first need to import it. You can either require the module or import it - both ways are supported. After importing, you call the minimatch function with two parameters - the string you want to test and the pattern you want to match against. For example:

const { minimatch } = require('minimatch');

console.log(minimatch('bar.foo', '*.foo')); // Outputs: true
console.log(minimatch('bar.foo', '*.bar')); // Outputs: false
console.log(minimatch('bar.foo', '*.+(bar|foo)', { debug: true })); // Outputs: true

As seen in the code block above, minimatch supports brace expansion, extended glob matching, Globstar '**' matching, and POSIX character classes - offering a wide variety of pattern matching options.

Now let's look at different operation you can perform. You can create a minimatch object using the minimatch.Minimatch class. For example:

var Minimatch = require('minimatch').Minimatch
var mm = new Minimatch(pattern, options)

The package also provides several functions to interact with pattern such as the filter(), makeRe(), escape(), unescape() and match() methods among others which can be used depending on your specific needs. For instance:

var isJS = minimatch(file, '*.js', { matchBase: true });
var javascripts = fileList.filter(minimatch.filter('*.js', { matchBase: true }));
var javascripts = minimatch.match(fileList, '*.js', { matchBase: true });

Where are the minimatch docs?

The documentation for the minimatch npm package can be found in the README file in its GitHub repository. The repository's URL is git://github.com/isaacs/minimatch.git. The README contains detailed information about usage, features, options and everything you need to effectively utilize the minimatch utility in your JavaScript projects.