mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
PR-URL: https://github.com/nodejs/node/pull/62020 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
24 lines
557 B
JavaScript
24 lines
557 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker, isMainThread } = require('worker_threads');
|
|
|
|
if (isMainThread) {
|
|
const w = new Worker(__filename, { stdout: true });
|
|
const expected = 'hello world';
|
|
|
|
let data = '';
|
|
w.stdout.setEncoding('utf8');
|
|
w.stdout.on('data', (chunk) => {
|
|
data += chunk;
|
|
});
|
|
|
|
w.on('exit', common.mustCall(() => {
|
|
assert.strictEqual(data, expected);
|
|
}));
|
|
} else {
|
|
process.stdout.write('hello');
|
|
process.stdout.write(' ');
|
|
process.stdout.write('world');
|
|
}
|