git ssb

3+

cel / ssb-npm-registry



Tree: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3

Files: d2f2697f296dd39aed6a8b63c6d04a736a7db5b3 / node_modules / looper / README.md

808 bytesRaw

looper

Loop with callbacks but don't RangeError

travis

testling

Synopsis

Normally, if mightBeAsync calls it's cb immediately this would RangeError:

var l = 100000
;(function next () {
  if(--l) mightBeAsync(next)
})

looper detects that case, and falls back to a while loop,

Example

var loop = require('looper')

var l = 100000
loop(function () {
  var next = this
  if(--l) probablySync(next)
})()

when you want to stop looping, don't call next. looper checks if each callback is sync or not, so you can even mix sync and async calls!

License

MIT

Built with git-ssb-web