First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
4
node_modules/throttles/priority/index.d.ts
generated
vendored
Normal file
4
node_modules/throttles/priority/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
type isDone = () => void;
|
||||
type toAdd = (fn: Function, isHigh?: boolean) => void;
|
||||
declare function throttles(limit?: number): [toAdd, isDone];
|
||||
export default throttles;
|
31
node_modules/throttles/priority/index.js
generated
vendored
Normal file
31
node_modules/throttles/priority/index.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
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
node_modules/throttles/priority/index.min.js
generated
vendored
Normal file
1
node_modules/throttles/priority/index.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!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()}]}}));
|
31
node_modules/throttles/priority/index.mjs
generated
vendored
Normal file
31
node_modules/throttles/priority/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
export default 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];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue