Skip to content

Commit 75a6fff

Browse files
authored
doc: disambiguate top-level worker_threads module exports
PR-URL: #59890 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent e105e82 commit 75a6fff

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

doc/api/errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4419,7 +4419,7 @@ An error occurred trying to allocate memory. This should never happen.
44194419
[`new URLSearchParams(iterable)`]: url.md#new-urlsearchparamsiterable
44204420
[`package.json`]: packages.md#nodejs-packagejson-field-definitions
44214421
[`postMessage()`]: worker_threads.md#portpostmessagevalue-transferlist
4422-
[`postMessageToThread()`]: worker_threads.md#workerpostmessagetothreadthreadid-value-transferlist-timeout
4422+
[`postMessageToThread()`]: worker_threads.md#worker_threadspostmessagetothreadthreadid-value-transferlist-timeout
44234423
[`process.on('exit')`]: process.md#event-exit
44244424
[`process.send()`]: process.md#processsendmessage-sendhandle-options-callback
44254425
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn

doc/api/globals.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ navigator.locks.request('shared_resource', { mode: 'shared' }, async (lock) => {
831831
});
832832
```
833833

834-
See [`worker.locks`][] for detailed API documentation.
834+
See [`worker_threads.locks`][] for detailed API documentation.
835835

836836
## Class: `PerformanceEntry`
837837

@@ -1380,7 +1380,7 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
13801380
[`setTimeout`]: timers.md#settimeoutcallback-delay-args
13811381
[`structuredClone`]: https://developer.mozilla.org/en-US/docs/Web/API/structuredClone
13821382
[`window.navigator`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator
1383-
[`worker.locks`]: worker_threads.md#workerlocks
1383+
[`worker_threads.locks`]: worker_threads.md#worker_threadslocks
13841384
[browser `LockManager`]: https://developer.mozilla.org/en-US/docs/Web/API/LockManager
13851385
[buffer section]: buffer.md
13861386
[built-in objects]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects

doc/api/process.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4536,7 +4536,7 @@ cases:
45364536
[`net.Server`]: net.md#class-netserver
45374537
[`net.Socket`]: net.md#class-netsocket
45384538
[`os.constants.dlopen`]: os.md#dlopen-constants
4539-
[`postMessageToThread()`]: worker_threads.md#workerpostmessagetothreadthreadid-value-transferlist-timeout
4539+
[`postMessageToThread()`]: worker_threads.md#worker_threadspostmessagetothreadthreadid-value-transferlist-timeout
45404540
[`process.argv`]: #processargv
45414541
[`process.config`]: #processconfig
45424542
[`process.execPath`]: #processexecpath

doc/api/worker_threads.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ The `node:worker_threads` module enables the use of threads that execute
1010
JavaScript 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

2222
Workers (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,
102102
specifically `argv` and `execArgv` options.
103103

104-
## `worker.getEnvironmentData(key)`
104+
## `worker_threads.getEnvironmentData(key)`
105105

106106
<!-- YAML
107107
added:
@@ -158,7 +158,7 @@ if (isMainThread) {
158158
}
159159
```
160160
161-
## `worker.isInternalThread`
161+
## `worker_threads.isInternalThread`
162162
163163
<!-- YAML
164164
added:
@@ -202,7 +202,7 @@ const { isInternalThread } = require('node:worker_threads');
202202
console.log(isInternalThread); // false
203203
```
204204
205-
## `worker.isMainThread`
205+
## `worker_threads.isMainThread`
206206
207207
<!-- YAML
208208
added: v10.5.0
@@ -238,7 +238,7 @@ if (isMainThread) {
238238
}
239239
```
240240
241-
## `worker.markAsUntransferable(object)`
241+
## `worker_threads.markAsUntransferable(object)`
242242
243243
<!-- YAML
244244
added:
@@ -315,7 +315,7 @@ console.log(typedArray2);
315315
316316
There is no equivalent to this API in browsers.
317317
318-
## `worker.isMarkedAsUntransferable(object)`
318+
## `worker_threads.isMarkedAsUntransferable(object)`
319319
320320
<!-- YAML
321321
added: v21.0.0
@@ -349,7 +349,7 @@ isMarkedAsUntransferable(pooledBuffer); // Returns true.
349349
350350
There is no equivalent to this API in browsers.
351351
352-
## `worker.markAsUncloneable(object)`
352+
## `worker_threads.markAsUncloneable(object)`
353353
354354
<!-- YAML
355355
added:
@@ -399,7 +399,7 @@ try {
399399
400400
There is no equivalent to this API in browsers.
401401
402-
## `worker.moveMessagePortToContext(port, contextifiedSandbox)`
402+
## `worker_threads.moveMessagePortToContext(port, contextifiedSandbox)`
403403
404404
<!-- YAML
405405
added: 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
426426
events using it.
427427
428-
## `worker.parentPort`
428+
## `worker_threads.parentPort`
429429
430430
<!-- YAML
431431
added: 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
482482
added:
@@ -588,7 +588,7 @@ if (level === 0) {
588588
channel.onmessage = channel.close;
589589
```
590590

591-
## `worker.receiveMessageOnPort(port)`
591+
## `worker_threads.receiveMessageOnPort(port)`
592592

593593
<!-- YAML
594594
added: v12.3.0
@@ -634,7 +634,7 @@ console.log(receiveMessageOnPort(port2));
634634
When 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
640640
added:
@@ -654,7 +654,7 @@ this matches its values.
654654
655655
If 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
660660
added: 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
691691
added:
@@ -709,7 +709,7 @@ The `worker.setEnvironmentData()` API sets the content of
709709
`worker.getEnvironmentData()` in the current thread and all new `Worker`
710710
instances spawned from the current context.
711711
712-
## `worker.threadId`
712+
## `worker_threads.threadId`
713713
714714
<!-- YAML
715715
added: 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`][].
722722
This value is unique for each [`Worker`][] instance inside a single process.
723723
724-
## `worker.threadName`
724+
## `worker_threads.threadName`
725725
726726
<!-- YAML
727727
added:
@@ -734,7 +734,7 @@ added:
734734
A string identifier for the current thread or null if the thread is not running.
735735
On the corresponding worker object (if there is any), it is available as [`worker.threadName`][].
736736
737-
## `worker.workerData`
737+
## `worker_threads.workerData`
738738
739739
<!-- YAML
740740
added: v10.5.0
@@ -768,7 +768,7 @@ if (isMainThread) {
768768
}
769769
```
770770
771-
## `worker.locks`
771+
## `worker_threads.locks`
772772
773773
<!-- YAML
774774
added: v24.5.0
@@ -2238,7 +2238,7 @@ thread spawned will spawn another until the application crashes.
22382238
[`data:` URL]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
22392239
[`fs.close()`]: fs.md#fsclosefd-callback
22402240
[`fs.open()`]: fs.md#fsopenpath-flags-mode-callback
2241-
[`markAsUntransferable()`]: #workermarkasuntransferableobject
2241+
[`markAsUntransferable()`]: #worker_threadsmarkasuntransferableobject
22422242
[`node:cluster` module]: cluster.md
22432243
[`perf_hooks.performance`]: perf_hooks.md#perf_hooksperformance
22442244
[`perf_hooks` `eventLoopUtilization()`]: perf_hooks.md#performanceeventlooputilizationutilization1-utilization2
@@ -2255,23 +2255,23 @@ thread spawned will spawn another until the application crashes.
22552255
[`process.stdout`]: process.md#processstdout
22562256
[`process.threadCpuUsage()`]: process.md#processthreadcpuusagepreviousvalue
22572257
[`process.title`]: process.md#processtitle
2258-
[`require('node:worker_threads').isMainThread`]: #workerismainthread
2258+
[`require('node:worker_threads').isMainThread`]: #worker_threadsismainthread
22592259
[`require('node:worker_threads').parentPort.on('message')`]: #event-message
22602260
[`require('node:worker_threads').parentPort.postMessage()`]: #workerpostmessagevalue-transferlist
2261-
[`require('node:worker_threads').parentPort`]: #workerparentport
2262-
[`require('node:worker_threads').threadId`]: #workerthreadid
2263-
[`require('node:worker_threads').threadName`]: #workerthreadname
2264-
[`require('node:worker_threads').workerData`]: #workerworkerdata
2261+
[`require('node:worker_threads').parentPort`]: #worker_threadsparentport
2262+
[`require('node:worker_threads').threadId`]: #worker_threadsthreadid
2263+
[`require('node:worker_threads').threadName`]: #worker_threadsthreadname
2264+
[`require('node:worker_threads').workerData`]: #worker_threadsworkerdata
22652265
[`trace_events`]: tracing.md
22662266
[`v8.getHeapSnapshot()`]: v8.md#v8getheapsnapshotoptions
22672267
[`v8.getHeapStatistics()`]: v8.md#v8getheapstatistics
22682268
[`vm`]: vm.md
2269-
[`worker.SHARE_ENV`]: #workershare_env
2269+
[`worker.SHARE_ENV`]: #worker_threadsshare_env
22702270
[`worker.on('message')`]: #event-message_1
22712271
[`worker.postMessage()`]: #workerpostmessagevalue-transferlist
22722272
[`worker.terminate()`]: #workerterminate
2273-
[`worker.threadId`]: #workerthreadid_1
2274-
[`worker.threadName`]: #workerthreadname_1
2273+
[`worker.threadId`]: #workerthreadid
2274+
[`worker.threadName`]: #workerthreadname
22752275
[async-resource-worker-pool]: async_context.md#using-asyncresource-for-a-worker-thread-pool
22762276
[browser `LockManager`]: https://developer.mozilla.org/en-US/docs/Web/API/LockManager
22772277
[browser `MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort

0 commit comments

Comments
 (0)