EventEmitter 类


EventEmitter 类由 node:events 模块定义和暴露:

import { EventEmitter } from 'node:events';const EventEmitter = require('node:events');

所有的 EventEmitter,当添加新的监听器时触发事件 'newListener',当删除现有的监听器时触发事件 'removeListener'

它支持以下的选项:

The EventEmitter class is defined and exposed by the node:events module:

import { EventEmitter } from 'node:events';const EventEmitter = require('node:events');

All EventEmitters emit the event 'newListener' when new listeners are added and 'removeListener' when existing listeners are removed.

It supports the following option: