feat(node): EventEmitter.errorMonitor v12 backport (#46485)

see: #45469 some symbols are not ported to v12
https://nodejs.org/docs/latest-v12.x/api/events.html#events_eventemitter_errormonitor

/cc @orgads

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-08-06 02:02:15 +02:00 committed by GitHub
parent f02d51f150
commit 6c071c6ff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -12,7 +12,19 @@ declare module "events" {
namespace internal {
function once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>;
function once(emitter: DOMEventTarget, event: string): Promise<any[]>;
class EventEmitter extends internal {
/**
* This symbol shall be used to install a listener for only monitoring `'error'`
* events. Listeners installed using this symbol are called before the regular
* `'error'` listeners are called.
*
* Installing a listener using this symbol does not change the behavior once an
* `'error'` event is emitted, therefore the process will still crash if no
* regular `'error'` listener is installed.
*/
const errorMonitor: unique symbol;
class EventEmitter extends internal {
/** @deprecated since v4.0.0 */
static listenerCount(emitter: EventEmitter, event: string | symbol): number;
static defaultMaxListeners: number;

View File

@ -82,3 +82,8 @@ const any: any = 1;
}
}, 'name');
}
{
emitter.on(events.errorMonitor, listener);
emitter.on(events.EventEmitter.errorMonitor, listener);
}