Fast stream piped to slow stream seems to be ending early
const bluestream = require('bluestream')
let begin = 0
let end = 100
const idStream = bluestream.read(async function () {
if (begin < end) {
begin++
this.push(begin)
} else {
return null
}
})
const articleStream = bluestream.transform({ concurrent: 20 }, function (id) {
return new Promise((resolve) => {
setTimeout(() => {
console.log('resolved', id)
resolve(id)
}, 100)
})
})
bluestream.pipe(idStream, articleStream).then(console.log, console.log)
setTimeout(() => console.log('Done!'), 10000)
Try adjusting concurrent and also the setTImeout length and you'll get different results. In any case I can't get all 100 numbers to print. It always ends early.
Fast stream piped to slow stream seems to be ending early
Try adjusting
concurrent
and also thesetTImeout
length and you'll get different results. In any case I can't get all 100 numbers to print. It always ends early.