Skip to content

Commit

Permalink
dev: worker.terminateAndExit now returns Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
joshLong145 committed Oct 10, 2024
1 parent 6b829b6 commit b18249a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ worker.abortListeners = [];
/**
* Cleanup and exit the worker.
* @param {Number} code
* @returns
* @returns {Promise<void>}
*/
worker.terminateAndExit = function(code) {
var _exit = function() {
Expand All @@ -166,8 +166,13 @@ worker.terminateAndExit = function(code) {
var result = worker.terminationHandler(code);
if (isPromise(result)) {
result.then(_exit, _exit);

return result;
} else {
_exit();
return new Promise(function (_resolve, reject) {
reject(new Error("Worker terminating"));
});
}
}

Expand Down

0 comments on commit b18249a

Please sign in to comment.