I would expect this code to print 0 2 4 6 8 and then terminate. Instead it prints 0 2 4 6 8 and then uses all cpu indefinitely. Am I using it wrong?
function* nums() {
let i = 0;
while (true) {
yield i++;
}
}
let res = seq(nums(), compose(map(x => x * 2), take(5)));
for (let x of res) {
console.log(x);
}
If I instead use res = into([], compose(map(x => x * 2), take(5)), nums());
It terminates as expected.
I would expect this code to print 0 2 4 6 8 and then terminate. Instead it prints 0 2 4 6 8 and then uses all cpu indefinitely. Am I using it wrong?
If I instead use
res = into([], compose(map(x => x * 2), take(5)), nums());
It terminates as expected.