asynccbn
v0.0.3
Published
ES7 Async to callback (node style)
Downloads
4
Maintainers
Readme
asynccbn
Babel Plugin to transpile EcmaScript7 async function transpiled into callbacks.
still working, carefull in production enviroments
Why
Promises and generators need more memory and are slower then callbacks.
install
npm install asynccbn
usage
Use it as a babeljs plugin
sample 1: defining an async function
input:
async function divide(a,b)
{
return a/b;
}
output:
function divide(a, b, callback) {
callback(null, a / b);
}
sample 2: invoking async function
input:
async function fn() {
return await divide(8,2) + await divide(10,2);
}
output:
divide(8, 2, function(err$, res$1) {
if (err$) return callback(err$);
divide(10, 2, function(err$, res$2) {
if (err$) return callback(err$);
callback(null, res$1+res$2);
});
});