push-stream-std

@push-stream-std/push-pushable (0.0.10)

Published 2026-07-21 04:00:00 +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-pushable@0.0.10
"@push-stream-std/push-pushable": "0.0.10"

About this package

@push-stream-std/push-pushable

A source stream with an imperative push() / end() interface.

Published as @push-stream-std/push-pushable.

Synopsis

import pushable from '@push-stream-std/push-pushable';
import concat from '@push-stream-std/push-concat';

const source = pushable(function onClose(err) {
  if (err) console.error('closed with error:', err);
  else console.log('closed normally');
});

source.pipe(concat((err, result) => {
  if (err) return console.error(err);
  console.log(result); // [1, 2, 3]
}));

source.push(1);
source.push(2);
source.push(3);
source.end();

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-pushable

Why

Creates a source stream that can be programmatically fed values via push(). Values are forwarded to any piped sink, with internal buffering when the sink is paused. The stream is ended with end(err?), which signals normal completion or an error to downstream. An optional onClose callback fires once when the stream terminates.

API

pushable(onClose?)

Creates a pushable source stream.

  • onClose (err?) => void (optional) – Called once when the stream ends. Receives null for normal end, or the error if ended with an error.
  • Returns A source stream with pipe(), resume(), abort(err?), and the following additional methods:

source.push(value)

Push a value into the stream. If a sink is piped and not paused, the value is written immediately. Otherwise it is buffered.

source.end(err?)

End the stream. Any buffered values are flushed first. If an error is passed, the sink receives it. If onClose was provided, it is called.

source.abort(err?)

Abort the stream immediately. The buffer is cleared and the sink receives an abort signal. If onClose was provided, it is called.

Tests

npm test

Tests cover push and pipe ordering, end with buffered flush, error propagation, abort clearing the buffer, the onClose callback, and backpressure buffering.

Requirements

Node.js 22 or later. ESM only.

Dependencies

Dependencies

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

Development Dependencies

ID Version
fast-check ^3.23.2

Keywords

push-stream stream pushable
Details
npm
2026-07-21 04:00:00 +00:00
0
SEE LICENSE IN LICENSE
latest
3.9 KiB
Assets (1)
Versions (7) View all
0.0.10 2026-07-21
0.0.9 2026-07-20
0.0.8 2026-07-20
0.0.7 2026-07-20
0.0.6 2026-07-19