diff options
Diffstat (limited to 'doc/api/worker_threads.md')
-rw-r--r-- | doc/api/worker_threads.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index d20fd0fce5..8b301f42a8 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -286,7 +286,7 @@ For example: ```js const assert = require('assert'); const { - Worker, MessageChannel, MessagePort, isMainThread + Worker, MessageChannel, MessagePort, isMainThread, parentPort } = require('worker_threads'); if (isMainThread) { const worker = new Worker(__filename); @@ -296,7 +296,7 @@ if (isMainThread) { console.log('received:', value); }); } else { - require('worker_threads').once('message', (value) => { + parentPort.once('message', (value) => { assert(value.hereIsYourPort instanceof MessagePort); value.hereIsYourPort.postMessage('the worker is sending this'); value.hereIsYourPort.close(); |