Socket
Book a DemoInstallSign in
Socket

orderable

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orderable

Readable stream to which you can push chunks at an index

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

orderable

A readable stream to which you can in random order push chunks or sub-streams with an index, and they will be emitted by index ascending.

build status

Example

var Orderable = require('orderable');

var o = Orderable();

setTimeout(function(){
  o.set(0, 'foo\n');
}, Math.random() * 1000);

setTimeout(function(){
  o.set(1, createStringStream(['b', 'a', 'r', '\n']));
}, Math.random() * 1000);

setTimeout(function(){
  o.set(2, 'baz\n');
  o.set(3, null);
}, Math.random() * 1000);

o.pipe(process.stdout);

Always outputs:

$ node example.js
foo
bar
baz
$

Installation

$ npm install orderable

API

Orderable()

Create an orderable stream.

Orderable#set(index, chunk)

Push chunk onto the internal buffer at index. Pass chunk=null to mark the end of a stream. You can pass readable streams as well.

You can also do this at the beginning, like:

o.set(3, null);
o.set(0, 'foo');
o.set(1, 'bar');
o.set(2, 'baz');

License

MIT

FAQs

Package last updated on 01 Dec 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