throttlr
v0.0.1
Published
Buffer and execute tasks at defined time interval.
Downloads
2
Readme
Throttlr
installing
npm i -S throttlr
What it is
Buffer and execute tasks at defined time interval.
const throttlr = require('throttlr')
const t = throttlr(5000)
t(() => console.log('Executed directly'))
t(() => console.log('Will be executed in 5s'))
t(() => console.log('Will be executed in 10s'))
It can be used a simple API rate control mechanism.
const request = require('request')
const throttlr = require('throttlr')
const jobs = getAllJobsToSend()
const t = throttlr(5000)
jobs.forEach(job => {
t(() => request.post('/myUri', job))
})
In the above example, all jobs will be sent at 5s interval.
License
MIT