• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import { mustCall } from '../common/index.mjs';
2import assert from 'assert';
3import { Worker, isMainThread, parentPort } from 'worker_threads';
4
5const kTestString = 'Hello, world!';
6
7if (isMainThread) {
8  const w = new Worker(new URL(import.meta.url));
9  w.on('message', mustCall((message) => {
10    assert.strictEqual(message, kTestString);
11  }));
12} else {
13  setImmediate(() => {
14    process.nextTick(() => {
15      parentPort.postMessage(kTestString);
16    });
17  });
18}
19