@rjweb/utils
Advanced tools
Comparing version 1.11.2 to 1.11.3
@@ -0,1 +1,5 @@ | ||
## 1.11.3 | ||
- Fix Queue issues | ||
## 1.11.2 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "@rjweb/utils", | ||
"version": "1.11.2", | ||
"version": "1.11.3", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
@@ -67,3 +67,4 @@ "use strict"; | ||
this.queue.push(fn); | ||
if (this.lastRun + this.options.wait < Date.now()) { | ||
if (this.lastRun + this.options.wait < Date.now() && !this.nextRunScheduled) { | ||
this.nextRunScheduled = true; | ||
this.lastRun = Infinity; | ||
@@ -73,3 +74,3 @@ this.runNextQueueItem(); | ||
this.nextRunScheduled = true; | ||
setTimeout(() => this.runNextQueueItem(), this.lastRun + this.options.wait - Date.now()); | ||
setTimeout(() => this.runNextQueueItem(), Date.now() - this.lastRun + this.options.wait); | ||
} | ||
@@ -99,4 +100,2 @@ return this; | ||
this.queue = this.queue.slice(1); | ||
this.nextRunScheduled = false; | ||
this.lastRun = Date.now(); | ||
try { | ||
@@ -128,3 +127,5 @@ const result = await Promise.resolve(item()); | ||
} finally { | ||
if (this.queue.length && !this.nextRunScheduled) { | ||
this.nextRunScheduled = false; | ||
this.lastRun = Date.now(); | ||
if (this.queue.length) { | ||
this.nextRunScheduled = true; | ||
@@ -131,0 +132,0 @@ setTimeout(() => this.runNextQueueItem(), this.options.wait); |
{ | ||
"name": "@rjweb/utils", | ||
"version": "1.11.2", | ||
"version": "1.11.3", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
@@ -44,3 +44,4 @@ import { array } from "."; | ||
this.queue.push(fn); | ||
if (this.lastRun + this.options.wait < Date.now()) { | ||
if (this.lastRun + this.options.wait < Date.now() && !this.nextRunScheduled) { | ||
this.nextRunScheduled = true; | ||
this.lastRun = Infinity; | ||
@@ -50,3 +51,3 @@ this.runNextQueueItem(); | ||
this.nextRunScheduled = true; | ||
setTimeout(() => this.runNextQueueItem(), this.lastRun + this.options.wait - Date.now()); | ||
setTimeout(() => this.runNextQueueItem(), Date.now() - this.lastRun + this.options.wait); | ||
} | ||
@@ -76,4 +77,2 @@ return this; | ||
this.queue = this.queue.slice(1); | ||
this.nextRunScheduled = false; | ||
this.lastRun = Date.now(); | ||
try { | ||
@@ -105,3 +104,5 @@ const result = await Promise.resolve(item()); | ||
} finally { | ||
if (this.queue.length && !this.nextRunScheduled) { | ||
this.nextRunScheduled = false; | ||
this.lastRun = Date.now(); | ||
if (this.queue.length) { | ||
this.nextRunScheduled = true; | ||
@@ -108,0 +109,0 @@ setTimeout(() => this.runNextQueueItem(), this.options.wait); |
{ | ||
"name": "@rjweb/utils", | ||
"version": "1.11.2", | ||
"version": "1.11.3", | ||
"description": "Easy and Lightweight Utilities", | ||
@@ -5,0 +5,0 @@ "module": "lib/esm/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1841557
6545