📂
File System30M+/wkMIT

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

Import

ESM
import fg from 'fast-glob';

Quick Example

usage
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

Packagefast-glob
CategoryFile System
Weekly Downloads30M+
LicenseMIT
Installnpm install fast-glob

Related Packages

Browse npm Packages by Category

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