1.1.3 • Published 9 years ago

orderable v1.1.3

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

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

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago