Hacker News new | ask | show | jobs
by alexfarran 4832 days ago
You can use a trampoline like the one the author has written in this library https://github.com/fogus/lemonad/blob/master/lib/lemonad.js#...

Basically you rewrite your recursive functions so that instead of calling another function they return a parameterless closure. Then you can iteratively call your first function, and the function it returns, and the function it returns etc until the return value is not a function.

1 comments

or rather than creating an iterator yourself, use setTimeout(..., 0) to put the next call on the event loop.
I talk about that too. :-)