node-backoff

1.0.2 • Public • Published

node-backoff

Simple backoff in node.js

Install

$ npm i node-backoff --save
 

Options

  • min min timeout in milliseconds, defaut:100
  • max max timeout in milliseconds, default:10000
  • factor every call to duration() it is multiplied by factor, default:2
  • jitter randomization to the backoff durations,default:false

Using

 const Backoff = require('node-backoff');
 
 let backoff = new Backoff();
 let d1 = backoff.duration();//100ms
 let d2 = backoff.duration();//200ms
 let d3 = backoff.duration();//400ms
 let d4 = backoff.duration();//800ms
 
 //or forAttempt()
 let t1 = backoff.forAttempt(2);//400ms
 
 backoff.reset();// reset attempts

Readme

Keywords

Package Sidebar

Install

npm i node-backoff

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

4.84 kB

Total Files

5

Last publish

Collaborators

  • feiin