nodejs while-loop

node-while-loop 

A while loop alternative for Nodejs based on promises.

Install

$ npm install --save node-while-loop

  

Usage

var loop = require('node-while-loop');
 
var i = 1;
loop.while(function () {
    return i * i < 10;
}, function () {
    console.log(i);
    i++;
});
console.log('Hello Node!');
 
/* Output
Hello Node!
*/

  

API

while(condition, action)

condition function refers to a bool returning function which when returns false, breaks the loop.

action function refers to the task which needs to be iteratively performed.

posted on 2017-06-20 16:18  清明-心若淡定  阅读(1113)  评论(0编辑  收藏  举报