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.

相关文章:

  • 2021-10-18
  • 2022-12-23
  • 2021-10-30
  • 2021-05-19
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-03-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-06
  • 2022-01-24
相关资源
相似解决方案