Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
async each for an array
* for each item in the array, call a function, but only after the previous has called the callback.
function consecutive (list, task) {
var count = 0;
function step() {
var item = list[count];
if(typeof item === 'undefined') {
// console.log('this istem is undefined');
response = task(item, step);
* usage
consecutive([5,8,4,6,5,7], function(item, cb){
$.get( "ajax/test.php?amount="+item, function( data ) {
console.log( "Load was performed.", data );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment