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.
| Argument | Type | Description |
|---|---|---|
pattern | string | Glob pattern (e.g. **/*.js). |
options | object | Optional. 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:
| Scenario | Baseline | Rush-FS | Note |
|---|---|---|---|
Large tree node_modules/**/*.json (~30k entries) | fast-glob 303 ms | 30 ms | ~10x faster |
Recursive **/*.rs (small/medium tree) | node-glob 22 ms | 40 ms | node-glob faster at this scale |
Simple src/*.rs | node-glob 46 µs | 1.5 ms | Rush-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