Skip to content

Commit 769f63c

Browse files
lpincajasnell
authored andcommitted
doc: add added: information for events
PR-URL: #7822 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 66af6a9 commit 769f63c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

doc/api/events.md

+55
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ myEmitter.emit('error', new Error('whoops!'));
167167
```
168168

169169
## Class: EventEmitter
170+
<!-- YAML
171+
added: v0.1.26
172+
-->
170173

171174
The `EventEmitter` class is defined and exposed by the `events` module:
172175

@@ -178,6 +181,9 @@ All EventEmitters emit the event `'newListener'` when new listeners are
178181
added and `'removeListener'` when existing listeners are removed.
179182

180183
### Event: 'newListener'
184+
<!-- YAML
185+
added: v0.1.26
186+
-->
181187

182188
* `eventName` {String|Symbol} The name of the event being listened for
183189
* `listener` {Function} The event handler function
@@ -214,13 +220,20 @@ myEmitter.emit('event');
214220
```
215221

216222
### Event: 'removeListener'
223+
<!-- YAML
224+
added: v0.9.3
225+
-->
217226

218227
* `eventName` {String|Symbol} The event name
219228
* `listener` {Function} The event handler function
220229

221230
The `'removeListener'` event is emitted *after* the `listener` is removed.
222231

223232
### EventEmitter.listenerCount(emitter, eventName)
233+
<!-- YAML
234+
added: v0.9.12
235+
deprecated: v4.0.0
236+
-->
224237

225238
> Stability: 0 - Deprecated: Use [`emitter.listenerCount()`][] instead.
226239
@@ -236,6 +249,9 @@ console.log(EventEmitter.listenerCount(myEmitter, 'event'));
236249
```
237250

238251
### EventEmitter.defaultMaxListeners
252+
<!-- YAML
253+
added: v0.11.2
254+
-->
239255

240256
By default, a maximum of `10` listeners can be registered for any single
241257
event. This limit can be changed for individual `EventEmitter` instances
@@ -263,10 +279,16 @@ emitter.once('event', () => {
263279
```
264280

265281
### emitter.addListener(eventName, listener)
282+
<!-- YAML
283+
added: v0.1.26
284+
-->
266285

267286
Alias for `emitter.on(eventName, listener)`.
268287

269288
### emitter.emit(eventName[, arg1][, arg2][, ...])
289+
<!-- YAML
290+
added: v0.1.26
291+
-->
270292

271293
Synchronously calls each of the listeners registered for the event named
272294
`eventName`, in the order they were registered, passing the supplied arguments
@@ -275,6 +297,9 @@ to each.
275297
Returns `true` if the event had listeners, `false` otherwise.
276298

277299
### emitter.eventNames()
300+
<!-- YAML
301+
added: v6.0.0
302+
-->
278303

279304
Returns an array listing the events for which the emitter has registered
280305
listeners. The values in the array will be strings or Symbols.
@@ -293,18 +318,27 @@ console.log(myEE.eventNames());
293318
```
294319

295320
### emitter.getMaxListeners()
321+
<!-- YAML
322+
added: v1.0.0
323+
-->
296324

297325
Returns the current max listener value for the `EventEmitter` which is either
298326
set by [`emitter.setMaxListeners(n)`][] or defaults to
299327
[`EventEmitter.defaultMaxListeners`][].
300328

301329
### emitter.listenerCount(eventName)
330+
<!-- YAML
331+
added: v3.2.0
332+
-->
302333

303334
* `eventName` {String|Symbol} The name of the event being listened for
304335

305336
Returns the number of listeners listening to the event named `eventName`.
306337

307338
### emitter.listeners(eventName)
339+
<!-- YAML
340+
added: v0.1.26
341+
-->
308342

309343
Returns a copy of the array of listeners for the event named `eventName`.
310344

@@ -317,6 +351,9 @@ console.log(util.inspect(server.listeners('connection')));
317351
```
318352

319353
### emitter.on(eventName, listener)
354+
<!-- YAML
355+
added: v0.1.101
356+
-->
320357

321358
* `eventName` {String|Symbol} The name of the event.
322359
* `listener` {Function} The callback function
@@ -350,6 +387,9 @@ myEE.emit('foo');
350387
```
351388

352389
### emitter.once(eventName, listener)
390+
<!-- YAML
391+
added: v0.3.0
392+
-->
353393

354394
* `eventName` {String|Symbol} The name of the event.
355395
* `listener` {Function} The callback function
@@ -380,6 +420,9 @@ myEE.emit('foo');
380420
```
381421

382422
### emitter.prependListener(eventName, listener)
423+
<!-- YAML
424+
added: v6.0.0
425+
-->
383426

384427
* `eventName` {String|Symbol} The name of the event.
385428
* `listener` {Function} The callback function
@@ -399,6 +442,9 @@ server.prependListener('connection', (stream) => {
399442
Returns a reference to the `EventEmitter`, so that calls can be chained.
400443

401444
### emitter.prependOnceListener(eventName, listener)
445+
<!-- YAML
446+
added: v6.0.0
447+
-->
402448

403449
* `eventName` {String|Symbol} The name of the event.
404450
* `listener` {Function} The callback function
@@ -416,6 +462,9 @@ server.prependOnceListener('connection', (stream) => {
416462
Returns a reference to the `EventEmitter`, so that calls can be chained.
417463

418464
### emitter.removeAllListeners([eventName])
465+
<!-- YAML
466+
added: v0.1.26
467+
-->
419468

420469
Removes all listeners, or those of the specified `eventName`.
421470

@@ -426,6 +475,9 @@ component or module (e.g. sockets or file streams).
426475
Returns a reference to the `EventEmitter`, so that calls can be chained.
427476

428477
### emitter.removeListener(eventName, listener)
478+
<!-- YAML
479+
added: v0.1.26
480+
-->
429481

430482
Removes the specified `listener` from the listener array for the event named
431483
`eventName`.
@@ -490,6 +542,9 @@ the `emitter.listeners()` method will need to be recreated.
490542
Returns a reference to the `EventEmitter`, so that calls can be chained.
491543

492544
### emitter.setMaxListeners(n)
545+
<!-- YAML
546+
added: v0.3.5
547+
-->
493548

494549
By default EventEmitters will print a warning if more than `10` listeners are
495550
added for a particular event. This is a useful default that helps finding

0 commit comments

Comments
 (0)