Node-Fibers

While the other projects I’ve listed here merely compile to plain JavaScript, node-fibers actually extends the language understood by the Node runtime by adding threadlike constructs called fibers (http://en.wikipedia.org/wiki/Fiber_(computer_science)). A fiber can yield to other fibers, suspending its own execution until an event causes it run again.

​ 
​var​ fiber = Fiber.current;
​ 
console.log(​'Yielding until the timeout elapses...'​)
​ 
setTimeout(​function​() {
​ 
fiber.run();
​ 
}, 1000);
​ 
Fiber.yield();
​ 
console.log(​'...1 second later'​);

The main advantage of node-fibers over JavaScript precompilers is debugging. The line numbers in node-fiber stack traces correspond to the line numbers ...

Get Async JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.