The worker instance to wrap
Returns the underlying worker instance, can be used to access the full Worker API on the running platform.
Minimum viable API to provide the browser's addEventListener
API
for all platforms.
The event to subscribe to.
Event handler function
Minimum viable API to provide node's off
API
for all platforms.
The event to unsubscribe from
Event handler function that was registered using either on
or addEventListener
Minimum viable API to provide node's on
API
for all platforms.
The event to subscribe to.
Event handler function
Posts a message to the worker code, this is meant to be homogeneous across platforms.
The message to send to the worker, can be anything that is supported by the structured clone algorithm
Objects to transfer to the worker, limited to ArrayBuffer
objects as a minimum viable
API on all platforms.
Minimum viable API to provide the browser's removeEventListener
API
for all platforms.
The event to unsubscribe from
Event handler function that was registered using either on
or addEventListener
Terminates the underlying worker instance and invalidates the handle to it. This WorkerWrapper instance will become unusable after calling this method.
Utility function to create a Worker instance and wrap it. Supports browsers, NodeJS and deno.
A string containing the path to the worker source. Can be an absolute or relative path.
Options to use when creating the worker.
Generated using TypeDoc
Wraps a worker instance on supported platforms and exposes a shared minimum viable API, while providing access to the original instance for advanced, platform specific functionality.