lib/core/qutil.js
function map_p(collection, func_p) {
  if (collection.length === 0)
    return Q.resolve([]);

  var results = [];

  var lastFunc = Q.resolve(true);

  _.each(collection, function(el, index) {
    lastFunc = lastFunc.then(function() {
      return func_p(collection[index])
      .then(function(result) {
	results[index] = result;
	return results;
      });
    });
  });

  return lastFunc;
}
function map_p(collection, func_p) {
  if (collection.length === 0)
    return Q.resolve([]);

  var results = [];

  var lastFunc = Q.resolve(true);

  _.each(collection, function(el, index) {
    lastFunc = lastFunc.then(function() {
      return func_p(collection[index])
      .then(function(result) {
	results[index] = result;
	return results;
      });
    });
  });

  return lastFunc;
}
function map_p ( collection , func_p ) { if ( collection . length === 0 ) return Q . resolve ( [ ] ) ; var results = [ ] ; var lastFunc = Q . resolve ( true ) ; _ . each ( collection , function ( el , index ) { lastFunc = lastFunc . then ( function ( ) { return func_p ( collection [ index ] ) . then ( function ( result ) { results [ index ] = result ; return results ; } ) ; } ) ; } ) ; return lastFunc ; }
Pass in a collection and a promise-returning function, and map_p will
do a sequential map operation and resolve to the results.
Pass in a collection and a promise - returning function and map_p will do a sequential map operation and resolve to the results .