awaitqueue
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -39,3 +39,11 @@ "use strict"; | ||
close() { | ||
if (this.closed) | ||
return; | ||
this.closed = true; | ||
for (const pendingTask of this.pendingTasks) { | ||
pendingTask.stopped = true; | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
} | ||
// Enpty the pending tasks array. | ||
this.pendingTasks.length = 0; | ||
} | ||
@@ -51,2 +59,4 @@ /** | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.closed) | ||
throw new this.ClosedErrorClass('AwaitQueue closed'); | ||
if (typeof task !== 'function') | ||
@@ -82,2 +92,4 @@ throw new TypeError('given task is not a function'); | ||
stop() { | ||
if (this.closed) | ||
return; | ||
for (const pendingTask of this.pendingTasks) { | ||
@@ -115,7 +127,3 @@ pendingTask.stopped = true; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.closed) { | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
return; | ||
} | ||
// If stop() was called for this task, ignore it. | ||
// If the task is stopped, ignore it. | ||
if (pendingTask.stopped) | ||
@@ -125,7 +133,3 @@ return; | ||
const result = yield pendingTask.task(); | ||
if (this.closed) { | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
return; | ||
} | ||
// If stop() was called for this task, ignore it. | ||
// If the task is stopped, ignore it. | ||
if (pendingTask.stopped) | ||
@@ -137,7 +141,3 @@ return; | ||
catch (error) { | ||
if (this.closed) { | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
return; | ||
} | ||
// If stop() was called for this task, ignore it. | ||
// If the task is stopped, ignore it. | ||
if (pendingTask.stopped) | ||
@@ -144,0 +144,0 @@ return; |
{ | ||
"name": "awaitqueue", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "JavaScript utility to enqueue async tasks for Node.js and the browser", | ||
@@ -5,0 +5,0 @@ "author": "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)", |
@@ -69,3 +69,15 @@ export type AwaitQueueOptions = | ||
{ | ||
if (this.closed) | ||
return; | ||
this.closed = true; | ||
for (const pendingTask of this.pendingTasks) | ||
{ | ||
pendingTask.stopped = true; | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
} | ||
// Enpty the pending tasks array. | ||
this.pendingTasks.length = 0; | ||
} | ||
@@ -82,2 +94,5 @@ | ||
{ | ||
if (this.closed) | ||
throw new this.ClosedErrorClass('AwaitQueue closed'); | ||
if (typeof task !== 'function') | ||
@@ -123,2 +138,5 @@ throw new TypeError('given task is not a function'); | ||
{ | ||
if (this.closed) | ||
return; | ||
for (const pendingTask of this.pendingTasks) | ||
@@ -166,10 +184,3 @@ { | ||
{ | ||
if (this.closed) | ||
{ | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
return; | ||
} | ||
// If stop() was called for this task, ignore it. | ||
// If the task is stopped, ignore it. | ||
if (pendingTask.stopped) | ||
@@ -182,10 +193,3 @@ return; | ||
if (this.closed) | ||
{ | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
return; | ||
} | ||
// If stop() was called for this task, ignore it. | ||
// If the task is stopped, ignore it. | ||
if (pendingTask.stopped) | ||
@@ -199,10 +203,3 @@ return; | ||
{ | ||
if (this.closed) | ||
{ | ||
pendingTask.reject(new this.ClosedErrorClass('AwaitQueue closed')); | ||
return; | ||
} | ||
// If stop() was called for this task, ignore it. | ||
// If the task is stopped, ignore it. | ||
if (pendingTask.stopped) | ||
@@ -209,0 +206,0 @@ return; |
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
23661
591