Package-level declarations

Types

Link copied to clipboard
sealed external interface ReceiveMessageOnPortResult
Link copied to clipboard
sealed external interface ResourceLimits
Link copied to clipboard
typealias Serializable = Any
Link copied to clipboard
typealias TransferListItem = Any
Link copied to clipboard
external class Worker : EventEmitter

The Worker class represents an independent JavaScript execution thread. Most Node.js APIs are available inside of it.

Link copied to clipboard
sealed external interface WorkerOptions
Link copied to clipboard
sealed external interface WorkerPerformance

Properties

Link copied to clipboard
external val isMainThread: Boolean
Link copied to clipboard
external val parentPort: MessagePort?
Link copied to clipboard
Link copied to clipboard
external val SHARE_ENV: Symbol
Link copied to clipboard
external val threadId: Double
Link copied to clipboard
external val workerData: Any?

Functions

Link copied to clipboard

Within a worker thread, worker.getEnvironmentData() returns a clone of data passed to the spawning thread's worker.setEnvironmentData(). Every new Worker receives its own copy of the environment data automatically.

Link copied to clipboard
external fun markAsUntransferable(value: Any)

Mark an object as not transferable. If object occurs in the transfer list of a port.postMessage() call, it is ignored.

Link copied to clipboard
external fun moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort

Transfer a MessagePort to a different vm Context. The original port object is rendered unusable, and the returned MessagePort instance takes its place.

Link copied to clipboard

Receive a single message from a given MessagePort. If no message is available,undefined is returned, otherwise an object with a single message property that contains the message payload, corresponding to the oldest message in the MessagePort's queue.

Link copied to clipboard
external fun setEnvironmentData(key: Serializable, value: Serializable)

The worker.setEnvironmentData() API sets the content of worker.getEnvironmentData() in the current thread and all new Worker instances spawned from the current context.