Huge news!Announcing our $20M Series A led by Andreessen Horowitz.Learn more
Socket
Socket
Log inDemoInstall

ordered-read-streams

Package Overview
Dependencies
3
Maintainers
2
Versions
14
Issues
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

ordered-read-streams

Combines array of streams into one Readable stream in strict order.

    2.0.0latest
    GitHub
    npm

Version published
Maintainers
2
Weekly downloads
2,247,877
increased by15.59%

Weekly downloads

Changelog

Source

2.0.0 (2022-10-10)

⚠ BREAKING CHANGES

  • Avoid eagerly reading streams
  • Destroy all streams correctly when another is destroyed
  • Switch to streamx (#27)
  • Normalize repository, dropping node <10.13 support (#25)

Features

  • Avoid eagerly reading streams (edb9aa1)
  • Ensure readable does not end until read from (87c871c)
  • Provide addSource function on the OrderedReadable stream (#28) (87c871c)
  • Switch to streamx (#27) (edb9aa1)

Bug Fixes

  • Destroy all streams correctly when another is destroyed (edb9aa1)

Miscellaneous Chores

  • Normalize repository, dropping node <10.13 support (#25) (f6e5671)

Readme

Source

ordered-read-streams

NPM version Downloads Build Status Coveralls Status

Combines array of streams into one Readable stream in strict order.

Usage

var { Readable } = require('streamx');
var ordered = require('ordered-read-streams');

var s1 = new Readable({
  read: function (cb) {
    var self = this;
    if (self.called) {
      self.push(null);
      return cb(null);
    }
    setTimeout(function () {
      self.called = true;
      self.push('stream 1');
      cb(null);
    }, 200);
  },
});
var s2 = new Readable({
  read: function (cb) {
    var self = this;
    if (self.called) {
      self.push(null);
      return cb(null);
    }
    setTimeout(function () {
      self.called = true;
      self.push('stream 2');
      cb(null);
    }, 30);
  },
});
var s3 = new Readable({
  read: function (cb) {
    var self = this;
    if (self.called) {
      self.push(null);
      return cb(null);
    }
    setTimeout(function () {
      self.called = true;
      self.push('stream 3');
      cb(null);
    }, 100);
  },
});

var readable = ordered([s1, s2, s3]);
readable.on('data', function (data) {
  console.log(data);
  // Logs:
  // stream 1
  // stream 2
  // stream 3
});

API

ordered(streams, [options])

Takes an array of Readable streams and produces a single OrderedReadable stream that will consume the provided streams in strict order. The produced Readable stream respects backpressure on itself and any provided streams.

orderedReadable.addSource(stream)

The returned Readable stream has an addSource instance function that takes appends a Readable stream to the list of source streams that the OrderedReadable is reading from.

License

MIT

Keywords

FAQs

Last updated on 10 Oct 2022

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install
SocketSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc