Skip to content

Commit bbf7b92

Browse files
Trottrichardlau
authored andcommitted
doc: use present tense in events.md
Present tense should be default choice. It is usually easier to read and understand. Refs: https://docs.microsoft.com/en-us/style-guide/grammar/verbs PR-URL: #35068 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Derek Lewis <[email protected]>
1 parent 178a740 commit bbf7b92

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

doc/api/events.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ can be used.
2424

2525
When the `EventEmitter` object emits an event, all of the functions attached
2626
to that specific event are called _synchronously_. Any values returned by the
27-
called listeners are _ignored_ and will be discarded.
27+
called listeners are _ignored_ and discarded.
2828

2929
The following example shows a simple `EventEmitter` instance with a single
3030
listener. The `eventEmitter.on()` method is used to register listeners, while
@@ -97,7 +97,7 @@ myEmitter.emit('event', 'a', 'b');
9797
## Handling events only once
9898

9999
When a listener is registered using the `eventEmitter.on()` method, that
100-
listener will be invoked _every time_ the named event is emitted.
100+
listener is invoked _every time_ the named event is emitted.
101101

102102
```js
103103
const myEmitter = new MyEmitter();
@@ -259,12 +259,12 @@ added: v0.1.26
259259
The `EventEmitter` instance will emit its own `'newListener'` event *before*
260260
a listener is added to its internal array of listeners.
261261

262-
Listeners registered for the `'newListener'` event will be passed the event
262+
Listeners registered for the `'newListener'` event are passed the event
263263
name and a reference to the listener being added.
264264

265265
The fact that the event is triggered before adding the listener has a subtle
266266
but important side effect: any *additional* listeners registered to the same
267-
`name` *within* the `'newListener'` callback will be inserted *before* the
267+
`name` *within* the `'newListener'` callback are inserted *before* the
268268
listener that is in the process of being added.
269269

270270
```js
@@ -334,7 +334,7 @@ event. This limit can be changed for individual `EventEmitter` instances
334334
using the [`emitter.setMaxListeners(n)`][] method. To change the default
335335
for *all* `EventEmitter` instances, the `EventEmitter.defaultMaxListeners`
336336
property can be used. If this value is not a positive number, a `TypeError`
337-
will be thrown.
337+
is thrown.
338338

339339
Take caution when setting the `EventEmitter.defaultMaxListeners` because the
340340
change affects *all* `EventEmitter` instances, including those created before
@@ -445,7 +445,7 @@ added: v6.0.0
445445
* Returns: {Array}
446446

447447
Returns an array listing the events for which the emitter has registered
448-
listeners. The values in the array will be strings or `Symbol`s.
448+
listeners. The values in the array are strings or `Symbol`s.
449449

450450
```js
451451
const EventEmitter = require('events');
@@ -672,11 +672,11 @@ listener array. If any single listener has been added multiple times to the
672672
listener array for the specified `eventName`, then `removeListener()` must be
673673
called multiple times to remove each instance.
674674

675-
Once an event has been emitted, all listeners attached to it at the
676-
time of emitting will be called in order. This implies that any
675+
Once an event is emitted, all listeners attached to it at the
676+
time of emitting are called in order. This implies that any
677677
`removeListener()` or `removeAllListeners()` calls *after* emitting and
678678
*before* the last listener finishes execution will not remove them from
679-
`emit()` in progress. Subsequent events will behave as expected.
679+
`emit()` in progress. Subsequent events behave as expected.
680680

681681
```js
682682
const myEmitter = new MyEmitter();
@@ -1042,7 +1042,7 @@ There are two key differences between the Node.js `EventTarget` and the
10421042
event.
10431043
2. In the Node.js `EventTarget`, if an event listener is an async function
10441044
or returns a `Promise`, and the returned `Promise` rejects, the rejection
1045-
will be automatically captured and handled the same way as a listener that
1045+
is automatically captured and handled the same way as a listener that
10461046
throws synchronously (see [`EventTarget` error handling][] for details).
10471047

10481048
### `NodeEventTarget` vs. `EventEmitter`
@@ -1053,7 +1053,7 @@ certain situations. A `NodeEventTarget` is *not* an instance of `EventEmitter`
10531053
and cannot be used in place of an `EventEmitter` in most cases.
10541054

10551055
1. Unlike `EventEmitter`, any given `listener` can be registered at most once
1056-
per event `type`. Attempts to register a `listener` multiple times will be
1056+
per event `type`. Attempts to register a `listener` multiple times are
10571057
ignored.
10581058
2. The `NodeEventTarget` does not emulate the full `EventEmitter` API.
10591059
Specifically the `prependListener()`, `prependOnceListener()`,
@@ -1070,17 +1070,17 @@ and cannot be used in place of an `EventEmitter` in most cases.
10701070
Event listeners registered for an event `type` may either be JavaScript
10711071
functions or objects with a `handleEvent` property whose value is a function.
10721072

1073-
In either case, the handler function will be invoked with the `event` argument
1073+
In either case, the handler function is invoked with the `event` argument
10741074
passed to the `eventTarget.dispatchEvent()` function.
10751075

10761076
Async functions may be used as event listeners. If an async handler function
1077-
rejects, the rejection will be captured and will be handled as described in
1077+
rejects, the rejection is captured and handled as described in
10781078
[`EventTarget` error handling][].
10791079

1080-
An error thrown by one handler function will not prevent the other handlers
1080+
An error thrown by one handler function does not prevent the other handlers
10811081
from being invoked.
10821082

1083-
The return value of a handler function will be ignored.
1083+
The return value of a handler function is ignored.
10841084

10851085
Handlers are always invoked in the order they were added.
10861086

@@ -1120,7 +1120,7 @@ target.addEventListener('foo', handler4, { once: true });
11201120
### `EventTarget` error handling
11211121

11221122
When a registered event listener throws (or returns a Promise that rejects),
1123-
by default the error will be forwarded to the `process.on('error')` event
1123+
by default the error is forwarded to the `process.on('error')` event
11241124
on `process.nextTick()`. Throwing within an event listener will *not* stop
11251125
the other registered handlers from being invoked.
11261126

@@ -1193,7 +1193,7 @@ added: v14.5.0
11931193

11941194
* Type: {boolean}
11951195

1196-
Will be `true` if `cancelable` is `true` and `event.preventDefault()` has been
1196+
Is `true` if `cancelable` is `true` and `event.preventDefault()` has been
11971197
called.
11981198

11991199
#### `event.eventPhase`
@@ -1292,18 +1292,18 @@ added: v14.5.0
12921292
* `type` {string}
12931293
* `listener` {Function|EventListener}
12941294
* `options` {Object}
1295-
* `once` {boolean} When `true`, the listener will be automatically removed
1295+
* `once` {boolean} When `true`, the listener is automatically removed
12961296
when it is first invoked. **Default:** `false`.
12971297
* `passive` {boolean} When `true`, serves as a hint that the listener will
12981298
not call the `Event` object's `preventDefault()` method.
12991299
**Default:** `false`.
13001300
* `capture` {boolean} Not directly used by Node.js. Added for API
13011301
completeness. **Default:** `false`.
13021302

1303-
Adds a new handler for the `type` event. Any given `listener` will be added
1303+
Adds a new handler for the `type` event. Any given `listener` is added
13041304
only once per `type` and per `capture` option value.
13051305

1306-
If the `once` option is `true`, the `listener` will be removed after the
1306+
If the `once` option is `true`, the `listener` is removed after the
13071307
next time a `type` event is dispatched.
13081308

13091309
The `capture` option is not used by Node.js in any functional way other than
@@ -1337,7 +1337,7 @@ Dispatches the `event` to the list of handlers for `event.type`. The `event`
13371337
may be an `Event` object or any object with a `type` property whose value is
13381338
a `string`.
13391339

1340-
The registered event listeners will be synchronously invoked in the order they
1340+
The registered event listeners is synchronously invoked in the order they
13411341
were registered.
13421342

13431343
#### `eventTarget.removeEventListener(type, listener)`

0 commit comments

Comments
 (0)