Skip to content

Instantly share code, notes, and snippets.

@niinpatel
Last active June 9, 2018 20:11
Show Gist options
  • Save niinpatel/cbf9114e84661562d0202a9a3da0f026 to your computer and use it in GitHub Desktop.
Save niinpatel/cbf9114e84661562d0202a9a3da0f026 to your computer and use it in GitHub Desktop.
Asynchronous Map Function
/**
* 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