Created
June 4, 2020 06:58
-
-
Save velotiotech/8da7d51c55209f1b8f56b808cbd1b19d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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