emitter.setMaxListeners(n)


默认情况下,如果为特定事件添加了 10 个以上的监听器,则 EventEmitter 将打印警告。 这是一个有用的默认值,有助于查找内存泄漏。 emitter.setMaxListeners() 方法允许修改此特定 EventEmitter 实例的限制。 该值可以设置为 Infinity(或 0)以指示无限数量的监听器。

返回对 EventEmitter 的引用,以便可以链式调用。

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

Returns a reference to the EventEmitter, so that calls can be chained.