@push-stream-std/push-glob (0.0.9)
Installation
@push-stream-std:registry=https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/npm install @push-stream-std/push-glob@0.0.9"@push-stream-std/push-glob": "0.0.9"About this package
@push-stream-std/push-glob
Stream file paths matching glob pattern.
Published as @push-stream-std/push-glob.
Synopsis
import glob from '@push-stream-std/push-glob';
glob('**/*.js', { cwd: './src' }).pipe({
write(path) { console.log(path); },
end(err) { if (err) console.error(err); else console.log('Done scanning.'); },
abort(err) { console.error('aborted:', err); },
paused: false
});
Install
npm config set @push-stream-std:registry https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/
npm config set -- //hub.kl1.tenere.ai/api/packages/push-stream-std/npm/:_authToken "$PACKAGE_TOKEN"
npm install @push-stream-std/push-glob
Why
Resolves a glob pattern against the filesystem and streams matching file paths as a push-stream source. Uses Node.js fs.glob under the hood with promise wrapping for async execution. Supports cwd, dot, and ignore options. Results are buffered in a queue and emitted via push-stream resume calls, with O(1) amortized dequeue via the head pointer pattern. Handles backpressure by holding paths when the sink is paused.
API
glob(pattern, options)
pattern-string- Glob pattern to match files against (e.g.'**/*.js','*.txt').options.cwd-string(default:'.') - Working directory for the glob search.options.dot-boolean(default:false) - Whether to include files starting with..options.ignore-string | string[]- Glob patterns to ignore.
Returns a push-stream source. Pipe it to a sink to receive file path strings. Call source.abort(err) to cancel the scan. If the pattern matches nothing, the sink receives no writes and ends normally.
Tests
npm test
Tests cover matching files in directories, multiple patterns (*.{txt,md}), recursive subdirectory matching (**/*.txt), handling of no matches, dot option, backpressure, and abort on error.
Requirements
Node.js 22 or later. ESM only.
Dependencies
Dependencies
| ID | Version |
|---|---|
| @push-stream-std/push-stream-base | * |