@push-stream-std/push-stream-to-stream (0.0.3)
Installation
@push-stream-std:registry=https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/npm install @push-stream-std/push-stream-to-stream@0.0.3"@push-stream-std/push-stream-to-stream": "0.0.3"About this package
push-stream-to-stream
Convert push-streams to and from Node.js streams.
Published as @push-stream-std/push-stream-to-stream.
Synopsis
import { readable, writable, duplex } from '@push-stream-std/push-stream-to-stream';
const nodeReadable = readable(pushSource);
nodeReadable.on('data', (chunk) => console.log('got', chunk));
nodeReadable.on('end', () => console.log('done'));
const nodeWritable = writable(pushSink);
nodeSource.pipe(nodeWritable);
const nodeDuplex = duplex(pushDuplex);
nodeReadable2.pipe(nodeDuplex).pipe(nodeWritable2);
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-stream-to-stream
Description
Bridges the gap between push-stream and Node.js's built-in Readable, Writable, and Duplex streams. readable adapts a push-stream source into a Node.js Readable in object mode. writable adapts a push-stream sink into a Node.js Writable. duplex adapts a push-stream duplex (with both source and sink properties) into a Node.js Duplex. All conversions use object mode with a default highWaterMark of 16 and propagate errors, abort, and end events bidirectionally.
API
readable(pushSource)
Converts a push-stream source to a Node.js Readable stream in object mode.
- pushSource
object– A push-stream source withpipe(),resume(),abort(). - Returns
stream.Readable– A Node.js readable stream. Backpressure is managed through the sink'spausedgetter/setter. If the source is already ended, the stream is ended or destroyed on the next tick.
writable(pushSink)
Converts a push-stream sink to a Node.js Writable stream in object mode.
- pushSink
object– A push-stream sink withwrite(),end(),abort(). - Returns
stream.Writable– A Node.js writable stream. On'finish', the sink'send()is called. If the sink is already ended, the stream is destroyed on the next tick.
duplex(pushDuplex)
Converts a push-stream duplex to a Node.js Duplex stream in object mode.
- pushDuplex
object– A push-stream duplex with.sourceand.sinkproperties. - Returns
stream.Duplex– A Node.js duplex stream. The readable side reads frompushDuplex.source; the writable side writes topushDuplex.sink. Aborts and errors are propagated bidirectionally to both source and sink abort handlers.
Tests
npm test
Requirements
Node.js 18 or later. ESM only.
License
MIT