Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue where it's not possible to use this library inside of a NodeJS worker thread, since the check below is not accounting for where the thread originated from. When using this library within a worker thread, the
workerThread()
code is executed, rather than themainThread()
code which creates the worker polyfill.web-worker/node.js
Line 73 in 29fef97
This change executes
workerThread()
only if themod
property is present from theworkerData
, indicating that it's being executed from a thread created within this library. Ifmod
isn't present, this means that the code is executing within the context of some other worker thread that wasn't created from this library, and it needs to treat the current thread as the main thread by executingmainThread()
.One enhancement might be to randomize the
mod
property name. This change assumes that a parent thread won't send amod
property in theworkerData
...