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 in node-fiber source code, and thrown exceptions can be caught even when a fiber yields within a try/catch block.
3.149.242.9