New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

limiter-component

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

limiter-component - npm Package Compare versions

Comparing version 0.2.2 to 1.0.0

5

History.md
1.0.0 / 2017-01-14
==================
* process subsequent function immediately when told to skip the rest of the interval
0.2.2 / 2017-01-14

@@ -3,0 +8,0 @@ ==================

22

index.js

@@ -11,2 +11,3 @@

penaltyCounter = 0,
skipCounter = 0,
timer;

@@ -29,3 +30,10 @@

fn();
lastTrigger = now();
// wait to the next interval unless told to skip
// to the next operation immediately
if (skipCounter > 0) {
skipCounter = 0;
}
else {
lastTrigger = now();
}
}

@@ -42,4 +50,9 @@

function schedule() {
var delay;
if (!timer && queue.length) {
timer = setTimeout(deque, currentInterval() - since());
delay = currentInterval() - since();
if (delay < 0) {
return deque();
}
timer = setTimeout(deque, delay);
}

@@ -61,2 +74,6 @@ }

function skip() {
skipCounter += 1;
}
function cancel() {

@@ -73,4 +90,5 @@ if (timer) {

penalty: penalty,
skip: skip,
cancel: cancel
};
}

2

package.json
{
"name": "limiter-component",
"version": "0.2.2",
"version": "1.0.0",
"description": "Limits the rate of function calls to one per period. It delays but does not throttle the calls.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -38,5 +38,9 @@ [![NPM version][npm-image]][npm-url]

l.trigger(function() {
l.penalty(); // wait a bit longer next time
l.penalty(); // wait a bit longer the next time
});
l.trigger(doThat);
l.trigger(function() {
l.skip(); // don't wait at all the next time
});
l.trigger(doThis);
```

@@ -59,4 +63,8 @@

Make limiter to use `penaltyInterval` before triggering next function.
Make limiter use `penaltyInterval` before triggering next function.
### skip()
Make limiter trigger next function immediately.
### cancel()

@@ -63,0 +71,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc