co
co copied to clipboard
Add streams into yieldable list
Hi, I think it will be nice to be able yielding the streams (it will be waiting the stream "end" event) as well.
@andreytkachenko Can you elaborate more ?
Current yieldable list are:
- promises
- thunks (functions)
- array (parallel execution)
- objects (parallel execution)
- generators (delegation)
- generator functions (delegation) I am suggesting add streams in that list as well. It is possible to promisify stream like that:
const promisify = (readable) => {
const result = []
const w = new Writable({
write(chunk, encoding, callback) {·
result.push(chunk)
callback()
}
})
readable.pipe(w)
return new Promise((resolve, reject) => {
w.on('finish', resolve)
w.on('error', reject)
}).then(() => result.join(''))
}
and then yield them, but it would be great to just yield them