Skip to content

Instantly share code, notes, and snippets.

@deepal
Last active December 22, 2019 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepal/cf2c08d35c4f39b5e2f858e634381703 to your computer and use it in GitHub Desktop.
Save deepal/cf2c08d35c4f39b5e2f858e634381703 to your computer and use it in GitHub Desktop.
const kPublicPort = Symbol('kPublicPort');
// ...redacted...
const { port1, port2 } = new MessageChannel();
this[kPublicPort] = port1;
this[kPublicPort].on('message', (message) => this.emit('message', message));
// ...redacted...
this[kPort].postMessage({
type: 'loadScript',
filename,
doEval: !!options.eval,
cwdCounter: cwdCounter || workerIo.sharedCwdCounter,
workerData: options.workerData,
publicPort: port2,
// ...redacted...
hasStdin: !!options.stdin
}, [port2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment