@push-stream-std/push-cont (0.0.3)
Published 2026-07-19 21:14:06 +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-cont@0.0.3"@push-stream-std/push-cont": "0.0.3"About this package
push-cont
Continuation-passing style source creation for push-streams.
Published as @push-stream-std/push-cont.
Synopsis
import { cont } from '@push-stream-std/push-cont';
import { collect } from '@push-stream-std/push-collect';
const lazy = cont((cb) => {
setTimeout(() => {
cb(null, { pipe: (sink) => { sink.write(1); sink.write(2); sink.end(); } });
}, 100);
});
collect(lazy, (err, values) => {
console.log(values); // [1, 2]
});
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-cont
Description
Creates a push-stream source that defers stream creation until it is piped to a sink. The callback receives (err, resultSource) in continuation-passing style, making it ideal for async initialization, conditional stream selection, or lazy resource allocation.
API
cont(cb)
Returns a push-stream source that invokes cb when piped.
- cb
(callback) => void— A function that receives a node-style callback(err, source). When piped,cbis invoked with this callback to resolve the actual source stream. - Returns
source— A push-stream source. All operations (pipe, resume, abort) are buffered until the callback resolves with the actual stream. If the callback returns an error, the pending sink is ended with that error.
Tests
npm test
Tests cover sync and async resolution, error handling, abort propagation, and double-pipe prevention.
Requirements
Node.js 18 or later. ESM only.
License
MIT
Dependencies
Dependencies
| ID | Version |
|---|---|
| push-stream-base | file:../push-stream-base |
Development Dependencies
| ID | Version |
|---|---|
| fast-check | ^4.5.3 |
Keywords
push-stream
stream
continuation
Details
Assets (1)
Versions (6)
View all
push-cont-0.0.3.tgz
3.2 KiB