1.0.1 • Published 7 years ago

min-delay v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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.