| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 178a740 commit bbf7b92
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,7 @@ can be used. | |||
| 24 | 24 | ||
| 25 | 25 | When the `EventEmitter` object emits an event, all of the functions attached | |
| 26 | 26 | 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. | ||
| 28 | 28 | ||
| 29 | 29 | The following example shows a simple `EventEmitter` instance with a single | |
| 30 | 30 | listener. The `eventEmitter.on()` method is used to register listeners, while | |
@@ -97,7 +97,7 @@ myEmitter.emit('event', 'a', 'b'); | |||
| 97 | 97 | ## Handling events only once | |
| 98 | 98 | ||
| 99 | 99 | 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. | ||
| 101 | 101 | ||
| 102 | 102 | ```js | |
| 103 | 103 | const myEmitter = new MyEmitter(); | |
@@ -259,12 +259,12 @@ added: v0.1.26 | |||
| 259 | 259 | The `EventEmitter` instance will emit its own `'newListener'` event *before* | |
| 260 | 260 | a listener is added to its internal array of listeners. | |
| 261 | 261 | ||
| 262 | - Listeners registered for the `'newListener'` event will be passed the event | ||
| 262 | + Listeners registered for the `'newListener'` event are passed the event | ||
| 263 | 263 | name and a reference to the listener being added. | |
| 264 | 264 | ||
| 265 | 265 | The fact that the event is triggered before adding the listener has a subtle | |
| 266 | 266 | 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 | ||
| 268 | 268 | listener that is in the process of being added. | |
| 269 | 269 | ||
| 270 | 270 | ```js | |
@@ -334,7 +334,7 @@ event. This limit can be changed for individual `EventEmitter` instances | |||
| 334 | 334 | using the [`emitter.setMaxListeners(n)`][] method. To change the default | |
| 335 | 335 | for *all* `EventEmitter` instances, the `EventEmitter.defaultMaxListeners` | |
| 336 | 336 | property can be used. If this value is not a positive number, a `TypeError` | |
| 337 | - will be thrown. | ||
| 337 | + is thrown. | ||
| 338 | 338 | ||
| 339 | 339 | Take caution when setting the `EventEmitter.defaultMaxListeners` because the | |
| 340 | 340 | change affects *all* `EventEmitter` instances, including those created before | |
@@ -445,7 +445,7 @@ added: v6.0.0 | |||
| 445 | 445 | * Returns: {Array} | |
| 446 | 446 | ||
| 447 | 447 | 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. | ||
| 449 | 449 | ||
| 450 | 450 | ```js | |
| 451 | 451 | const EventEmitter = require('events'); | |
@@ -672,11 +672,11 @@ listener array. If any single listener has been added multiple times to the | |||
| 672 | 672 | listener array for the specified `eventName`, then `removeListener()` must be | |
| 673 | 673 | called multiple times to remove each instance. | |
| 674 | 674 | ||
| 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 | ||
| 677 | 677 | `removeListener()` or `removeAllListeners()` calls *after* emitting and | |
| 678 | 678 | *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. | ||
| 680 | 680 | ||
| 681 | 681 | ```js | |
| 682 | 682 | const myEmitter = new MyEmitter(); | |
@@ -1042,7 +1042,7 @@ There are two key differences between the Node.js `EventTarget` and the | |||
| 1042 | 1042 | event. | |
| 1043 | 1043 | 2. In the Node.js `EventTarget`, if an event listener is an async function | |
| 1044 | 1044 | 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 | ||
| 1046 | 1046 | throws synchronously (see [`EventTarget` error handling][] for details). | |
| 1047 | 1047 | ||
| 1048 | 1048 | ### `NodeEventTarget` vs. `EventEmitter` | |
@@ -1053,7 +1053,7 @@ certain situations. A `NodeEventTarget` is *not* an instance of `EventEmitter` | |||
| 1053 | 1053 | and cannot be used in place of an `EventEmitter` in most cases. | |
| 1054 | 1054 | ||
| 1055 | 1055 | 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 | ||
| 1057 | 1057 | ignored. | |
| 1058 | 1058 | 2. The `NodeEventTarget` does not emulate the full `EventEmitter` API. | |
| 1059 | 1059 | Specifically the `prependListener()`, `prependOnceListener()`, | |
@@ -1070,17 +1070,17 @@ and cannot be used in place of an `EventEmitter` in most cases. | |||
| 1070 | 1070 | Event listeners registered for an event `type` may either be JavaScript | |
| 1071 | 1071 | functions or objects with a `handleEvent` property whose value is a function. | |
| 1072 | 1072 | ||
| 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 | ||
| 1074 | 1074 | passed to the `eventTarget.dispatchEvent()` function. | |
| 1075 | 1075 | ||
| 1076 | 1076 | 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 | ||
| 1078 | 1078 | [`EventTarget` error handling][]. | |
| 1079 | 1079 | ||
| 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 | ||
| 1081 | 1081 | from being invoked. | |
| 1082 | 1082 | ||
| 1083 | - The return value of a handler function will be ignored. | ||
| 1083 | + The return value of a handler function is ignored. | ||
| 1084 | 1084 | ||
| 1085 | 1085 | Handlers are always invoked in the order they were added. | |
| 1086 | 1086 | ||
@@ -1120,7 +1120,7 @@ target.addEventListener('foo', handler4, { once: true }); | |||
| 1120 | 1120 | ### `EventTarget` error handling | |
| 1121 | 1121 | ||
| 1122 | 1122 | 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 | ||
| 1124 | 1124 | on `process.nextTick()`. Throwing within an event listener will *not* stop | |
| 1125 | 1125 | the other registered handlers from being invoked. | |
| 1126 | 1126 | ||
@@ -1193,7 +1193,7 @@ added: v14.5.0 | |||
| 1193 | 1193 | ||
| 1194 | 1194 | * Type: {boolean} | |
| 1195 | 1195 | ||
| 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 | ||
| 1197 | 1197 | called. | |
| 1198 | 1198 | ||
| 1199 | 1199 | #### `event.eventPhase` | |
@@ -1292,18 +1292,18 @@ added: v14.5.0 | |||
| 1292 | 1292 | * `type` {string} | |
| 1293 | 1293 | * `listener` {Function|EventListener} | |
| 1294 | 1294 | * `options` {Object} | |
| 1295 | - * `once` {boolean} When `true`, the listener will be automatically removed | ||
| 1295 | + * `once` {boolean} When `true`, the listener is automatically removed | ||
| 1296 | 1296 | when it is first invoked. **Default:** `false`. | |
| 1297 | 1297 | * `passive` {boolean} When `true`, serves as a hint that the listener will | |
| 1298 | 1298 | not call the `Event` object's `preventDefault()` method. | |
| 1299 | 1299 | **Default:** `false`. | |
| 1300 | 1300 | * `capture` {boolean} Not directly used by Node.js. Added for API | |
| 1301 | 1301 | completeness. **Default:** `false`. | |
| 1302 | 1302 | ||
| 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 | ||
| 1304 | 1304 | only once per `type` and per `capture` option value. | |
| 1305 | 1305 | ||
| 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 | ||
| 1307 | 1307 | next time a `type` event is dispatched. | |
| 1308 | 1308 | ||
| 1309 | 1309 | 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` | |||
| 1337 | 1337 | may be an `Event` object or any object with a `type` property whose value is | |
| 1338 | 1338 | a `string`. | |
| 1339 | 1339 | ||
| 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 | ||
| 1341 | 1341 | were registered. | |
| 1342 | 1342 | ||
| 1343 | 1343 | #### `eventTarget.removeEventListener(type, listener)` | |
| Back | FazBrowse Home | New Git URL |
0 commit comments