M
worker_threads.moveMessagePortToContext
History
Added in: v11.13.0
v11.13.0
Introduced in: v10.5.0
v10.5.0
worker_threads.moveMessagePortToContext(port, contextifiedSandbox): MessagePort
Attributes
port:
MessagePortThe message port to transfer.
contextifiedSandbox:
ObjectA contextified object as returned by the
vm.createContext() method.Returns:
MessagePortTransfer 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() listener are also created in the target context
and inherit from its global Object class.
However, the created MessagePort no longer inherits from
EventTarget, and only port.onmessage() can be used to receive
events using it.