Skip to content

Commit cb3c3fc

Browse files
TrottBridgeAR
authored andcommitted
doc,worker: use code markup/markdown in headers
PR-URL: #31086 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 342d337 commit cb3c3fc

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

doc/api/worker_threads.md

+32-32
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.resourceLimits
160+
## `worker.resourceLimits`
161161
<!-- YAML
162162
added: v13.2.0
163163
-->
@@ -173,7 +173,7 @@ this matches its values.
173173

174174
If this is used in the main thread, its value is an empty object.
175175

176-
## worker.SHARE_ENV
176+
## `worker.SHARE_ENV`
177177
<!-- YAML
178178
added: v11.14.0
179179
-->
@@ -192,7 +192,7 @@ new Worker('process.env.SET_IN_WORKER = "foo"', { eval: true, env: SHARE_ENV })
192192
});
193193
```
194194

195-
## worker.threadId
195+
## `worker.threadId`
196196
<!-- YAML
197197
added: v10.5.0
198198
-->
@@ -203,7 +203,7 @@ An integer identifier for the current thread. On the corresponding worker object
203203
(if there is any), it is available as [`worker.threadId`][].
204204
This value is unique for each [`Worker`][] instance inside a single process.
205205

206-
## worker.workerData
206+
## `worker.workerData`
207207
<!-- YAML
208208
added: v10.5.0
209209
-->
@@ -224,7 +224,7 @@ if (isMainThread) {
224224
}
225225
```
226226

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

247-
## Class: MessagePort
247+
## Class: `MessagePort`
248248
<!-- YAML
249249
added: v10.5.0
250250
-->
@@ -259,7 +259,7 @@ structured data, memory regions and other `MessagePort`s between different
259259
With the exception of `MessagePort`s being [`EventEmitter`][]s rather
260260
than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s.
261261

262-
### Event: 'close'
262+
### Event: `'close'`
263263
<!-- YAML
264264
added: v10.5.0
265265
-->
@@ -281,7 +281,7 @@ port1.postMessage('foobar');
281281
port1.close();
282282
```
283283

284-
### Event: 'message'
284+
### Event: `'message'`
285285
<!-- YAML
286286
added: v10.5.0
287287
-->
@@ -294,7 +294,7 @@ input of [`port.postMessage()`][].
294294
Listeners on this event will receive a clone of the `value` parameter as passed
295295
to `postMessage()` and no further arguments.
296296

297-
### port.close()
297+
### `port.close()`
298298
<!-- YAML
299299
added: v10.5.0
300300
-->
@@ -306,7 +306,7 @@ This method can be called when no further communication will happen over this
306306
The [`'close'` event][] will be emitted on both `MessagePort` instances that
307307
are part of the channel.
308308

309-
### port.postMessage(value\[, transferList\])
309+
### `port.postMessage(value[, transferList])`
310310
<!-- YAML
311311
added: v10.5.0
312312
-->
@@ -387,7 +387,7 @@ posting without having side effects.
387387
For more information on the serialization and deserialization mechanisms
388388
behind this API, see the [serialization API of the `v8` module][v8.serdes].
389389

390-
### port.ref()
390+
### `port.ref()`
391391
<!-- YAML
392392
added: v10.5.0
393393
-->
@@ -400,7 +400,7 @@ If listeners are attached or removed using `.on('message')`, the port will
400400
be `ref()`ed and `unref()`ed automatically depending on whether
401401
listeners for the event exist.
402402

403-
### port.start()
403+
### `port.start()`
404404
<!-- YAML
405405
added: v10.5.0
406406
-->
@@ -415,7 +415,7 @@ Node.js also diverges in its handling of `.onmessage`. Setting it will
415415
automatically call `.start()`, but unsetting it will let messages queue up
416416
until a new handler is set or the port is discarded.
417417

418-
### port.unref()
418+
### `port.unref()`
419419
<!-- YAML
420420
added: v10.5.0
421421
-->
@@ -428,7 +428,7 @@ If listeners are attached or removed using `.on('message')`, the port will
428428
be `ref()`ed and `unref()`ed automatically depending on whether
429429
listeners for the event exist.
430430

431-
## Class: Worker
431+
## Class: `Worker`
432432
<!-- YAML
433433
added: v10.5.0
434434
-->
@@ -503,7 +503,7 @@ if (isMainThread) {
503503
}
504504
```
505505

506-
### new Worker(filename\[, options\])
506+
### `new Worker(filename[, options])`
507507
<!-- YAML
508508
added: v10.5.0
509509
changes:
@@ -560,7 +560,7 @@ changes:
560560
* `codeRangeSizeMb` {number} The size of a pre-allocated memory range
561561
used for generated code.
562562

563-
### Event: 'error'
563+
### Event: `'error'`
564564
<!-- YAML
565565
added: v10.5.0
566566
-->
@@ -570,7 +570,7 @@ added: v10.5.0
570570
The `'error'` event is emitted if the worker thread throws an uncaught
571571
exception. In that case, the worker will be terminated.
572572

573-
### Event: 'exit'
573+
### Event: `'exit'`
574574
<!-- YAML
575575
added: v10.5.0
576576
-->
@@ -582,7 +582,7 @@ exited by calling [`process.exit()`][], the `exitCode` parameter will be the
582582
passed exit code. If the worker was terminated, the `exitCode` parameter will
583583
be `1`.
584584

585-
### Event: 'message'
585+
### Event: `'message'`
586586
<!-- YAML
587587
added: v10.5.0
588588
-->
@@ -593,15 +593,15 @@ The `'message'` event is emitted when the worker thread has invoked
593593
[`require('worker_threads').parentPort.postMessage()`][].
594594
See the [`port.on('message')`][] event for more details.
595595

596-
### Event: 'online'
596+
### Event: `'online'`
597597
<!-- YAML
598598
added: v10.5.0
599599
-->
600600

601601
The `'online'` event is emitted when the worker thread has started executing
602602
JavaScript code.
603603

604-
### worker.postMessage(value\[, transferList\])
604+
### `worker.postMessage(value[, transferList])`
605605
<!-- YAML
606606
added: v10.5.0
607607
-->
@@ -613,7 +613,7 @@ Send a message to the worker that will be received via
613613
[`require('worker_threads').parentPort.on('message')`][].
614614
See [`port.postMessage()`][] for more details.
615615

616-
### worker.ref()
616+
### `worker.ref()`
617617
<!-- YAML
618618
added: v10.5.0
619619
-->
@@ -623,7 +623,7 @@ Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker will
623623
behavior). If the worker is `ref()`ed, calling `ref()` again will have
624624
no effect.
625625

626-
### worker.resourceLimits
626+
### `worker.resourceLimits`
627627
<!-- YAML
628628
added: v13.2.0
629629
-->
@@ -639,7 +639,7 @@ this matches its values.
639639

640640
If the worker has stopped, the return value is an empty object.
641641

642-
### worker.stderr
642+
### `worker.stderr`
643643
<!-- YAML
644644
added: v10.5.0
645645
-->
@@ -651,7 +651,7 @@ inside the worker thread. If `stderr: true` was not passed to the
651651
[`Worker`][] constructor, then data will be piped to the parent thread's
652652
[`process.stderr`][] stream.
653653

654-
### worker.stdin
654+
### `worker.stdin`
655655
<!-- YAML
656656
added: v10.5.0
657657
-->
@@ -662,7 +662,7 @@ If `stdin: true` was passed to the [`Worker`][] constructor, this is a
662662
writable stream. The data written to this stream will be made available in
663663
the worker thread as [`process.stdin`][].
664664

665-
### worker.stdout
665+
### `worker.stdout`
666666
<!-- YAML
667667
added: v10.5.0
668668
-->
@@ -674,7 +674,7 @@ inside the worker thread. If `stdout: true` was not passed to the
674674
[`Worker`][] constructor, then data will be piped to the parent thread's
675675
[`process.stdout`][] stream.
676676

677-
### worker.terminate()
677+
### `worker.terminate()`
678678
<!-- YAML
679679
added: v10.5.0
680680
changes:
@@ -692,7 +692,7 @@ Stop all JavaScript execution in the worker thread as soon as possible.
692692
Returns a Promise for the exit code that is fulfilled when the
693693
[`'exit'` event][] is emitted.
694694

695-
### worker.threadId
695+
### `worker.threadId`
696696
<!-- YAML
697697
added: v10.5.0
698698
-->
@@ -703,7 +703,7 @@ An integer identifier for the referenced thread. Inside the worker thread,
703703
it is available as [`require('worker_threads').threadId`][].
704704
This value is unique for each `Worker` instance inside a single process.
705705

706-
### worker.unref()
706+
### `worker.unref()`
707707
<!-- YAML
708708
added: v10.5.0
709709
-->

0 commit comments

Comments
 (0)