Socket
Book a DemoInstallSign in
Socket

queued-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

queued-stream

Queue up multiple readable streams to stream as single output stream

0.1.3
latest
Source
npmnpm
Version published
Weekly downloads
6
500%
Maintainers
1
Weekly downloads
 
Created
Source

node-queued-stream

This transform stream will switch from one queued input stream to the next to provide a continuous output stream. The output stream will only end once a maximum output byte length has been reached or when explicitly ended. This allows for input streams to be queued after this stream has been piped, after output has started or even after all the previously queued up streams have completed.

Installation

npm install queued-stream

Usage

var QueuedStream = require('queued-stream');
var fs = require('fs');

var queuedStream = new QueuedStream({ maxBytes: 20000 });

queuedStream.pipe(fs.createWriteStream('combined.txt'));

// Add input streams when ready
combinedStream.append(fs.createReadStream('file1.txt'))

// Add more input streams later
setTimeout(function(){
  queuedStream.append(fs.createReadStream('file2.txt'));
}, 1000);

To end after all items in the queue had been processed, just append an empty value to the queued stream.

queuedStream.append(fs.createReadStream('file3.txt')).append(null);

API

QueuedStream([options])

  • maxBytes ends the output stream after so many bytes have been output (discards the rest)

queuedStream.append(stream, [expectedBytes])

Should read from this stream next. It will switch to the next stream in the queue after expectedBytes have been read, or if this stream has ended.

If stream is null, output will end.

queuedStream.destroy()

Immediately unpipes from active stream, where active, and ends the output stream.

Keywords

queue

FAQs

Package last updated on 23 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.