Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

micromatch/picomatch

Developer Tools

A dependency-free JavaScript glob matcher supporting wildcards, extglobs, POSIX brackets, and regex syntax.

1,331
212
JavaScript
MIT
8 years old

Overview

Picomatch turns a glob pattern into a matcher function, letting Node.js code test path strings and file names against patterns such as *.js, **/*.js, or !(foo).!(bar). It handles wildcards (*, ?), nested-directory globstars (**), extglobs, comma-delimited braces, POSIX bracket classes, negated patterns, and escaping of special characters, and it has no runtime dependencies advanced globbing.

The library targets developers who need a small, fast glob engine inside tooling — file watchers, build pipelines, linters, test runners — or want to compile patterns to regular expressions themselves. The main export is a single function; the package also exposes helpers like isMatch, matchBase, parse, scan, makeRe, and toRegex API reference.

Install and first matcher

Install from npm in a project that uses a CommonJS or bundler-based setup:

npm install --save picomatch

Then create a matcher and reuse it for repeated tests; compiling once and reusing the returned function is the intended pattern for file watching and batch matching usage:

const picomatch = require('picomatch');
const isMatch = picomatch('*.js');

console.log(isMatch('abcd'));  // false
console.log(isMatch('a.js'));  // true
console.log(isMatch('a.md'));  // false
console.log(isMatch('a/b.js')); // false

For environments without Node.js path detection, picomatch/posix provides the same API with POSIX paths by default; pass windows: true in the options to also accept backslashes as separators main API.

Options that change matching

Frequently relevant options include dot (match dotfiles), nocase (case-insensitive), basename/matchBase (match against the file's basename), ignore (exclude patterns), bash (stricter Bash-like rules), windows, posix, noextglob, noglobstar, and nonegate. Callbacks onMatch, onIgnore, and onResult receive details of each evaluation options table.

Constraints and known differences

  • ** matches path separators only when it is the entire path segment; foo**/bar behaves like foo*/bar. Single * never crosses path separators in Picomatch, whereas Bash does for nested paths matching vs. Bash.
  • Brace support is limited to comma-delimited lists like {a,b}; ranges such as {01..03} and increments are not expanded natively — use micromatch for those braces.
  • POSIX bracket classes are off by default and require posix: true POSIX brackets.
  • By default, risky nested quantified extglobs such as +(a|aa) are treated literally rather than compiled, as a safeguard; maxExtglobRecursion can raise the limit options table.
  • Input strings longer than maxLength (default 65536) throw an error.
  • Requires a JavaScript runtime; the README documents CommonJS usage and a dependency-free POSIX build. License: MIT license.

HotRepo's take

Picomatch entered the JavaScript daily list on 2026-11-19 at position 6 with 3 stars gained, its only recorded snapshot in the supplied data; there is no multi-day series to infer momentum from. That single appearance fits a long-lived infrastructure library: with a 2018 creation date and 1,330 stars, it is not a new arrival. The README's own benchmark table reports Picomatch outrunning minimatch across star, globstar, and brace-range cases — including a stark difference on large ranges — but those are project-published figures on chosen patterns, so treat them as an indication of the library's optimization focus rather than an independent verdict. The maintained guardrails around extglob recursion and input length are worth noting when using user-supplied patterns.

Written by AI from the project's README, updated . The project's own docs are the source of truth.