Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

throttled-queue

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

throttled-queue - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.idea/copyright/profiles_settings.xml

2

package.json
{
"name": "throttled-queue",
"version": "1.0.0",
"version": "1.0.1",
"description": "Throttles arbitrary code to execute a maximum number of times per interval. Best for making throttled API requests.",

@@ -5,0 +5,0 @@ "main": "throttled-queue.js",

@@ -76,3 +76,3 @@ # throttled-queue

throttle(function() {
// This will fire at most 10 at a time, one after the other.
// This will fire at most 10 a second, as rapidly as possible.
});

@@ -90,3 +90,3 @@ }

throttle(function() {
// This will fire at most 10 at a time, spacing them out instead of in a burst.
// This will fire at most 10 requests a second, spacing them out instead of in a burst.
});

@@ -93,0 +93,0 @@ }

@@ -37,2 +37,6 @@ "use strict";

if (interval < 200) {
console.warn('An interval of less than 200ms can create performance issues.');
}
var queue = [];

@@ -60,20 +64,7 @@ var last_called = Date.now();

var num_requests = 0;
var callbacks = queue.splice(0, max_requests_per_interval);
for(var x = 0; x < callbacks.length; x++) {
callbacks[x]();
}
/**
* Execute the callbacks.
*/
while (queue.length && num_requests < max_requests_per_interval) {
var callback = queue[num_requests++];
callback();
}
/**
* Push the called items off the queue.
*/
if (num_requests < queue.length) {
queue = queue.slice(num_requests, queue.length);
} else {
queue = [];
}
last_called = Date.now();

@@ -80,0 +71,0 @@ timeout = setTimeout(dequeue, interval);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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