@@ -314,42 +314,6 @@ console.log(myErr.eventNames());
314314 // Prints ['foo', 'bar', Symbol('symbol')]
315315```
316316
317- ### emitter.firstOn(eventName, listener)
318-
319- * ` eventName ` {string|Symbol} The name of the event.
320- * ` listener ` {Function} The callback function
321-
322- Adds the ` listener ` function to the * beginning* of the listeners array for the
323- event named ` eventName ` . No checks are made to see if the ` listener ` has
324- already been added. Multiple calls passing the same combination of ` eventName `
325- and ` listener ` will result in the ` listener ` being added, and called, multiple
326- times.
327-
328- ``` js
329- server .firstOn (' connection' , (stream ) => {
330- console .log (' someone connected!' );
331- });
332- ```
333-
334- Returns a reference to the ` EventEmitter ` so calls can be chained.
335-
336- ### emitter.firstOnce(eventName, listener)
337-
338- * ` eventName ` {string|Symbol} The name of the event.
339- * ` listener ` {Function} The callback function
340-
341- Adds a ** one time** ` listener ` function for the event named ` eventName ` to the
342- beginning of the listeners array. This listener is invoked only the next time
343- ` eventName ` is triggered, after which it is removed.
344-
345- ``` js
346- server .firstOnce (' connection' , (stream ) => {
347- console .log (' Ah, we have our first user!' );
348- });
349- ```
350-
351- Returns a reference to the ` EventEmitter ` so calls can be chained.
352-
353317### emitter.getMaxListeners()
354318
355319Returns the current max listener value for the ` EventEmitter ` which is either
@@ -394,13 +358,13 @@ server.on('connection', (stream) => {
394358Returns a reference to the ` EventEmitter ` so calls can be chained.
395359
396360By default, event listeners are invoked in the order they are added. The
397- ` emitter.firstOn () ` method can be used as an alternative to add the event
398- listener to the beginning of the listeners array.
361+ ` emitter.prependListener () ` method can be used as an alternative to add the
362+ event listener to the beginning of the listeners array.
399363
400364``` js
401365const myEE = new EventEmitter ();
402366myEE .on (' foo' , () => console .log (' a' ));
403- myEE .firstOn (' foo' , () => console .log (' b' ));
367+ myEE .prependListener (' foo' , () => console .log (' b' ));
404368myEE .emit (' foo' );
405369 // Prints:
406370 // b
@@ -425,19 +389,55 @@ server.once('connection', (stream) => {
425389Returns a reference to the ` EventEmitter ` so calls can be chained.
426390
427391By default, event listeners are invoked in the order they are added. The
428- ` emitter.firstOnce () ` method can be used as an alternative to add the event
429- listener to the beginning of the listeners array.
392+ ` emitter.prependOnceListener () ` method can be used as an alternative to add the
393+ event listener to the beginning of the listeners array.
430394
431395``` js
432396const myEE = new EventEmitter ();
433397myEE .once (' foo' , () => console .log (' a' ));
434- myEE .firstOnce (' foo' , () => console .log (' b' ));
398+ myEE .prependOnceListener (' foo' , () => console .log (' b' ));
435399myEE .emit (' foo' );
436400 // Prints:
437401 // b
438402 // a
439403```
440404
405+ ### emitter.prependListener(eventName, listener)
406+
407+ * ` eventName ` {string|Symbol} The name of the event.
408+ * ` listener ` {Function} The callback function
409+
410+ Adds the ` listener ` function to the * beginning* of the listeners array for the
411+ event named ` eventName ` . No checks are made to see if the ` listener ` has
412+ already been added. Multiple calls passing the same combination of ` eventName `
413+ and ` listener ` will result in the ` listener ` being added, and called, multiple
414+ times.
415+
416+ ``` js
417+ server .prependListener (' connection' , (stream ) => {
418+ console .log (' someone connected!' );
419+ });
420+ ```
421+
422+ Returns a reference to the ` EventEmitter ` so calls can be chained.
423+
424+ ### emitter.prependOnceListener(eventName, listener)
425+
426+ * ` eventName ` {string|Symbol} The name of the event.
427+ * ` listener ` {Function} The callback function
428+
429+ Adds a ** one time** ` listener ` function for the event named ` eventName ` to the
430+ beginning of the listeners array. This listener is invoked only the next time
431+ ` eventName ` is triggered, after which it is removed.
432+
433+ ``` js
434+ server .prependOnceListener (' connection' , (stream ) => {
435+ console .log (' Ah, we have our first user!' );
436+ });
437+ ```
438+
439+ Returns a reference to the ` EventEmitter ` so calls can be chained.
440+
441441### emitter.removeAllListeners([ eventName] )
442442
443443Removes all listeners, or those of the specified ` eventName ` .
0 commit comments