emitter.prependListener(eventName, listener)
eventName<string> | <symbol> 事件的名称。listener<Function> 回调函数- 返回: <EventEmitter>
将 listener 函数添加到名为 eventName 的事件的监听器数组的 开头。不会检查 listener 是否已经被添加。多次传入相同的 eventName 和 listener 组合会导致 listener 被多次添加并多次调用。
【Adds the listener function to the beginning of the listeners array for the
event named eventName. No checks are made to see if the listener has
already been added. Multiple calls passing the same combination of eventName
and listener will result in the listener being added, and called, multiple
times.】
server.prependListener('connection', (stream) => {
console.log('someone connected!');
}); 返回 EventEmitter 的引用,以便可以进行链式调用。
【Returns a reference to the EventEmitter, so that calls can be chained.】