Last active
August 29, 2015 14:01
-
-
Save goonoo/b1889e21e08e534e1afe to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = { | |
map: function (arr, iterator, callback) { | |
throw "IMPLEMENT ME PLZ" | |
}, | |
mapSeries: function (arr, iterator, callback) { | |
throw "IMPLEMENT ME PLZ" | |
} | |
}; | |
var test_arr = [1,2,3,4,5,6,7,8,9,0]; | |
var test_iterator = function (item, callback) { | |
setTimeout(function () { | |
console.log(item); | |
callback(null, item); | |
}, Math.random() * 999); | |
}; | |
var test_callback = function (err, result) { | |
console.log(result); | |
}; | |
async.map(test_arr, test_iterator, test_callback); | |
// RESULT may be... | |
// 3 | |
// 1 | |
// ... | |
// 7 <- random number from 0 to 9 | |
// [1,2,3,4,5,6,7,8,9,0] <- final result | |
setTimeout(function () { | |
async.mapSeries(test_arr, test_iterator, test_callback); | |
// RESULT may be... | |
// 1 | |
// 2 | |
// ... | |
// 0 <- in order to test_arr | |
// [1,2,3,4,5,6,7,8,9,0] <- final result | |
}, 1200); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment