Array.prototype.asyncEach = function (each, done) {
var i = -1, a = this
function iter() {
if (++i === a.length) { done && done(); return }
each.call(a, a[i], iter)
}
iter()
}
// Example
(new Array(10)).asyncEach(function (item, next) {
setTimeout(function () {
console.log("tick")
next()
}, 1000)
})