JSPM

pull-backoff

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q16977F
  • License MIT

pull-stream source for exponential backoff intervals

Package Exports

  • pull-backoff

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-backoff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pull-backoff

npm install --save pull-backoff

Creates 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
                                                    6s

Arguments:

  • interval: initial interval of time expressed in milliseconds
  • factor: (optional, default 2) how much to multiply the previous interval each time the stream emits
  • maximum: (optional, default Infinity) 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
> 4

License

MIT