@randajan/jet-core
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -662,3 +662,3 @@ var __defProp = Object.defineProperty; | ||
// src/jet/buffer.js | ||
var buffer = (processQueue, bufferMs = 100, maxQueueSize = 100) => { | ||
var buffer = (processQueue, bufferMs = 100, maxQueueMs = 0, maxQueueSize = 0) => { | ||
if (!jet.isRunnable(processQueue)) { | ||
@@ -668,5 +668,8 @@ throw new Error("jet.buffer(...) require function as a first argument"); | ||
bufferMs = Math.max(0, Number.jet.to(bufferMs)); | ||
maxQueueMs = Math.max(0, Number.jet.to(maxQueueMs)); | ||
maxQueueSize = Math.max(0, Number.jet.to(maxQueueSize)); | ||
let int, queue = []; | ||
let intA, intB, queue = []; | ||
const execute = (_) => { | ||
clearTimeout(intA); | ||
clearTimeout(intB); | ||
const q = queue; | ||
@@ -677,3 +680,3 @@ queue = []; | ||
return (...args) => { | ||
clearTimeout(int); | ||
clearTimeout(intA); | ||
if (maxQueueSize && queue.length >= maxQueueSize) { | ||
@@ -683,3 +686,6 @@ return execute(); | ||
queue.push(args); | ||
int = setTimeout(execute, bufferMs); | ||
intA = setTimeout(execute, bufferMs); | ||
if (maxQueueMs > bufferMs && queue.length === 1) { | ||
intB = setTimeout(execute, maxQueueMs); | ||
} | ||
}; | ||
@@ -686,0 +692,0 @@ }; |
{ | ||
"name": "@randajan/jet-core", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "Ecosystem of types and related usefull tools.", | ||
@@ -5,0 +5,0 @@ "repository": "randajan/jet-core", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152337
1488