1.0.0 • Published 6 years ago
pull-backoff v1.0.0
pull-backoff
npm install --save pull-backoffCreates a pull-stream that emits numbers in exponential backoff periods of time.
Description
Periodically deliver incremental numbers, where the interval of time varies exponentially, up to an (optional) maximum interval of time.
Marble diagram:
backoff(500, 2, 6000)
-0---1-------2---------------3-----------------------4----...
intervals:
500ms
1s
2s
4s
6sArguments:
interval: initial interval of time expressed in millisecondsfactor: (optional, default2) how much to multiply the previousintervaleach time the stream emitsmaximum: (optional, defaultInfinity) the maximum interval at which to limit the interval calculation
Usage
const pull = require('pull-stream')
const backoff = require('pull-backoff')
pull(
backoff(500, 2, 6000),
pull.take(5),
pull.drain(i => console.log(i))
)> 0
> 1
> 2
> 3
> 4License
MIT
1.0.0
6 years ago