promisen.js
function eachSeries(arrayTask, iteratorTask) {
    if (arrayTask == null) arrayTask = promisen();
    iteratorTask = promisen(iteratorTask);
    return waterfall([arrayTask, loopTask]);

    // composite multiple tasks
    function loopTask(arrayResults) {
      arrayResults = Array.prototype.map.call(arrayResults, wrap);
      return series(arrayResults).call(this);
    }

    function wrap(value) {
      return iterator;
      function iterator() {
        return iteratorTask.call(this, value);
      }
    }
  }
function eachSeries(arrayTask, iteratorTask) {
    if (arrayTask == null) arrayTask = promisen();
    iteratorTask = promisen(iteratorTask);
    return waterfall([arrayTask, loopTask]);

    // composite multiple tasks
    function loopTask(arrayResults) {
      arrayResults = Array.prototype.map.call(arrayResults, wrap);
      return series(arrayResults).call(this);
    }

    function wrap(value) {
      return iterator;
      function iterator() {
        return iteratorTask.call(this, value);
      }
    }
  }
function eachSeries ( arrayTask , iteratorTask ) { if ( arrayTask == null ) arrayTask = promisen ( ) ; iteratorTask = promisen ( iteratorTask ) ; return waterfall ( [ arrayTask , loopTask ] ) ; // composite multiple tasks function loopTask ( arrayResults ) { arrayResults = Array . prototype . map . call ( arrayResults , wrap ) ; return series ( arrayResults ) . call ( this ) ; } function wrap ( value ) { return iterator ; function iterator ( ) { return iteratorTask . call ( this , value ) ; } } }
creates a promise-returning function which runs task repeatedly for each value of array in order.

@class promisen
@static
@function eachSeries
@param arrayTask {Array|Function|Promise|thenable} array or task returns array for iteration
@param iteratorTask {Function} task runs repeatedly for each of array values
@returns {Function} promise-returning function
@example
var promisen = require("promisen");

var task = promisen.eachSeries([1, 2, 3], mul2);

task.call(target).then(function(array) {...}); // => [2, 4, 6]

function mul2(value) {
return value * 2;
}
creates a promise - returning function which runs task repeatedly for each value of array in order .