Last active
June 9, 2018 20:11
-
-
Save niinpatel/cbf9114e84661562d0202a9a3da0f026 to your computer and use it in GitHub Desktop.
Asynchronous Map Function
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
/** | |
* Asynchronous Map Function via async module | |
*/ | |
const Async = require('async'); | |
Async.map([1,2,3], double, (err, results) => { | |
if(err) console.log(err); | |
console.log(results) | |
} ); | |
async function double(num) { | |
if(isNaN(num)) | |
return await new Error('argument is not a number'); | |
else | |
return await num * 2; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment