function-throttler

1.0.0 • Public • Published

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);

Readme

Keywords

Package Sidebar

Install

npm i function-throttler

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

10.1 kB

Total Files

6

Last publish

Collaborators

  • almenon