aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/queue.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/queue.js b/tools/queue.js
index d8853e4..f45ec80 100644
--- a/tools/queue.js
+++ b/tools/queue.js
@@ -3,15 +3,18 @@
module.exports = function(delayms, maxExport, call){
let queue = [];
- let open = true; // The meaning of this variable is complicated, so watch closely
+ let id = 0;
+ let open = true; // Has call() run in the past delayms ms?
let getObjs = (maxExport == 1) ? // Should call be given one object or an array?
() => queue.shift() :
() => queue.splice(0, maxExport);
this.enqueue = function(arr){
+ id += arr.length;
for (item of arr)
queue.push(item);
if (open) dequeue();
+ return id;
}
disabled = true; // Used to disable pushes when non-sensical like if a socket is down
@@ -31,7 +34,7 @@ module.exports = function(delayms, maxExport, call){
open = true;
else {
open = false;
- call(getObjs());
+ call(getObjs(), id-queue.length);
setTimeout(dequeue, delayms);
}
}