O'Reilly logo

Async JavaScript by Trevor Burnham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Streamline.js

Like Kaffeine, Streamline.js[65] provides a special syntax for transforming the code after an async function call into its callback. Just use _ in place of the callback argument.

 
for​ (​var​ s = 1; s < 60; s++) {
 
setTimeout(_, 1000);
 
console.log(s + ​' seconds have elapsed'​);
 
}
 
console.log(​'1 minute has elapsed'​);

Interestingly, Streamline can generate either standard callback-driven JavaScript or fiber-based code for node-fibers (see the next section). Also, unlike most other JavaScript precompilers, Streamline can be used in conjunction with CoffeeScript.

Note that Streamline expects callbacks to follow the Node-style argument list convention (err, results...), which eases error handling in Node but makes it difficult ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required