@@ -10,13 +10,13 @@ The `node:worker_threads` module enables the use of threads that execute
1010JavaScript in parallel. To access it:
1111
1212``` mjs
13- import worker from ' node:worker_threads' ;
13+ import worker_threads from ' node:worker_threads' ;
1414```
1515
1616``` cjs
1717' use strict' ;
1818
19- const worker = require (' node:worker_threads' );
19+ const worker_threads = require (' node:worker_threads' );
2020```
2121
2222Workers (threads) are useful for performing CPU-intensive JavaScript operations.
@@ -101,7 +101,7 @@ Worker threads inherit non-process-specific options by default. Refer to
101101[` Worker constructor options`][] to know how to customize worker thread options,
102102specifically `argv` and `execArgv` options.
103103
104- ## `worker .getEnvironmentData (key )`
104+ ## `worker_threads .getEnvironmentData (key )`
105105
106106<!-- YAML
107107added:
@@ -158,7 +158,7 @@ if (isMainThread) {
158158}
159159```
160160
161- ## `worker .isInternalThread`
161+ ## `worker_threads .isInternalThread`
162162
163163<!-- YAML
164164added:
@@ -202,7 +202,7 @@ const { isInternalThread } = require('node:worker_threads');
202202console.log(isInternalThread); // false
203203```
204204
205- ## `worker .isMainThread`
205+ ## `worker_threads .isMainThread`
206206
207207<!-- YAML
208208added: v10.5.0
@@ -238,7 +238,7 @@ if (isMainThread) {
238238}
239239```
240240
241- ## `worker .markAsUntransferable(object)`
241+ ## `worker_threads .markAsUntransferable(object)`
242242
243243<!-- YAML
244244added:
@@ -315,7 +315,7 @@ console.log(typedArray2);
315315
316316There is no equivalent to this API in browsers.
317317
318- ## `worker .isMarkedAsUntransferable(object)`
318+ ## `worker_threads .isMarkedAsUntransferable(object)`
319319
320320<!-- YAML
321321added: v21.0.0
@@ -349,7 +349,7 @@ isMarkedAsUntransferable(pooledBuffer); // Returns true.
349349
350350There is no equivalent to this API in browsers.
351351
352- ## `worker .markAsUncloneable(object)`
352+ ## `worker_threads .markAsUncloneable(object)`
353353
354354<!-- YAML
355355added:
@@ -399,7 +399,7 @@ try {
399399
400400There is no equivalent to this API in browsers.
401401
402- ## `worker .moveMessagePortToContext(port, contextifiedSandbox)`
402+ ## `worker_threads .moveMessagePortToContext(port, contextifiedSandbox)`
403403
404404<!-- YAML
405405added: v11.13.0
@@ -425,7 +425,7 @@ However, the created `MessagePort` no longer inherits from
425425{EventTarget}, and only [`port.onmessage()`][] can be used to receive
426426events using it.
427427
428- ## `worker .parentPort`
428+ ## `worker_threads .parentPort`
429429
430430<!-- YAML
431431added: v10.5.0
@@ -476,7 +476,7 @@ if (isMainThread) {
476476}
477477```
478478
479- ## `worker .postMessageToThread(threadId, value[, transferList][, timeout])`
479+ ## `worker_threads .postMessageToThread(threadId, value[, transferList][, timeout])`
480480
481481<!-- YAML
482482added:
@@ -588,7 +588,7 @@ if (level === 0) {
588588channel.onmessage = channel.close;
589589` ` `
590590
591- ## ` worker .receiveMessageOnPort(port)`
591+ ## ` worker_threads .receiveMessageOnPort(port)`
592592
593593<!-- YAML
594594added: v12.3 .0
@@ -634,7 +634,7 @@ console.log(receiveMessageOnPort(port2));
634634When this function is used, no `' message' ` event is emitted and the
635635`onmessage` listener is not invoked.
636636
637- ## `worker .resourceLimits`
637+ ## `worker_threads .resourceLimits`
638638
639639<!-- YAML
640640added:
@@ -654,7 +654,7 @@ this matches its values.
654654
655655If this is used in the main thread, its value is an empty object.
656656
657- ## `worker .SHARE_ENV`
657+ ## `worker_threads .SHARE_ENV`
658658
659659<!-- YAML
660660added: v11.14.0
@@ -685,7 +685,7 @@ new Worker('process.env.SET_IN_WORKER = "foo"', { eval: true, env: SHARE_ENV })
685685 });
686686```
687687
688- ## `worker .setEnvironmentData(key[, value])`
688+ ## `worker_threads .setEnvironmentData(key[, value])`
689689
690690<!-- YAML
691691added:
@@ -709,7 +709,7 @@ The `worker.setEnvironmentData()` API sets the content of
709709`worker.getEnvironmentData()` in the current thread and all new `Worker`
710710instances spawned from the current context.
711711
712- ## `worker .threadId`
712+ ## `worker_threads .threadId`
713713
714714<!-- YAML
715715added: v10.5.0
@@ -721,7 +721,7 @@ An integer identifier for the current thread. On the corresponding worker object
721721(if there is any), it is available as [`worker.threadId`][].
722722This value is unique for each [`Worker`][] instance inside a single process.
723723
724- ## `worker .threadName`
724+ ## `worker_threads .threadName`
725725
726726<!-- YAML
727727added: v24.6.0
@@ -732,7 +732,7 @@ added: v24.6.0
732732A string identifier for the current thread or null if the thread is not running.
733733On the corresponding worker object (if there is any), it is available as [`worker.threadName`][].
734734
735- ## `worker .workerData`
735+ ## `worker_threads .workerData`
736736
737737<!-- YAML
738738added: v10.5.0
@@ -766,7 +766,7 @@ if (isMainThread) {
766766}
767767` ` `
768768
769- ## ` worker .locks `
769+ ## ` worker_threads .locks `
770770
771771<!-- YAML
772772added: v24.5.0
@@ -2225,7 +2225,7 @@ thread spawned will spawn another until the application crashes.
22252225[` data:` URL ]: https: // developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
22262226[` fs.close()` ]: fs .md #fsclosefd- callback
22272227[` fs.open()` ]: fs .md #fsopenpath- flags- mode- callback
2228- [` markAsUntransferable()` ]: #workermarkasuntransferableobject
2228+ [` markAsUntransferable()` ]: #worker_threadsmarkasuntransferableobject
22292229[` node:cluster` module ]: cluster .md
22302230[` perf_hooks.performance` ]: perf_hooks .md #perf_hooksperformance
22312231[` perf_hooks` ` eventLoopUtilization()` ]: perf_hooks .md #performanceeventlooputilizationutilization1- utilization2
@@ -2242,23 +2242,23 @@ thread spawned will spawn another until the application crashes.
22422242[` process.stdout` ]: process .md #processstdout
22432243[` process.threadCpuUsage()` ]: process .md #processthreadcpuusagepreviousvalue
22442244[` process.title` ]: process .md #processtitle
2245- [` require('node:worker_threads').isMainThread` ]: #workerismainthread
2245+ [` require('node:worker_threads').isMainThread` ]: #worker_threadsismainthread
22462246[` require('node:worker_threads').parentPort.on('message')` ]: #event - message
22472247[` require('node:worker_threads').parentPort.postMessage()` ]: #workerpostmessagevalue- transferlist
2248- [` require('node:worker_threads').parentPort` ]: #workerparentport
2249- [` require('node:worker_threads').threadId` ]: #workerthreadid
2250- [` require('node:worker_threads').threadName` ]: #workerthreadname
2251- [` require('node:worker_threads').workerData` ]: #workerworkerdata
2248+ [` require('node:worker_threads').parentPort` ]: #worker_threadsparentport
2249+ [` require('node:worker_threads').threadId` ]: #worker_threadsthreadid
2250+ [` require('node:worker_threads').threadName` ]: #worker_threadsthreadname
2251+ [` require('node:worker_threads').workerData` ]: #worker_threadsworkerdata
22522252[` trace_events` ]: tracing .md
22532253[` v8.getHeapSnapshot()` ]: v8 .md #v8getheapsnapshotoptions
22542254[` v8.getHeapStatistics()` ]: v8 .md #v8getheapstatistics
22552255[` vm` ]: vm .md
2256- [` worker.SHARE_ENV` ]: #workershare_env
2256+ [` worker.SHARE_ENV` ]: #worker_threadsshare_env
22572257[` worker.on('message')` ]: #event - message_1
22582258[` worker.postMessage()` ]: #workerpostmessagevalue- transferlist
22592259[` worker.terminate()` ]: #workerterminate
2260- [` worker.threadId` ]: #workerthreadid_1
2261- [` worker.threadName` ]: #workerthreadname_1
2260+ [` worker.threadId` ]: #workerthreadid
2261+ [` worker.threadName` ]: #workerthreadname
22622262[async - resource- worker- pool]: async_context .md #using- asyncresource- for - a- worker- thread- pool
22632263[browser ` LockManager` ]: https: // developer.mozilla.org/en-US/docs/Web/API/LockManager
22642264[browser ` MessagePort` ]: https: // developer.mozilla.org/en-US/docs/Web/API/MessagePort
0 commit comments