Skip to content

Commit 111e403

Browse files
committed
doc: use consistent event name parameter
Implementing the suggestion in #4554 this pull request renames the parameter name in all the places that accept an event name as a parameter. Previously, the parameter has been called `event` or `type`. Now as suggested it is consistently called `eventName`. PR-URL: Reviewed-By: Reviewed-By:
1 parent cd9f54b commit 111e403

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

doc/api/events.markdown

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ added and `'removeListener'` when a listener is removed.
201201

202202
### Event: 'newListener'
203203

204-
* `event` {String|Symbol} The event name
204+
* `eventName` {String|Symbol} The name of the event being listened for
205205
* `listener` {Function} The event handler function
206206

207207
The `EventEmitter` instance will emit it's own `'newListener'` event *before*
@@ -237,16 +237,16 @@ myEmitter.emit('event');
237237

238238
### Event: 'removeListener'
239239

240-
* `event` {String|Symbol} The event name
240+
* `eventName` {String|Symbol} The event name
241241
* `listener` {Function} The event handler function
242242

243243
The `'removeListener'` event is emitted *after* a listener is removed.
244244

245-
### EventEmitter.listenerCount(emitter, event)
245+
### EventEmitter.listenerCount(emitter, eventName)
246246

247247
Stability: 0 - Deprecated: Use [`emitter.listenerCount()`][] instead.
248248

249-
A class method that returns the number of listeners for the given `event`
249+
A class method that returns the number of listeners for the given `eventName`
250250
registered on the given `emitter`.
251251

252252
```js
@@ -284,16 +284,17 @@ emitter.once('event', () => {
284284
});
285285
```
286286

287-
### emitter.addListener(event, listener)
287+
### emitter.addListener(eventName, listener)
288288

289-
Alias for `emitter.on(event, listener)`.
289+
Alias for `emitter.on(eventName, listener)`.
290290

291-
### emitter.emit(event[, arg1][, arg2][, ...])
291+
### emitter.emit(eventName[, arg1][, arg2][, ...])
292292

293-
Synchronously calls each of the listeners registered for `event`, in the order
294-
they were registered, passing the supplied arguments to each.
293+
Synchronously calls each of the listeners registered for the event named
294+
`eventName`, in the order they were registered, passing the supplied arguments
295+
to each.
295296

296-
Returns `true` if event had listeners, `false` otherwise.
297+
Returns `true` if the event had listeners, `false` otherwise.
297298

298299
### emitter.eventNames()
299300

@@ -319,15 +320,15 @@ Returns the current max listener value for the `EventEmitter` which is either
319320
set by [`emitter.setMaxListeners(n)`][] or defaults to
320321
[`EventEmitter.defaultMaxListeners`][].
321322

322-
### emitter.listenerCount(event)
323+
### emitter.listenerCount(eventName)
323324

324-
* `event` {Value} The type of event
325+
* `eventName` {Value} The name of the event being listened for
325326

326-
Returns the number of listeners listening to the `event` type.
327+
Returns the number of listeners listening to the event named `eventName`.
327328

328-
### emitter.listeners(event)
329+
### emitter.listeners(eventName)
329330

330-
Returns a copy of the array of listeners for the specified `event`.
331+
Returns a copy of the array of listeners for the event named `eventName`.
331332

332333
```js
333334
server.on('connection', (stream) => {
@@ -337,12 +338,12 @@ console.log(util.inspect(server.listeners('connection')));
337338
// Prints: [ [Function] ]
338339
```
339340

340-
### emitter.on(event, listener)
341+
### emitter.on(eventName, listener)
341342

342343
Adds the `listener` function to the end of the listeners array for the
343-
specified `event`. No checks are made to see if the `listener` has already
344-
been added. Multiple calls passing the same combination of `event` and
345-
`listener` will result in the `listener` being added, and called, multiple
344+
event named `eventName`. No checks are made to see if the `listener` has
345+
already been added. Multiple calls passing the same combination of `eventName`
346+
and `listener` will result in the `listener` being added, and called, multiple
346347
times.
347348

348349
```js
@@ -353,10 +354,11 @@ server.on('connection', (stream) => {
353354

354355
Returns a reference to the `EventEmitter` so calls can be chained.
355356

356-
### emitter.once(event, listener)
357+
### emitter.once(eventName, listener)
357358

358-
Adds a **one time** `listener` function for the `event`. This listener is
359-
invoked only the next time `event` is triggered, after which it is removed.
359+
Adds a **one time** `listener` function for the event named `eventName`. This
360+
listener is invoked only the next time `eventName` is triggered, after which
361+
it is removed.
360362

361363
```js
362364
server.once('connection', (stream) => {
@@ -366,20 +368,20 @@ server.once('connection', (stream) => {
366368

367369
Returns a reference to the `EventEmitter` so calls can be chained.
368370

369-
### emitter.removeAllListeners([event])
371+
### emitter.removeAllListeners([eventName])
370372

371-
Removes all listeners, or those of the specified `event`.
373+
Removes all listeners, or those of the specified `eventName`.
372374

373375
Note that it is bad practice to remove listeners added elsewhere in the code,
374376
particularly when the `EventEmitter` instance was created by some other
375377
component or module (e.g. sockets or file streams).
376378

377379
Returns a reference to the `EventEmitter` so calls can be chained.
378380

379-
### emitter.removeListener(event, listener)
381+
### emitter.removeListener(eventName, listener)
380382

381-
Removes the specified `listener` from the listener array for the specified
382-
`event`.
383+
Removes the specified `listener` from the listener array for the event named
384+
`eventName`.
383385

384386
```js
385387
var callback = (stream) => {
@@ -392,8 +394,8 @@ server.removeListener('connection', callback);
392394

393395
`removeListener` will remove, at most, one instance of a listener from the
394396
listener array. If any single listener has been added multiple times to the
395-
listener array for the specified `event`, then `removeListener` must be called
396-
multiple times to remove each instance.
397+
listener array for the specified `eventName`, then `removeListener` must be
398+
called multiple times to remove each instance.
397399

398400
Note that once an event has been emitted, all listeners attached to it at the
399401
time of emitting will be called in order. This implies that any `removeListener()`

0 commit comments

Comments
 (0)