🛠️
Utility40M+/wkISC

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
npm install minimatch
yarn
yarn add minimatch
pnpm
pnpm add minimatch

Import

ESM
import { minimatch } from 'minimatch';

Quick Example

usage
import { minimatch } from 'minimatch';

minimatch('src/app.ts', '**/*.ts'); // true
minimatch('node_modules/x', '!node_modules/**'); // false
minimatch('test.js', '*.{js,ts}'); // true

About 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

Packageminimatch
CategoryUtility
Weekly Downloads40M+
LicenseISC
Installnpm install minimatch

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.