min-delay

1.0.1 • Public • Published

min-delay

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status Donate

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.

Package Sidebar

Install

npm i min-delay

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • kikobeats