for ( ; ; ) loop for long async tasks
npm install forloopforloop
=======
Node.js non-blocking for ( ; ; ) loop for long running tasks.


This library tackles the use case where CPU-intensive code block is executed repetitively inside a loop.
$ npm install forloop
`Usage
###forloop(initialization, limit, increment, iterationCallback, finalCallback)
__Arguments__
*
initialization - Initial value for the counter variable.
* limit - The final value of the counter to break the loop.
* increment - The value to increment the counter variable.
* iterationCallback(i) - A function to call on each itertation of the loop.
The current value of the counter variable is passed as the argument.
* finalCallback() - A function, which is called when the loop exits.Example
Calculating Golden Ratio$3
`js
var count = 10000000;
var φ = 0;for (var i = 0; i < count; i++) {
φ = Math.sqrt(φ + Math.sqrt(1));
}
console.log("φ ≈ %d", φ);
`$3
`js
var forloop = require('forloop');
var count = 10000000;
var φ = 0;forloop(0, count, 1,
function(i) {
φ = Math.sqrt(φ + Math.sqrt(1));
},
function() {
console.log("φ ≈ %d", φ);
}
);
``$ npm test