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 4e76a3c

Browse filesBrowse files
addaleaxtargos
authored andcommitted
doc: update MessagePort documentation for EventTarget inheritance
Refs: #34057 Refs: #35835 PR-URL: #35839 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 8169902 commit 4e76a3c
Copy full SHA for 4e76a3c

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+9
-5
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
+9-5Lines changed: 9 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ inherit from its global `Object` class. Objects passed to the
142142
and inherit from its global `Object` class.
143143

144144
However, the created `MessagePort` will no longer inherit from
145-
[`EventEmitter`][], and only [`port.onmessage()`][] can be used to receive
145+
[`EventTarget`][], and only [`port.onmessage()`][] can be used to receive
146146
events using it.
147147

148148
## `worker.parentPort`
@@ -297,17 +297,22 @@ port2.postMessage({ foo: 'bar' });
297297
## Class: `MessagePort`
298298
<!-- YAML
299299
added: v10.5.0
300+
changes:
301+
- version:
302+
- v14.7.0
303+
pr-url: https://github.com/nodejs/node/pull/34057
304+
description: This class now inherits from `EventTarget` rather than
305+
from `EventEmitter`.
300306
-->
301307

302-
* Extends: {EventEmitter}
308+
* Extends: {EventTarget}
303309

304310
Instances of the `worker.MessagePort` class represent one end of an
305311
asynchronous, two-way communications channel. It can be used to transfer
306312
structured data, memory regions and other `MessagePort`s between different
307313
[`Worker`][]s.
308314

309-
With the exception of `MessagePort`s being [`EventEmitter`][]s rather
310-
than [`EventTarget`][]s, this implementation matches [browser `MessagePort`][]s.
315+
This implementation matches [browser `MessagePort`][]s.
311316

312317
### Event: `'close'`
313318
<!-- YAML
@@ -986,7 +991,6 @@ active handle in the event system. If the worker is already `unref()`ed calling
986991
[`Buffer`]: buffer.md
987992
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`]: errors.md#errors_err_missing_message_port_in_transfer_list
988993
[`ERR_WORKER_NOT_RUNNING`]: errors.md#ERR_WORKER_NOT_RUNNING
989-
[`EventEmitter`]: events.md
990994
[`EventTarget`]: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
991995
[`FileHandle`]: fs.md#fs_class_filehandle
992996
[`KeyObject`]: crypto.md#crypto_class_keyobject

0 commit comments

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