Skip to content

Instantly share code, notes, and snippets.

@abuzarhamza
Created October 29, 2018 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abuzarhamza/03724d121f41bd410ba45a7bbbf97bff to your computer and use it in GitHub Desktop.
Save abuzarhamza/03724d121f41bd410ba45a7bbbf97bff to your computer and use it in GitHub Desktop.
async
let async = require('async');
async.autoInject({
a: test1.bind(null, 1),
b: test2.bind(null, 2),
c: ['b', (b , cb)=> {
test4.bind(null, 3)(cb);
}],
d: ['b', (b, cb)=> {
test4.call(null,3,cb)
}]
}, ()=> {
console.log('******************+++');
});
function test1(n, done) {
console.log('n1=?', n);
done();
}
function test2(n, done) {
setTimeout(() => {
console.log('n2', n);
done();
}, 2000);
}
function test4(n, done) {
setTimeout(() => {
console.log('n3', n);
//done();
}, 4000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment