B2G/gecko/browser/devtools/scratchpad/test/browser_scratchpad_restore.js
/* Call the iterator for each item in the list,
   calling the final callback with all the results
   after every iterator call has sent its result */
Call the iterator for each item in the list,
calling the final callback with all the results
after every iterator call has sent its result
Call the iterator for each item in the list calling the final callback with all the results after every iterator call has sent its result
function asyncMap(items, iterator, callback)
{
  let expected = items.length;
  let results = [];
  items.forEach(function(item) {
    iterator(item, function(result) {
      results.push(result);
      if (results.length == expected) {
        callback(results);
      }
    });
  });
}
function asyncMap ( items , iterator , callback ) { let expected = items . length ; let results = [ ] ; items . forEach ( function ( item ) { iterator ( item , function ( result ) { results . push ( result ) ; if ( results . length == expected ) { callback ( results ) ; } } ) ; } ) ; }
Call the iterator for each item in the list,
calling the final callback with all the results
after every iterator call has sent its result
Call the iterator for each item in the list calling the final callback with all the results after every iterator call has sent its result