-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
var arr = [];
for (var i=0; i<=100000; i++) { arr.push(i) }
zo(arr).reduce(0, function(memo, item, into) {
into(memo + item);
}).results(function(sum) {
console.log("Sum", sum);
});
This will now blow the call stack, since reduce is recursive.
fwiw, I was looking at zo (which I hadn't seen before), because I was writing my own functional async library, and ran into the above problem. I just figured it out -- thanks to mikegerwitz on irc. If you use process.nextTick, you won't exhaust the call stack.
So, in your foldl, do:
process.nextTick(function() {
xyz(folded, index + 1, items, next);
})
Cheers
Metadata
Metadata
Assignees
Labels
No labels