Comparing version 1.6.2 to 1.6.3
@@ -220,6 +220,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
const taskCompleted = () => this.taskCompletion(task.id); | ||
let taskCompletionDotThen; | ||
const taskID = this.nextTaskID++; | ||
const taskCompletion = this.taskCompletion(taskID); | ||
taskCompletion.catch((error) => { | ||
// Prevent unhandled rejections here as we assume the user will use | ||
// `pool.completed()`, `pool.settled()` or `task.catch()` to handle errors | ||
this.debug(`Task #${taskID} errored:`, error); | ||
}); | ||
const task = { | ||
id: this.nextTaskID++, | ||
id: taskID, | ||
run: taskFunction, | ||
@@ -235,9 +240,3 @@ cancel: () => { | ||
}, | ||
get then() { | ||
if (!taskCompletionDotThen) { | ||
const promise = taskCompleted(); | ||
taskCompletionDotThen = promise.then.bind(promise); | ||
} | ||
return taskCompletionDotThen; | ||
} | ||
then: taskCompletion.then.bind(taskCompletion) | ||
}; | ||
@@ -244,0 +243,0 @@ if (this.taskQueue.length >= maxQueuedJobs) { |
@@ -227,6 +227,11 @@ "use strict"; | ||
} | ||
const taskCompleted = () => this.taskCompletion(task.id); | ||
let taskCompletionDotThen; | ||
const taskID = this.nextTaskID++; | ||
const taskCompletion = this.taskCompletion(taskID); | ||
taskCompletion.catch((error) => { | ||
// Prevent unhandled rejections here as we assume the user will use | ||
// `pool.completed()`, `pool.settled()` or `task.catch()` to handle errors | ||
this.debug(`Task #${taskID} errored:`, error); | ||
}); | ||
const task = { | ||
id: this.nextTaskID++, | ||
id: taskID, | ||
run: taskFunction, | ||
@@ -242,9 +247,3 @@ cancel: () => { | ||
}, | ||
get then() { | ||
if (!taskCompletionDotThen) { | ||
const promise = taskCompleted(); | ||
taskCompletionDotThen = promise.then.bind(promise); | ||
} | ||
return taskCompletionDotThen; | ||
} | ||
then: taskCompletion.then.bind(taskCompletion) | ||
}; | ||
@@ -251,0 +250,0 @@ if (this.taskQueue.length >= maxQueuedJobs) { |
{ | ||
"name": "threads", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "Web workers & worker threads as simple as a function call", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
175534
3962