EventEmitter 类
EventEmitter
类由 node:events
模块定义和暴露:
import { EventEmitter } from 'node:events';
const EventEmitter = require('node:events');
所有的 EventEmitter
,当添加新的监听器时触发事件 'newListener'
,当删除现有的监听器时触发事件 'removeListener'
。
它支持以下的选项:
captureRejections
<boolean> 启用自动捕获 promise 拒绝。 默认值:false
。
The EventEmitter
class is defined and exposed by the node:events
module:
import { EventEmitter } from 'node:events';
const EventEmitter = require('node:events');
All EventEmitter
s emit the event 'newListener'
when new listeners are
added and 'removeListener'
when existing listeners are removed.
It supports the following option:
captureRejections
<boolean> It enables automatic capturing of promise rejection. Default:false
.