push-stream-std

@push-stream-std/push-glob (0.0.8)

Published 2026-07-20 18:59:41 +00:00 by Dvorak

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.8
"@push-stream-std/push-glob": "0.0.8"

About this package

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

Description

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 18 or later. ESM only.

License

MIT

Dependencies

Dependencies

ID Version
@push-stream-std/push-stream-base *

Keywords

push-stream stream glob file fs
Details
npm
2026-07-20 18:59:41 +00:00
0
SEE LICENSE IN LICENSE
12 KiB
Assets (1)
Versions (11) View all
0.0.16 2026-07-21
0.0.15 2026-07-21
0.0.14 2026-07-21
0.0.13 2026-07-21
0.0.12 2026-07-21