npm.io
0.0.2 • Published 12 years ago

to-stream

Licence
MIT
Version
0.0.2
Deps
1
Vulns
0
Weekly
0

to-stream

Build Status

Turn an array to a Node.js stream.

The array can contains Promise, Generator and GeneratorFunction

Install

$ npm install --save to-stream

Example

var Promise = require('promise');
var toStream = require('to-stream');

var promise = new Promise(function (resolve, reject) {
  setTimeout(function () {
    resolve('b');
  });
});

var gen = function *() {
  yield 'c';
  yield 'd';
};

toStream(['a', null, promise, gen])
  .on('data', function (data) {
    if (toStream.isNull(data)) {
      console.log('null');
    } else {
      console.log(data);
    }
  });

API

toStream(Array)
toStream(Generator)
toStream(GeneratorFunction)
toStream.isNull()
toStream.isUndefined()

License

The MIT License (MIT)

http://poying.mit-license.org/

Keywords