minimatch
minimatch is a minimal matching utility that tests whether a filename or path string matches a given glob pattern. Unlike the glob library which performs actual…
Installation
npm install minimatch
yarn add minimatch
pnpm add minimatch
Import
import { minimatch } from 'minimatch';Quick Example
import { minimatch } from 'minimatch';
minimatch('src/app.ts', '**/*.ts'); // true
minimatch('node_modules/x', '!node_modules/**'); // false
minimatch('test.js', '*.{js,ts}'); // trueAbout minimatch
minimatch is a minimal matching utility that tests whether a filename or path string matches a given glob pattern. Unlike the glob library which performs actual filesystem operations to find matching files, minimatch is a pure string-matching library that determines if a pattern matches a string without touching the filesystem. The library supports the full glob syntax including wildcards (*), globstars (**), character classes ([...]), negation (!), brace expansion ({a,b}), and extglob patterns (?(pattern), *(pattern), +(pattern), @(pattern), !(pattern)). minimatch is used internally by npm for matching package files against ignore patterns, by glob for its pattern matching, and by numerous other tools that need to check if filenames conform to patterns. The library provides a Minimatch class for pre-compiling patterns for repeated matching against many filenames, which is significantly faster than re-parsing the pattern each time. minimatch handles platform-specific path separators and supports options for dot file matching, case sensitivity, and partial matching. The library is one of the most depended-upon packages in the npm ecosystem.
Quick Facts
| Package | minimatch |
| Category | Utility |
| Weekly Downloads | 40M+ |
| License | ISC |
| Install | npm install minimatch |
Related Packages
glob is a library for matching files using glob patterns — the wildcard syntax familiar from shell c…
fast-glob is a high-performance glob matching library for Node.js that provides significant speed im…
Globby is a user-friendly glob matching library built on top of fast-glob that provides a convenient…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.