fast-glob
fast-glob is a high-performance glob matching library for Node.js that provides significant speed improvements over the traditional glob package. fast-glob achi…
Installation
npm install fast-glob
yarn add fast-glob
pnpm add fast-glob
Import
import fg from 'fast-glob';
Quick Example
import fg from 'fast-glob';
const entries = await fg(['src/**/*.ts', '!**/*.d.ts'], {
dot: false,
ignore: ['node_modules'],
});
const stream = fg.stream('**/*.json');
for await (const entry of stream) {
console.log(entry);
}About fast-glob
fast-glob is a high-performance glob matching library for Node.js that provides significant speed improvements over the traditional glob package. fast-glob achieves its performance through several optimizations: it uses micromatch for pattern matching, implements efficient directory traversal that prunes search paths early based on pattern analysis, supports concurrent filesystem operations, and avoids unnecessary stat calls. The library provides both async and sync APIs with stream support for processing results incrementally. fast-glob supports standard glob features including ** for recursive matching, brace expansion, character classes, and negation patterns. Configuration options include cwd for base directory, ignore patterns, dot file inclusion, follow symlinks, depth limiting, unique results, case sensitivity, and stats inclusion. fast-glob is used internally by globby, Vite, Rollup, PostCSS, and many other tools as their file matching engine. Benchmarks show fast-glob performing 2-5x faster than the traditional glob package for typical workspace scanning patterns. The library handles edge cases like circular symlinks, permission errors, and platform-specific path separators. For applications that need raw performance in file discovery without the convenience features of globby, fast-glob is the optimal choice.
Quick Facts
| Package | fast-glob |
| Category | File System |
| Weekly Downloads | 30M+ |
| License | MIT |
| Install | npm install fast-glob |
Related Packages
Globby is a user-friendly glob matching library built on top of fast-glob that provides a convenient…
glob is a library for matching files using glob patterns — the wildcard syntax familiar from shell c…
minimatch is a minimal matching utility that tests whether a filename or path string matches a given…
Chokidar is a fast, efficient file watching library for Node.js that provides a reliable cross-platf…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.