Aw shucks, I thought that would fix it. For the last part, though, what I meant was (sorry, I had just woken up lol):
function loop(n) {
return signal(n).then(i => {
if (i % 1000 == 0) console.log(i)
setTimeout(loop, 0, n + 1)
})
}
Or maybe even
function loop(n) {
return signal(n).then(i => {
if (i % 1000 == 0) console.log(i)
loop(n + 1)
})
}
You can still sequence and aggregate the results without explicitly chaining the Promise object. I believe that libraries like bluebird do have this same flapMap optimization you’ve created, though (but I’ve started to prefer native for less dependencies).
I have not tried Bluebird, maybe it does it because the problem and the solution are pretty obvious, which is why I was surprised to see that the standard Promise doesn't do it.
5
u/1-800-BICYCLE Oct 11 '17
Aw shucks, I thought that would fix it. For the last part, though, what I meant was (sorry, I had just woken up lol):
Or maybe even
You can still sequence and aggregate the results without explicitly chaining the Promise object. I believe that libraries like bluebird do have this same flapMap optimization you’ve created, though (but I’ve started to prefer native for less dependencies).