loopnext

0.0.3 • Public • Published

loopNext

Build Status

Run loops with async statements in a sync fashion. Did I tell you about nested sync loops? ;)

To use

  1. Install it:
```bash
$ npm i loopnext
```
  1. Require it and use:
```js
var LoopNext = require('loopnext');
var loop = new LoopNext();
loop.syncLoop(iterations, function (l) {
  // loop body
  // call `l.next()` for next iteration
});
```

Example

var LoopNext = require('loopnext');
 
var loop = new LoopNext();
var count = 0;
loop.syncLoop(4, function (l) {
  setTimeout(function () {
    console.log(count);
    count++;
    l.next();
  }, 3000);
});
// 0
// 1
// 2
// 3

License

MIT © 2015 Sunny (darkowlzz)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    2
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i loopnext

Weekly Downloads

2

Version

0.0.3

License

MIT

Last publish

Collaborators

  • darkowlzz