More protobufjs migration

This commit is contained in:
Fedor Indutny 2021-07-09 12:36:10 -07:00 committed by GitHub
parent cf06e6638e
commit ddbbe3a6b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 3967 additions and 3369 deletions

View file

@ -12,8 +12,10 @@
* https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
*/
export type EventHandler = (event: any) => unknown;
export default class EventTarget {
listeners?: { [type: string]: Array<Function> };
listeners?: { [type: string]: Array<EventHandler> };
dispatchEvent(ev: Event): Array<unknown> {
if (!(ev instanceof Event)) {
@ -36,7 +38,7 @@ export default class EventTarget {
return results;
}
addEventListener(eventName: string, callback: Function): void {
addEventListener(eventName: string, callback: EventHandler): void {
if (typeof eventName !== 'string') {
throw new Error('First argument expects a string');
}
@ -54,7 +56,7 @@ export default class EventTarget {
this.listeners[eventName] = listeners;
}
removeEventListener(eventName: string, callback: Function): void {
removeEventListener(eventName: string, callback: EventHandler): void {
if (typeof eventName !== 'string') {
throw new Error('First argument expects a string');
}