1. stream-composer
Modern stream composer
stream-composer
Package: stream-composer
Created by: mafintosh
Last modified: Thu, 01 Jun 2023 00:23:21 GMT
Version: 1.0.2
License: MIT
Downloads: 795,806
Repository: https://github.com/mafintosh/stream-composer

Install

npm install stream-composer
yarn add stream-composer

stream-composer

Modern stream composer

npm install stream-composer

Supports composing and pipelining multiple streams into a single streamx stream.

Usage

 const Composer = require('stream-composer')

// Make a duplex stream out of a read and write stream
const stream = new Composer()

stream.setReadable(someReadableStream) // set readable side
stream.setWritable(someWritableStream) // set writable side

// reads, read from the readable stream
stream.on('data', function (data) {
  // data is from someReadableStream
})

// writes, write to the writable stream
stream.write(data)

API

stream = new Composer([options])

Make a new composer. Optionally pass the writable stream and readable stream in the constructor.
Options are forwarded to streamx.

stream.setReadable(readableStream)

Set the readable stream. If you pass null the readable stream will be set to an empty stream for you.

stream.setWritable(writableStream)

Set the writable stream. If you pass null the writable stream will be set to an empty stream for you.

stream.setPipeline(...pipelineStreams)

Set the stream to a pipeline. Writing to the outer stream writes to the first stream in the pipeline
and reading from the outer stream, reads from the last stream in the pipeline.

stream = Composer.pipeline(...pipelineStreams)

Helper for making a composer stream and setting the pipeline in one go.

stream = Composer.duplexer(writableStream, readableStream)

Helper for making a composer stream and setting the writable and readable stream in one go.

License

MIT

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code