NET-Web-API-w-Angular/my-app/node_modules/karma/lib/emitter_wrapper.js

34 lines
732 B
JavaScript
Raw Normal View History

2024-02-09 00:38:41 +00:00
'use strict'
class EmitterWrapper {
constructor (emitter) {
this.listeners = {}
this.emitter = emitter
}
addListener (event, listener) {
this.emitter.addListener(event, listener)
this.listeners[event] = this.listeners[event] || []
this.listeners[event].push(listener)
return this
}
on (event, listener) {
return this.addListener(event, listener)
}
removeAllListeners (event) {
const events = event ? [event] : Object.keys(this.listeners)
events.forEach((event) => {
this.listeners[event].forEach((listener) => {
this.emitter.removeListener(event, listener)
})
delete this.listeners[event]
})
return this
}
}
module.exports = EmitterWrapper