function-threshold

0.2.0 • Public • Published

function-threshold

NPM version

Limit the amount of times a function can be called in a specific timeframe and throw an error if the limit is exceeded.

Installation

with npm

npm install function-threshold

with yarn

yarn add function-threshold

Example

var FunctionThreshold = require('function-threshold');
 
function myFunction(suffix) {
  console.log('hooray, hello ' + suffix + '!');
}
 
// limit to 5 executions per 10 seconds (10.000 ms)
var threshold = new FunctionThreshold(myFunction, 5, 10000);
 
// call the function somewhere. It will throw an exception if limit is exceeded
threshold.call('world');
 

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    1
  • 0.1.0
    0

Package Sidebar

Install

npm i function-threshold

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • frebo