events.setMaxListeners(n[, ...eventTargets])
n
<number> 非负的数值。 每个EventTarget
事件的最大监听器数。...eventsTargets
<EventTarget[]> | <EventEmitter[]> 零个或多个 <EventTarget> 或 <EventEmitter> 实例。 如果没有指定,则n
被设置为所有新创建的 <EventTarget> 和 <EventEmitter> 对象的默认最大值。
import { setMaxListeners, EventEmitter } from 'node:events';
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);
const {
setMaxListeners,
EventEmitter
} = require('node:events');
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);
n
<number> A non-negative number. The maximum number of listeners perEventTarget
event....eventsTargets
<EventTarget[]> | <EventEmitter[]> Zero or more <EventTarget> or <EventEmitter> instances. If none are specified,n
is set as the default max for all newly created <EventTarget> and <EventEmitter> objects.
import { setMaxListeners, EventEmitter } from 'node:events';
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);
const {
setMaxListeners,
EventEmitter
} = require('node:events');
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);