Skip to content

Almenon/throttle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

throttle

functions you can use to throttle your input if you get too many calls

npm install function-throttler

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

About

generic throttling functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published