@push-stream-std/push-pair (0.0.6)
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.6"@push-stream-std/push-pair": "0.0.6"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 withpipe(),resume(), andabort()methods.sink– A sink withwrite(data),end(err?), andabort(err?)methods, plus asourceproperty 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 |