min-delay
v1.0.1
Published
Wait a minimum quantity of time between consecutive callbacks.
Downloads
1
Maintainers
Readme
min-delay
Wait a minimum quantity of time between consecutive callbacks.
Install
$ npm install min-delay --save
Usage
const minDelay = require('min-delay')
const get = require('simple-get')
const delay = minDelay(1000)
const fn = get.concat.bind(get, 'https://kikobeats.com', callback)
function callback (err, res, data) {
// If the request take more than 1000ms, then the callback is returned
// otherwise we wait the time until 1000ms
// For example, if the request take 100ms, we wait 900ms until
// return the callback.
if (err) throw err
console.log(data)
}
delay(fn)
API
minDelay(delay)
input
Required
Type: Number
Quantity of time to wait before return the callback.
License
MIT © Kiko Beats.