push-stream-std

@push-stream-std/push-pair (0.0.4)

Published 2026-07-19 21:15:44 +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-pair@0.0.4
"@push-stream-std/push-pair": "0.0.4"

About this package

push-pair

Create a connected source and sink pair — data written to the sink appears at the source.

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

Synopsis

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

const { source, sink } = pair();

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

sink.write(1);
sink.write(2);
sink.write(3);
sink.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-pair

Description

A connected source-sink pair. Values written to the sink via sink.write() are immediately forwarded to the source, where they flow downstream through the source's piped sink chain. If the source has no sink yet or is paused, values are buffered internally and flushed when a sink is piped or the source resumes. The sink.end() method signals the source to end, and sink.abort() rolls up through the source chain.

API

pair()

Creates a connected source-sink pair.

  • Returns { source, sink }
    • source – A source stream with pipe(), resume(), and abort() methods.
    • sink – A sink with write(data), end(err?), and abort(err?) methods, plus a source property referencing the source.

Tests

npm test

Tests cover write-then-pipe ordering, end propagation, error forwarding on end(err), abort handling, and backpressure buffering.

Requirements

Node.js 18 or later. ESM only.

License

MIT

Dependencies

Dependencies

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

Development Dependencies

ID Version
fast-check ^3.0.0

Keywords

push-stream stream pair
Details
npm
2026-07-19 21:15:44 +00:00
0
MIT
3.5 KiB
Assets (1)
Versions (6) View all
0.0.9 2026-07-21
0.0.8 2026-07-20
0.0.7 2026-07-20
0.0.6 2026-07-19
0.0.4 2026-07-19