(type: string | number, listener: Listener)
| 92 | } |
| 93 | |
| 94 | off(type: string | number, listener: Listener): this { |
| 95 | const list = this.events[type] |
| 96 | if (list === undefined) return this |
| 97 | |
| 98 | if (list === listener) { |
| 99 | if (--this.eventsCount === 0) this.events = {} |
| 100 | else { |
| 101 | delete this.events[type] |
| 102 | } |
| 103 | } else if (typeof list !== 'function') { |
| 104 | let position = -1 |
| 105 | |
| 106 | for (let i = list.length - 1; i >= 0; i--) { |
| 107 | if (list[i] === listener) { |
| 108 | position = i |
| 109 | break |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | if (position < 0) return this |
| 114 | |
| 115 | if (position === 0) list.shift() |
| 116 | else { |
| 117 | list.splice(position, 1) |
| 118 | } |
| 119 | |
| 120 | if (list.length === 1) this.events[type] = list[0] |
| 121 | } |
| 122 | |
| 123 | return this |
| 124 | } |
| 125 | |
| 126 | once(type: string | number, listener: Listener, prepend = false): this { |
| 127 | const wrapper = (...args: any[]) => { |
no outgoing calls
no test coverage detected