GithubHelp home page GithubHelp logo

fearphage / ordered-read-streams Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gulpjs/ordered-read-streams

0.0 2.0 0.0 26 KB

Combines array of streams into one read stream in strict order

License: MIT License

JavaScript 100.00%

ordered-read-streams's Introduction

ordered-read-streams NPM version Build Status

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

Installation

npm install ordered-read-streams

Overview

ordered-read-streams handles all data/errors from input streams in parallel, but emits data/errors in strict order in which streams are passed to constructor. This is objectMode = true stream.

Example

var through = require('through2');
var Ordered = require('ordered-read-streams');

var s1 = through.obj(function (data, enc, next) {
  var self = this;
  setTimeout(function () {
    self.push(data);
    next();
  }, 200)
});
var s2 = through.obj(function (data, enc, next) {
  var self = this;
  setTimeout(function () {
    self.push(data);
    next();
  }, 30)
});
var s3 = through.obj(function (data, enc, next) {
  var self = this;
  setTimeout(function () {
    self.push(data);
    next();
  }, 100)
});

var streams = new Ordered([s1, s2, s3]);
streams.on('data', function (data) {
  console.log(data);
})

s1.write('stream 1');
s1.end();

s2.write('stream 2');
s2.end();

s3.write('stream 3');
s3.end();

Ouput will be:

stream 1
stream 2
stream 3

Licence

MIT

ordered-read-streams's People

Contributors

armed avatar phated avatar shinnn avatar tomchentw avatar piranna avatar ustccjw avatar

Watchers

Phred Lane avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.