Created
January 10, 2013 22:14
-
-
Save dgershman/4506266 to your computer and use it in GitHub Desktop.
async example forEach
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
var async = require('async'); | |
var obj = [ "apple", "banana", "orange", "pineapple", "kiwi", "watermelon", "grape" ]; | |
function getObj(i, callback) { | |
setTimeout(function() { | |
console.log(i) | |
callback(null); | |
}, 2000); | |
} | |
/*for (var i = 0; i < obj.length; i++) { | |
getObj(i, function(data) { | |
console.log(data); | |
}); | |
}*/ | |
async.forEach(obj, getObj, function(err) { | |
console.log("done"); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment