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 ...

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.