1.0.0 • Published 4 years ago
promise-to-stream v1.0.0
Promise To Stream
A simple function that turns a promise to a readable stream, so every resolve is a push to the returned readable stream
Example
const PromiseToStream = require("promise-to-stream");
const promise = new Promise(resolve => {
resolve('a');
resolve('b');
resolve(null); // triger end
});
let data = '';
PromiseToStream(promise)
.on('data', chunk => {
data += chunk;
})
.on('end', () => {
console.log(data === 'ab'); // true
});
// You can use pipe as well.
1.0.0
4 years ago