to-stream
v0.0.2
Published
Turn an array to a Node.js stream
Downloads
15
Readme
to-stream
Turn an array to a Node.js stream.
The array can contains
Promise
,Generator
andGeneratorFunction
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)