promisen.js
function parallel(tasks) {
    if (tasks == null) return promisen([]);
    tasks = Array.prototype.map.call(tasks, wrap);
    return all;

    function all(value) {
      var boundTasks = Array.prototype.map.call(tasks, run.bind(this, value));
      return promisen.Promise.all(boundTasks);
    }

    // apply the first argument only. ignore rest.
    function wrap(task) {
      return promisen(task);
    }

    function run(value, func) {
      return func.call(this, value);
    }
  }
function parallel(tasks) {
    if (tasks == null) return promisen([]);
    tasks = Array.prototype.map.call(tasks, wrap);
    return all;

    function all(value) {
      var boundTasks = Array.prototype.map.call(tasks, run.bind(this, value));
      return promisen.Promise.all(boundTasks);
    }

    // apply the first argument only. ignore rest.
    function wrap(task) {
      return promisen(task);
    }

    function run(value, func) {
      return func.call(this, value);
    }
  }
function parallel ( tasks ) { if ( tasks == null ) return promisen ( [ ] ) ; tasks = Array . prototype . map . call ( tasks , wrap ) ; return all ; function all ( value ) { var boundTasks = Array . prototype . map . call ( tasks , run . bind ( this , value ) ) ; return promisen . Promise . all ( boundTasks ) ; } // apply the first argument only. ignore rest. function wrap ( task ) { return promisen ( task ) ; } function run ( value , func ) { return func . call ( this , value ) ; } }
creates a promise-returning function which runs multiple tasks in parallel.

@class promisen
@static
@function parallel
@param tasks {Array|Array-like} list of tasks
@returns {Function} promise-returning function
@example
var promisen = require("promisen");

// generate a promise-returning function
var task = promisen.parallel([task1, task2, task3,...]);

// execute it
task(value).then(function(array) {...}); // array of results

// execute it with target object which is passed to every tasks
task.call(target, value).then(function(result) {...});
creates a promise - returning function which runs multiple tasks in parallel .