First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
21
node_modules/throttles/dist/index.mjs
generated
vendored
Normal file
21
node_modules/throttles/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
export default 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];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue