1.0.2 • Published 5 years ago
the-jitter v1.0.2
the-jitter
Random delay timer
Installation
$ npm install the-jitter --save
Usage
'use strict'
const { TheJitter } = require('the-jitter')
async function tryExample () {
const jitter = new TheJitter({
maxCount: 100,
maxInterval: 1000,
})
async function doSomething (i) {
console.log('Method called', i)
const at = new Date()
await jitter.handle(async () => {
const took = new Date() - at
console.log(`Jitter delay=${at}ms`, i)
// called with some delay
/* ... */
})
console.log('Method Finished', i)
}
for (let i = 0; i < 1000; i++) {
void doSomething(i)
}
}
tryExample().catch((err) => console.error(err))
API Guide
License
This software is released under the MIT License.