Skip to Content
APIglob

glob

Match files and directories by glob pattern (e.g. **/*.js). Supports concurrency and gitIgnore (Rush-FS extensions). Uses ignore  for matching.

Basic usage

import { glob } from '@rush-fs/core' const files = await glob('**/*.ts', { cwd: './src' }) const entries = await glob('**/*.rs', { cwd: './crate', withFileTypes: true, concurrency: 4, gitIgnore: true })

Methods

glob(pattern, options?)

Async. Returns Promise<string[]> or Promise<Array<{ name, parentPath, isDir }>> when withFileTypes: true.

ArgumentTypeDescription
patternstringGlob pattern (e.g. **/*.js).
optionsobjectOptional. See below.

Options: cwd (string), withFileTypes (boolean), exclude (string[]), concurrency (number, default 4), gitIgnore (boolean, respect .gitignore).

globSync(pattern, options?)

Sync. Same arguments and return types.

Performance

From repo benchmarks (pnpm build && pnpm bench glob), Apple Silicon, Node 24, release build:

ScenarioBaselineRush-FSNote
Large tree node_modules/**/*.json (~30k entries)fast-glob 303 ms30 ms~10x faster
Recursive **/*.rs (small/medium tree)node-glob 22 ms40 msnode-glob faster at this scale
Simple src/*.rsnode-glob 46 µs1.5 msRush-FS has fixed startup cost; use for large trees

Rush-FS excels at large, deep trees (e.g. node_modules); tune concurrency for very large directories.

Notes

  • gitIgnore: When true, respects .gitignore (and similar) for exclusion; Rush-FS extension.
  • concurrency: Rush-FS extension; default 4. Increase for very large directories.
  • exclude: Additional patterns to exclude; applied with the same semantics as the ignore crate.
Last updated on