Skip to main content
moveMessagePortToContext - node__worker_threads.d.ts - Node documentation
function moveMessagePortToContext

Usage in Deno

```typescript import { moveMessagePortToContext } from "node:node__worker_threads.d.ts"; ```
moveMessagePortToContext(
contextifiedSandbox: Context,
): MessagePort
> [!WARNING] Deno compatibility > This symbol is not supported. Transfer a `MessagePort` to a different `vm` Context. The original `port` object is rendered unusable, and the returned `MessagePort` instance takes its place. The returned `MessagePort` is an object in the target context and inherits from its global `Object` class. Objects passed to the [`port.onmessage()`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage) listener are also created in the target context and inherit from its global `Object` class. However, the created `MessagePort` no longer inherits from [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget), and only [`port.onmessage()`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/onmessage) can be used to receive events using it.

Parameters

The message port to transfer.
contextifiedSandbox: Context
A `contextified` object as returned by the `vm.createContext()` method.

Return Type