Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 36b3e15

Browse filesBrowse files
TrottMylesBorins
authored andcommitted
doc,worker: use code markup/markdown in headers
Backport-PR-URL: #31108 PR-URL: #31086 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 7d2748a commit 36b3e15
Copy full SHA for 36b3e15

File tree

Expand file treeCollapse file tree

1 file changed

+30
-30
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+30
-30
lines changed
Open diff view settings
Collapse file

‎doc/api/worker_threads.md‎

Copy file name to clipboardExpand all lines: doc/api/worker_threads.md
+30-30Lines changed: 30 additions & 30 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ When implementing a worker pool, use the [`AsyncResource`][] API to inform
5353
diagnostic tools (e.g. in order to provide asynchronous stack traces) about the
5454
correlation between tasks and their outcomes.
5555

56-
## worker.isMainThread
56+
## `worker.isMainThread`
5757
<!-- YAML
5858
added: v10.5.0
5959
-->
@@ -74,7 +74,7 @@ if (isMainThread) {
7474
}
7575
```
7676

77-
## worker.moveMessagePortToContext(port, contextifiedSandbox)
77+
## `worker.moveMessagePortToContext(port, contextifiedSandbox)`
7878
<!-- YAML
7979
added: v11.13.0
8080
-->
@@ -98,7 +98,7 @@ However, the created `MessagePort` will no longer inherit from
9898
[`EventEmitter`][], and only [`port.onmessage()`][] can be used to receive
9999
events using it.
100100

101-
## worker.parentPort
101+
## `worker.parentPort`
102102
<!-- YAML
103103
added: v10.5.0
104104
-->
@@ -129,7 +129,7 @@ if (isMainThread) {
129129
}
130130
```
131131

132-
## worker.receiveMessageOnPort(port)
132+
## `worker.receiveMessageOnPort(port)`
133133
<!-- YAML
134134
added: v12.3.0
135135
-->
@@ -157,7 +157,7 @@ console.log(receiveMessageOnPort(port2));
157157
When this function is used, no `'message'` event will be emitted and the
158158
`onmessage` listener will not be invoked.
159159

160-
## worker.SHARE_ENV
160+
## `worker.SHARE_ENV`
161161
<!-- YAML
162162
added: v11.14.0
163163
-->
@@ -176,7 +176,7 @@ new Worker('process.env.SET_IN_WORKER = "foo"', { eval: true, env: SHARE_ENV })
176176
});
177177
```
178178

179-
## worker.threadId
179+
## `worker.threadId`
180180
<!-- YAML
181181
added: v10.5.0
182182
-->
@@ -187,7 +187,7 @@ An integer identifier for the current thread. On the corresponding worker object
187187
(if there is any), it is available as [`worker.threadId`][].
188188
This value is unique for each [`Worker`][] instance inside a single process.
189189

190-
## worker.workerData
190+
## `worker.workerData`
191191
<!-- YAML
192192
added: v10.5.0
193193
-->
@@ -208,7 +208,7 @@ if (isMainThread) {
208208
}
209209
```
210210

211-
## Class: MessageChannel
211+
## Class: `MessageChannel`
212212
<!-- YAML
213213
added: v10.5.0
214214
-->
@@ -228,7 +228,7 @@ port2.postMessage({ foo: 'bar' });
228228
// Prints: received { foo: 'bar' } from the `port1.on('message')` listener
229229
```
230230

231-
## Class: MessagePort
231+
## Class: `MessagePort`
232232
<!-- YAML
233233
added: v10.5.0
234234
-->
@@ -243,7 +243,7 @@ structured data, memory regions and other `MessagePort`s between different
243243
With the exception of `MessagePort`s being [`EventEmitter`][]s rather
244244
than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s.
245245

246-
### Event: 'close'
246+
### Event: `'close'`
247247
<!-- YAML
248248
added: v10.5.0
249249
-->
@@ -265,7 +265,7 @@ port1.postMessage('foobar');
265265
port1.close();
266266
```
267267

268-
### Event: 'message'
268+
### Event: `'message'`
269269
<!-- YAML
270270
added: v10.5.0
271271
-->
@@ -278,7 +278,7 @@ input of [`port.postMessage()`][].
278278
Listeners on this event will receive a clone of the `value` parameter as passed
279279
to `postMessage()` and no further arguments.
280280

281-
### port.close()
281+
### `port.close()`
282282
<!-- YAML
283283
added: v10.5.0
284284
-->
@@ -290,7 +290,7 @@ This method can be called when no further communication will happen over this
290290
The [`'close'` event][] will be emitted on both `MessagePort` instances that
291291
are part of the channel.
292292

293-
### port.postMessage(value\[, transferList\])
293+
### `port.postMessage(value[, transferList])`
294294
<!-- YAML
295295
added: v10.5.0
296296
-->
@@ -371,7 +371,7 @@ posting without having side effects.
371371
For more information on the serialization and deserialization mechanisms
372372
behind this API, see the [serialization API of the `v8` module][v8.serdes].
373373

374-
### port.ref()
374+
### `port.ref()`
375375
<!-- YAML
376376
added: v10.5.0
377377
-->
@@ -384,7 +384,7 @@ If listeners are attached or removed using `.on('message')`, the port will
384384
be `ref()`ed and `unref()`ed automatically depending on whether
385385
listeners for the event exist.
386386

387-
### port.start()
387+
### `port.start()`
388388
<!-- YAML
389389
added: v10.5.0
390390
-->
@@ -399,7 +399,7 @@ Node.js also diverges in its handling of `.onmessage`. Setting it will
399399
automatically call `.start()`, but unsetting it will let messages queue up
400400
until a new handler is set or the port is discarded.
401401

402-
### port.unref()
402+
### `port.unref()`
403403
<!-- YAML
404404
added: v10.5.0
405405
-->
@@ -412,7 +412,7 @@ If listeners are attached or removed using `.on('message')`, the port will
412412
be `ref()`ed and `unref()`ed automatically depending on whether
413413
listeners for the event exist.
414414

415-
## Class: Worker
415+
## Class: `Worker`
416416
<!-- YAML
417417
added: v10.5.0
418418
-->
@@ -487,7 +487,7 @@ if (isMainThread) {
487487
}
488488
```
489489

490-
### new Worker(filename\[, options\])
490+
### `new Worker(filename[, options])`
491491

492492
* `filename` {string} The path to the Worker’s main script. Must be
493493
either an absolute path or a relative path (i.e. relative to the
@@ -520,7 +520,7 @@ if (isMainThread) {
520520
will be thrown if the object cannot be cloned (e.g. because it contains
521521
`function`s).
522522

523-
### Event: 'error'
523+
### Event: `'error'`
524524
<!-- YAML
525525
added: v10.5.0
526526
-->
@@ -530,7 +530,7 @@ added: v10.5.0
530530
The `'error'` event is emitted if the worker thread throws an uncaught
531531
exception. In that case, the worker will be terminated.
532532

533-
### Event: 'exit'
533+
### Event: `'exit'`
534534
<!-- YAML
535535
added: v10.5.0
536536
-->
@@ -542,7 +542,7 @@ exited by calling [`process.exit()`][], the `exitCode` parameter will be the
542542
passed exit code. If the worker was terminated, the `exitCode` parameter will
543543
be `1`.
544544

545-
### Event: 'message'
545+
### Event: `'message'`
546546
<!-- YAML
547547
added: v10.5.0
548548
-->
@@ -553,15 +553,15 @@ The `'message'` event is emitted when the worker thread has invoked
553553
[`require('worker_threads').parentPort.postMessage()`][].
554554
See the [`port.on('message')`][] event for more details.
555555

556-
### Event: 'online'
556+
### Event: `'online'`
557557
<!-- YAML
558558
added: v10.5.0
559559
-->
560560

561561
The `'online'` event is emitted when the worker thread has started executing
562562
JavaScript code.
563563

564-
### worker.postMessage(value\[, transferList\])
564+
### `worker.postMessage(value[, transferList])`
565565
<!-- YAML
566566
added: v10.5.0
567567
-->
@@ -573,7 +573,7 @@ Send a message to the worker that will be received via
573573
[`require('worker_threads').parentPort.on('message')`][].
574574
See [`port.postMessage()`][] for more details.
575575

576-
### worker.ref()
576+
### `worker.ref()`
577577
<!-- YAML
578578
added: v10.5.0
579579
-->
@@ -583,7 +583,7 @@ Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker will
583583
behavior). If the worker is `ref()`ed, calling `ref()` again will have
584584
no effect.
585585

586-
### worker.stderr
586+
### `worker.stderr`
587587
<!-- YAML
588588
added: v10.5.0
589589
-->
@@ -595,7 +595,7 @@ inside the worker thread. If `stderr: true` was not passed to the
595595
[`Worker`][] constructor, then data will be piped to the parent thread's
596596
[`process.stderr`][] stream.
597597

598-
### worker.stdin
598+
### `worker.stdin`
599599
<!-- YAML
600600
added: v10.5.0
601601
-->
@@ -606,7 +606,7 @@ If `stdin: true` was passed to the [`Worker`][] constructor, this is a
606606
writable stream. The data written to this stream will be made available in
607607
the worker thread as [`process.stdin`][].
608608

609-
### worker.stdout
609+
### `worker.stdout`
610610
<!-- YAML
611611
added: v10.5.0
612612
-->
@@ -618,7 +618,7 @@ inside the worker thread. If `stdout: true` was not passed to the
618618
[`Worker`][] constructor, then data will be piped to the parent thread's
619619
[`process.stdout`][] stream.
620620

621-
### worker.terminate()
621+
### `worker.terminate()`
622622
<!-- YAML
623623
added: v10.5.0
624624
changes:
@@ -636,7 +636,7 @@ Stop all JavaScript execution in the worker thread as soon as possible.
636636
Returns a Promise for the exit code that is fulfilled when the
637637
[`'exit'` event][] is emitted.
638638

639-
### worker.threadId
639+
### `worker.threadId`
640640
<!-- YAML
641641
added: v10.5.0
642642
-->
@@ -647,7 +647,7 @@ An integer identifier for the referenced thread. Inside the worker thread,
647647
it is available as [`require('worker_threads').threadId`][].
648648
This value is unique for each `Worker` instance inside a single process.
649649

650-
### worker.unref()
650+
### `worker.unref()`
651651
<!-- YAML
652652
added: v10.5.0
653653
-->

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.