promisen.js
function WHILE(condTask, runTask) {
    var runTasks = Array.prototype.slice.call(arguments, 1);
    runTasks.push(nextTask);
    runTask = waterfall(runTasks);
    var whileTask = IF(condTask, runTask);
    return whileTask;

    function nextTask(value) {
      return whileTask.call(this, value);
    }
  }
function WHILE(condTask, runTask) {
    var runTasks = Array.prototype.slice.call(arguments, 1);
    runTasks.push(nextTask);
    runTask = waterfall(runTasks);
    var whileTask = IF(condTask, runTask);
    return whileTask;

    function nextTask(value) {
      return whileTask.call(this, value);
    }
  }
function WHILE ( condTask , runTask ) { var runTasks = Array . prototype . slice . call ( arguments , 1 ) ; runTasks . push ( nextTask ) ; runTask = waterfall ( runTasks ) ; var whileTask = IF ( condTask , runTask ) ; return whileTask ; function nextTask ( value ) { return whileTask . call ( this , value ) ; } }
creates a promise-returning function which runs a task repeatedly while the condition is true.

When null or undefined is given as condTask, it will do nothing for value and just passes it.

@class promisen
@static
@function while
@param condTask {Boolean|Function|Promise|thenable|*|null} boolean or function returns boolean
@param runTask {...(Function|Promise|thenable|*)} task runs while true
@returns {Function} promise-returning function
@example
var promisen = require("promisen");

// counter = 8; while (--counter) { runTask }
var counter = promisen.number(8);
var whileTask = promisen.while(counter.decr, runTask);

// for (initTask; condTask; afterTask) { runTask }
var forTask = promisen(initTask, promisen.while(condTask, runTask, afterTask));

// do { runTask } while (condTask)
var doWhileTask = promisen.while(null, runTask, condTask));
creates a promise - returning function which runs a task repeatedly while the condition is true .