1.0.0 • Published 6 years ago

function-throttler v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

throttle

generic throttling functions as a npm package

API

Table of Contents

limit

class for limiting the rate of function calls. Thanks to Pat Migliaccio. see https://medium.com/@pat_migliaccio/rate-limiting-throttling-consecutive-function-calls-with-queues-4c9de7106acc

Examples

let l = new limit(); let logMessageLimited = l.throttleAndQueue(msg => { console.log(msg); }, 500);

throttleAndQueue

Returns a version of your function that can be called at most every W milliseconds, where W is wait. Calls to your func that happen more often than W get queued up to be called every W ms

Parameters

  • fn
  • wait

throttledUpdate

Returns a version of your function that can be called at most every W milliseconds, where W is wait. for calls that happen more often than W the last call will be the one called

Parameters

  • fn
  • wait

throttle

limits your function to be called at most every W milliseconds, where W is wait. Calls over W get dropped. Thanks to Pat Migliaccio. see https://medium.com/@pat_migliaccio/rate-limiting-throttling-consecutive-function-calls-with-queues-4c9de7106acc

Parameters

  • fn
  • wait

Examples

let throttledFunc = throttle(myFunc,500);