Skip to content

Instantly share code, notes, and snippets.

@sibnerian
Created September 14, 2015 18:42
Show Gist options
  • Save sibnerian/7252aaac0aceb0aba1a4 to your computer and use it in GitHub Desktop.
Save sibnerian/7252aaac0aceb0aba1a4 to your computer and use it in GitHub Desktop.
var async = require('async');
var data = [
{timeout: 43, text: 'taco bell'},
{timeout: 26, text: 'twelve'},
{timeout: 340, text: 'kfC'}
];
var counter = 0;
var iterator = function (item, callback) {
setTimeout(function () {
var result = (++counter) + ': ' + item.text;
callback(null, result);
}, item.timeout);
};
async.map(data, iterator, function (err, results) {
console.log(err);
console.log(results);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment