lib/iterate.js
function iterate(list, iterator, state, callback)
{
  // store current index
  var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;

  state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
  {
    // don't repeat yourself
    // skip secondary callbacks
    if (!(key in state.jobs))
    {
      return;
    }

    // clean up jobs
    delete state.jobs[key];

    if (error)
    {
      // don't process rest of the results
      // stop still active jobs
      // and reset the list
      abort(state);
    }
    else
    {
      state.results[key] = output;
    }

    // return salvaged results
    callback(error, state.results);
  });
}
function iterate(list, iterator, state, callback)
{
  // store current index
  var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;

  state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
  {
    // don't repeat yourself
    // skip secondary callbacks
    if (!(key in state.jobs))
    {
      return;
    }

    // clean up jobs
    delete state.jobs[key];

    if (error)
    {
      // don't process rest of the results
      // stop still active jobs
      // and reset the list
      abort(state);
    }
    else
    {
      state.results[key] = output;
    }

    // return salvaged results
    callback(error, state.results);
  });
}
function iterate ( list , iterator , state , callback ) { // store current index var key = state [ 'keyedList' ] ? state [ 'keyedList' ] [ state . index ] : state . index ; state . jobs [ key ] = runJob ( iterator , key , list [ key ] , function ( error , output ) { // don't repeat yourself // skip secondary callbacks if ( ! ( key in state . jobs ) ) { return ; } // clean up jobs delete state . jobs [ key ] ; if ( error ) { // don't process rest of the results // stop still active jobs // and reset the list abort ( state ) ; } else { state . results [ key ] = output ; } // return salvaged results callback ( error , state . results ) ; } ) ; }
Iterates over each job object

@param {array|object} list - array or object (named list) to iterate over
@param {function} iterator - iterator to run
@param {object} state - current job status
@param {function} callback - invoked when all elements processed
Iterates over each job object