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

throttles

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

throttles - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

priority/index.min.js

22

dist/index.js

@@ -1,1 +0,21 @@

module.exports=function(n){n=n||1;var t=[],u=0;function o(){u<n&&t.length>0&&(t.shift()(),u++)}return[function(n){t.push(n)>1||o()},function(){u--,o()}]};
module.exports = function (limit) {
limit = limit || 1;
var queue=[], wip=0;
function toAdd(fn) {
queue.push(fn) > 1 || run(); // initializes if 1st
}
function isDone() {
wip--; // make room for next
run();
}
function run() {
if (wip < limit && queue.length > 0) {
queue.shift()(); wip++; // is now WIP
}
}
return [toAdd, isDone];
}

2

dist/index.min.js

@@ -1,1 +0,1 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=function(n){n=n||1;var t=[],f=0;function u(){f<n&&t.length>0&&(t.shift()(),f++)}return[function(n){t.push(n)>1||u()},function(){f--,u()}]}:"function"==typeof define&&define.amd?define(t):n.throttles=function(n){n=n||1;var t=[],f=0;function u(){f<n&&t.length>0&&(t.shift()(),f++)}return[function(n){t.push(n)>1||u()},function(){f--,u()}]}}(this,function(){return function(n){n=n||1;var t=[],f=0;function u(){f<n&&t.length>0&&(t.shift()(),f++)}return[function(n){t.push(n)>1||u()},function(){f--,u()}]}});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=function(n){n=n||1;var t=[],f=0;function u(){f<n&&t.length>0&&(t.shift()(),f++)}return[function(n){t.push(n)>1||u()},function(){f--,u()}]}:"function"==typeof define&&define.amd?define(t):n.throttles=function(n){n=n||1;var t=[],f=0;function u(){f<n&&t.length>0&&(t.shift()(),f++)}return[function(n){t.push(n)>1||u()},function(){f--,u()}]}}(this,(function(){return function(n){n=n||1;var t=[],f=0;function u(){f<n&&t.length>0&&(t.shift()(),f++)}return[function(n){t.push(n)>1||u()},function(){f--,u()}]}}));

@@ -1,4 +0,13 @@

type isDone = () => void;
type toAdd = (fn: Function) => void;
declare function throttles(limit?: number): [toAdd, isDone];
export default throttles;
declare module 'throttles' {
type isDone = () => void;
type toAdd = (fn: Function) => void;
function throttles(limit?: number): [toAdd, isDone];
export = throttles;
}
declare module 'throttles/priority' {
type isDone = () => void;
type toAdd = (fn: Function, isHigh?: boolean) => void;
function throttles(limit?: number): [toAdd, isDone];
export = throttles;
}
{
"name": "throttles",
"version": "1.0.0",
"version": "1.0.1",
"repository": "lukeed/throttles",

@@ -12,6 +12,16 @@ "description": "A tiny (139B to 204B) utility to regulate the execution rate of your functions",

"files": [
"*.d.ts",
"index.d.ts",
"priority",
"dist"
],
"modes": {
"default": "src/single.js",
"priority": "src/priority.js"
},
"scripts": {
"build": "bundt",
"pretest": "npm run build",
"test": "uvu -r esm test -i utils",
"postbuild": "cp priority.d.ts priority/index.d.ts"
},
"author": {

@@ -25,14 +35,7 @@ "name": "Luke Edwards",

},
"scripts": {
"build": "node bin",
"pretest": "npm run build",
"test": "tape -r esm test/*.js | tap-spec"
},
"devDependencies": {
"bundt": "0.4.0",
"bundt": "1.0.1",
"esm": "3.2.25",
"premove": "1.0.0",
"tap-spec": "5.0.0",
"tape": "4.11.0"
"uvu": "0.0.14"
}
}

@@ -1,1 +0,31 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=function(n){n=n||1;var t,i=[],f=[],e=0,u=0;function o(){u<n&&e>0&&((f.shift()||i.shift())(),e--,u++)}return[function(n,u){if(n.__t){if(!u)return;~(t=i.indexOf(n))&&i.splice(t,1).length&&e--}n.__t=1,(u?f:i).push(n),e++||o()},function(){u--,o()}]}:"function"==typeof define&&define.amd?define(t):n.throttles=function(n){n=n||1;var t,i=[],f=[],e=0,u=0;function o(){u<n&&e>0&&((f.shift()||i.shift())(),e--,u++)}return[function(n,u){if(n.__t){if(!u)return;~(t=i.indexOf(n))&&i.splice(t,1).length&&e--}n.__t=1,(u?f:i).push(n),e++||o()},function(){u--,o()}]}}(this,function(){return function(n){n=n||1;var t,i=[],f=[],e=0,u=0;function o(){u<n&&e>0&&((f.shift()||i.shift())(),e--,u++)}return[function(n,u){if(n.__t){if(!u)return;~(t=i.indexOf(n))&&i.splice(t,1).length&&e--}n.__t=1,(u?f:i).push(n),e++||o()},function(){u--,o()}]}});
module.exports = function (limit) {
limit = limit || 1;
var qlow=[], idx, qhigh=[], sum=0, wip=0;
function toAdd(fn, isHigh) {
if (fn.__t) {
if (isHigh) {
idx = qlow.indexOf(fn);
// must decrement (increments again)
if (!!~idx) qlow.splice(idx, 1).length && sum--;
} else return;
}
fn.__t = 1;
(isHigh ? qhigh : qlow).push(fn);
sum++ || run(); // initializes if 1st
}
function isDone() {
wip--; // make room for next
run();
}
function run() {
if (wip < limit && sum > 0) {
(qhigh.shift() || qlow.shift())();
sum--; wip++; // is now WIP
}
}
return [toAdd, isDone];
}

@@ -1,2 +0,2 @@

# throttles [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/throttles)](https://codecov.io/gh/lukeed/throttles)
# throttles [![build status](https://badgen.now.sh/github/status/lukeed/throttles)](https://github.com/lukeed/throttles/actions) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/throttles)](https://codecov.io/gh/lukeed/throttles)

@@ -3,0 +3,0 @@ > A tiny (139B to 204B) utility to regulate the execution rate of your functions

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