Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 4, 2020 06:58
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 velotiotech/8da7d51c55209f1b8f56b808cbd1b19d to your computer and use it in GitHub Desktop.
Save velotiotech/8da7d51c55209f1b8f56b808cbd1b19d to your computer and use it in GitHub Desktop.
async.race([
function (callback) {
setTimeout(function () {
callback(null, 'one');
}, 300);
},
function (callback) {
setTimeout(function () {
callback(null, 'two');
}, 100);
},
function (callback) {
setTimeout(function () {
callback(null, 'three');
}, 200);
}
],
// main callback
function (err, result) {
// the result will be equal to 'two' as it finishes earlier than the other 2
console.log('The result is ', result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment