Comparing version 1.0.0 to 1.0.1
@@ -84,9 +84,10 @@ // tslint:disable function-constructor no-eval max-classes-per-file | ||
} | ||
const terminateAll = () => { | ||
allWorkers.forEach(worker => worker.terminate()); | ||
const terminateWorkersAndMaster = () => { | ||
// we should terminate all workers and then gracefully shutdown self process | ||
Promise.all(allWorkers.map(worker => worker.terminate())).then(() => process.exit(0), () => process.exit(1)); | ||
allWorkers = []; | ||
}; | ||
// Take care to not leave orphaned processes behind. See #147. | ||
process.on("SIGINT", () => terminateAll()); | ||
process.on("SIGTERM", () => terminateAll()); | ||
process.on("SIGINT", () => terminateWorkersAndMaster()); | ||
process.on("SIGTERM", () => terminateWorkersAndMaster()); | ||
return Worker; | ||
@@ -126,4 +127,5 @@ } | ||
} | ||
const terminateAll = () => { | ||
allWorkers.forEach(worker => worker.terminate()); | ||
const terminateWorkersAndMaster = () => { | ||
// we should terminate all workers and then gracefully shutdown self process | ||
Promise.all(allWorkers.map(worker => worker.terminate())).then(() => process.exit(0), () => process.exit(1)); | ||
allWorkers = []; | ||
@@ -133,4 +135,4 @@ }; | ||
// See <https://github.com/avoidwork/tiny-worker#faq> | ||
process.on("SIGINT", () => terminateAll()); | ||
process.on("SIGTERM", () => terminateAll()); | ||
process.on("SIGINT", () => terminateWorkersAndMaster()); | ||
process.on("SIGTERM", () => terminateWorkersAndMaster()); | ||
return Worker; | ||
@@ -137,0 +139,0 @@ } |
@@ -96,9 +96,10 @@ "use strict"; | ||
} | ||
const terminateAll = () => { | ||
allWorkers.forEach(worker => worker.terminate()); | ||
const terminateWorkersAndMaster = () => { | ||
// we should terminate all workers and then gracefully shutdown self process | ||
Promise.all(allWorkers.map(worker => worker.terminate())).then(() => process.exit(0), () => process.exit(1)); | ||
allWorkers = []; | ||
}; | ||
// Take care to not leave orphaned processes behind. See #147. | ||
process.on("SIGINT", () => terminateAll()); | ||
process.on("SIGTERM", () => terminateAll()); | ||
process.on("SIGINT", () => terminateWorkersAndMaster()); | ||
process.on("SIGTERM", () => terminateWorkersAndMaster()); | ||
return Worker; | ||
@@ -138,4 +139,5 @@ } | ||
} | ||
const terminateAll = () => { | ||
allWorkers.forEach(worker => worker.terminate()); | ||
const terminateWorkersAndMaster = () => { | ||
// we should terminate all workers and then gracefully shutdown self process | ||
Promise.all(allWorkers.map(worker => worker.terminate())).then(() => process.exit(0), () => process.exit(1)); | ||
allWorkers = []; | ||
@@ -145,4 +147,4 @@ }; | ||
// See <https://github.com/avoidwork/tiny-worker#faq> | ||
process.on("SIGINT", () => terminateAll()); | ||
process.on("SIGTERM", () => terminateAll()); | ||
process.on("SIGINT", () => terminateWorkersAndMaster()); | ||
process.on("SIGTERM", () => terminateWorkersAndMaster()); | ||
return Worker; | ||
@@ -149,0 +151,0 @@ } |
{ | ||
"name": "threads", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Web workers & worker threads as simple as a function call", | ||
@@ -103,6 +103,10 @@ "main": "dist/index.js", | ||
"worker_threads": false, | ||
"./dist/master/implementation.js": "./dist/master/implementation.browser.js", | ||
"./dist/master/implementation.node.js": false, | ||
"./dist/worker/implementation.js": "./dist/worker/implementation.browser.js", | ||
"./dist/worker/implementation.tiny-worker.js": false, | ||
"./dist/worker/implementation.worker_threads.js": false, | ||
"./dist-esm/master/implementation.js": "./dist-esm/master/implementation.browser.js", | ||
"./dist-esm/master/implementation.node.js": false, | ||
"./dist-esm/worker/implementation.js": "./dist-esm/worker/implementation.browser.js", | ||
"./dist-esm/worker/implementation.tiny-worker.js": false, | ||
@@ -109,0 +113,0 @@ "./dist-esm/worker/implementation.worker_threads.js": false |
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
141896
3214