Skip to content

Function: parentScope()

Documentation / @wtf/platform-node / worker / parentScope

function parentScope(): ParentScope;

Defined in: packages/platform-node/src/worker.ts:221

The scope a worker’s script posts and is given messages by, of parentPort of node:worker_threads, as a worker’s self is in a browser; of a script that is no worker’s, one that posts nothing.

const self = parentScope()
self.addEventListener('message', ({ data }) => self.postMessage(data))

Returns

ParentScope