@inweb/eventemitter2 25.7.0 → 25.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
1
+ Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
2
2
  All rights reserved.
3
3
 
4
4
  This software and its documentation and related materials are owned by
@@ -13,7 +13,7 @@ with their copyright notices:
13
13
 
14
14
  This application incorporates Open Design Alliance software pursuant to a
15
15
  license agreement with Open Design Alliance.
16
- Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
16
+ Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
17
17
  All rights reserved.
18
18
 
19
19
  By use of this software, its documentation or related materials, you
@@ -5,7 +5,7 @@
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  ///////////////////////////////////////////////////////////////////////////////
8
- // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
8
+ // Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
9
9
  // All rights reserved.
10
10
  //
11
11
  // This software and its documentation and related materials are owned by
@@ -20,7 +20,7 @@
20
20
  //
21
21
  // This application incorporates Open Design Alliance software pursuant to a
22
22
  // license agreement with Open Design Alliance.
23
- // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
23
+ // Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
24
24
  // All rights reserved.
25
25
  //
26
26
  // By use of this software, its documentation or related materials, you
@@ -33,24 +33,12 @@
33
33
  constructor() {
34
34
  this._listeners = {};
35
35
  }
36
- /**
37
- * Registers a new listener for an event type.
38
- *
39
- * @param type - The type of event to listen to.
40
- * @param listener - The function that gets called when the event is fired.
41
- */
42
36
  addEventListener(type, listener) {
43
37
  if (this._listeners[type] === undefined)
44
38
  this._listeners[type] = [];
45
39
  this._listeners[type].push(listener);
46
40
  return this;
47
41
  }
48
- /**
49
- * Removes the listener from an event type.
50
- *
51
- * @param type - The type of the listener that gets removed.
52
- * @param listener - The listener function that gets removed.
53
- */
54
42
  removeEventListener(type, listener) {
55
43
  if (this._listeners[type] === undefined)
56
44
  return this;
@@ -61,12 +49,6 @@
61
49
  delete this._listeners[type];
62
50
  return this;
63
51
  }
64
- /**
65
- * If `type` is specified, removes all registered listeners for type, otherwise removes all
66
- * registered listeners.
67
- *
68
- * @param type - The type of the listener that gets removed.
69
- */
70
52
  removeAllListeners(type) {
71
53
  if (type)
72
54
  delete this._listeners[type];
@@ -74,12 +56,6 @@
74
56
  this._listeners = {};
75
57
  return this;
76
58
  }
77
- /**
78
- * Fires the event. Calls each of the listeners registered for the event type `event.type`,
79
- * in the order they were registered.
80
- *
81
- * @param event - The event that gets fired.
82
- */
83
59
  emitEvent(event) {
84
60
  if (this._listeners[event.type] === undefined)
85
61
  return false;
@@ -87,27 +63,17 @@
87
63
  invoke.forEach((listener) => listener.call(this, event));
88
64
  return true;
89
65
  }
90
- // Node.js style, to emit custom events
91
- /**
92
- * Alias to {@link EventEmitter2.addEventListener()}
93
- */
94
66
  on(type, listener) {
95
67
  return this.addEventListener(type, listener);
96
68
  }
97
- /**
98
- * Alias to {@link EventEmitter2.removeEventListener()}.
99
- */
100
69
  off(type, listener) {
101
70
  return this.removeEventListener(type, listener);
102
71
  }
103
- /**
104
- * Alias to {@link EventEmitter2.emitEvent()}.
105
- */
106
- emit(event, ...args) {
107
- if (typeof event === "string")
108
- return this.emitEvent({ type: event, args });
109
- else if (typeof event === "object")
110
- return this.emitEvent(event);
72
+ emit(type, ...args) {
73
+ if (typeof type === "string")
74
+ return this.emitEvent({ type, args });
75
+ else if (typeof type === "object")
76
+ return this.emitEvent(type);
111
77
  else
112
78
  return false;
113
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eventemitter2.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2021, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nexport interface IEvent {\n type: string;\n}\n\nexport interface IEventEmitter {\n addEventListener(type: string, listener: (event: IEvent) => void): this;\n removeEventListener(type: string, listener: (event: IEvent) => void): this;\n removeAllListeners(type?: string): this;\n emitEvent(event: IEvent): boolean;\n on(type: string, listener: (event: any) => void): this;\n off(type: string, listener: (event: any) => void): this;\n emit(event: string | object, ...args: any[]): boolean;\n}\n\n/**\n * The minimal basic Event that can be emitted by a {@link EventEmitter2}.\n */\nexport interface Event<T extends string = string> extends IEvent {\n type: T;\n}\n\n/**\n * Event emitter for custom objects.\n */\nexport class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {\n private _listeners: Record<any, any[]> = {};\n\n /**\n * Registers a new listener for an event type.\n *\n * @param type - The type of event to listen to.\n * @param listener - The function that gets called when the event is fired.\n */\n addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) this._listeners[type] = [];\n this._listeners[type].push(listener);\n return this;\n }\n\n /**\n * Removes the listener from an event type.\n *\n * @param type - The type of the listener that gets removed.\n * @param listener - The listener function that gets removed.\n */\n removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) return this;\n const listeners = this._listeners[type].filter((x: any) => x !== listener);\n if (listeners.length !== 0) this._listeners[type] = listeners;\n else delete this._listeners[type];\n return this;\n }\n\n /**\n * If `type` is specified, removes all registered listeners for type, otherwise removes all\n * registered listeners.\n *\n * @param type - The type of the listener that gets removed.\n */\n removeAllListeners<T extends keyof EventMap>(type?: T): this {\n if (type) delete this._listeners[type];\n else this._listeners = {};\n return this;\n }\n\n /**\n * Fires the event. Calls each of the listeners registered for the event type `event.type`,\n * in the order they were registered.\n *\n * @param event - The event that gets fired.\n */\n emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean {\n if (this._listeners[event.type] === undefined) return false;\n const invoke = this._listeners[event.type].slice();\n invoke.forEach((listener: any) => listener.call(this, event));\n return true;\n }\n\n // Node.js style, to emit custom events\n\n /**\n * Alias to {@link EventEmitter2.addEventListener()}\n */\n on(type: string, listener: (event: any) => void): this {\n return this.addEventListener(type as any, listener as any);\n }\n\n /**\n * Alias to {@link EventEmitter2.removeEventListener()}.\n */\n off(type: string, listener: (event: any) => void): this {\n return this.removeEventListener(type as any, listener as any);\n }\n\n /**\n * Alias to {@link EventEmitter2.emitEvent()}.\n */\n emit(event: string | object, ...args: any[]): boolean {\n if (typeof event === \"string\") return this.emitEvent({ type: event, args } as any);\n else if (typeof event === \"object\") return this.emitEvent(event as any);\n else return false;\n }\n}\n"],"names":[],"mappings":";;;;;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAuBA;;IAEG;UACU,aAAa,CAAA;IAA1B,IAAA,WAAA,GAAA;YACU,IAAU,CAAA,UAAA,GAAuB,EAAE,CAAC;SA6E7C;IA3EC;;;;;IAKG;QACH,gBAAgB,CAA2B,IAAO,EAAE,QAAsC,EAAA;IACxF,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACpE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,QAAA,OAAO,IAAI,CAAC;SACb;IAED;;;;;IAKG;QACH,mBAAmB,CAA2B,IAAO,EAAE,QAAsC,EAAA;IAC3F,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,IAAI,CAAC;YACrD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC3E,QAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;IAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;;IACzD,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,QAAA,OAAO,IAAI,CAAC;SACb;IAED;;;;;IAKG;IACH,IAAA,kBAAkB,CAA2B,IAAQ,EAAA;IACnD,QAAA,IAAI,IAAI;IAAE,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;;IAClC,YAAA,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IAC1B,QAAA,OAAO,IAAI,CAAC;SACb;IAED;;;;;IAKG;IACH,IAAA,SAAS,CAA2B,KAA8C,EAAA;YAChF,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,KAAK,CAAC;IAC5D,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IACnD,QAAA,MAAM,CAAC,OAAO,CAAC,CAAC,QAAa,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9D,QAAA,OAAO,IAAI,CAAC;SACb;;IAID;;IAEG;QACH,EAAE,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAW,EAAE,QAAe,CAAC,CAAC;SAC5D;IAED;;IAEG;QACH,GAAG,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC9C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAW,EAAE,QAAe,CAAC,CAAC;SAC/D;IAED;;IAEG;IACH,IAAA,IAAI,CAAC,KAAsB,EAAE,GAAG,IAAW,EAAA;YACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;IAAE,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAS,CAAC,CAAC;iBAC9E,IAAI,OAAO,KAAK,KAAK,QAAQ;IAAE,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,KAAY,CAAC,CAAC;;IACnE,YAAA,OAAO,KAAK,CAAC;SACnB;IACF;;;;;;;;;;"}
1
+ {"version":3,"file":"eventemitter2.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2024, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * The event interface for {@link IEventEmitter}.\n */\nexport interface IEvent {\n /**\n * Event type.\n */\n type: string;\n}\n\n/**\n * Event emitter interface.\n */\nexport interface IEventEmitter {\n /**\n * Registers a new listener for an event type.\n *\n * @param type - The type of event to listen to.\n * @param listener - The function that gets called when the event is fired.\n */\n addEventListener(type: string, listener: (event: IEvent) => void): this;\n\n /**\n * Removes the listener from an event type.\n *\n * @param type - The type of the event that gets removed.\n * @param listener - The listener function that gets removed.\n */\n removeEventListener(type: string, listener: (event: IEvent) => void): this;\n\n /**\n * If `type` is specified, removes all registered listeners for type, otherwise removes all\n * registered listeners.\n *\n * @param type - The type of the listener that gets removed.\n */\n removeAllListeners(type?: string): this;\n\n /**\n * Fires the event. Calls each of the listeners registered for the event type `event.type`,\n * in the order they were registered.\n *\n * @param event - The event that gets fired.\n */\n emitEvent(event: IEvent): boolean;\n\n // Node.js style, to emit custom eventsg\n\n /**\n * Registers a new listener for an event type. Alias to {@link addEventListener | addEventListener()}\n *\n * @param type - The type of event to listen to.\n * @param listener - The function that gets called when the event is fired.\n */\n on(type: string, listener: (event: any) => void): this;\n\n /**\n * Removes the listener from an event type. Alias to\n * {@link removeEventListener | removeEventListener()}.\n *\n * @param type - The type of the event that gets removed.\n * @param listener - The listener function that gets removed.\n */\n off(type: string, listener: (event: any) => void): this;\n\n /**\n * Fires the event. Alias to {@link emitEvent | emitEvent()}.\n *\n * @param type - The type of event that gets fired.\n * @param args - The event properties.\n */\n emit(type: string | object, ...args: any[]): boolean;\n}\n\n/**\n * The minimal basic event that can be emitted by a {@link EventEmitter2}.\n */\nexport interface Event<T extends string = string> extends IEvent {\n /**\n * Event type.\n */\n type: T;\n}\n\n/**\n * Event emitter for custom objects.\n */\nexport class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {\n private _listeners: Record<any, any[]> = {};\n\n addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) this._listeners[type] = [];\n this._listeners[type].push(listener);\n return this;\n }\n\n removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) return this;\n const listeners = this._listeners[type].filter((x: any) => x !== listener);\n if (listeners.length !== 0) this._listeners[type] = listeners;\n else delete this._listeners[type];\n return this;\n }\n\n removeAllListeners<T extends keyof EventMap>(type?: T): this {\n if (type) delete this._listeners[type];\n else this._listeners = {};\n return this;\n }\n\n emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean {\n if (this._listeners[event.type] === undefined) return false;\n const invoke = this._listeners[event.type].slice();\n invoke.forEach((listener: any) => listener.call(this, event));\n return true;\n }\n\n on(type: string, listener: (event: any) => void): this {\n return this.addEventListener(type as any, listener as any);\n }\n\n off(type: string, listener: (event: any) => void): this {\n return this.removeEventListener(type as any, listener as any);\n }\n\n emit(type: string | object, ...args: any[]): boolean {\n if (typeof type === \"string\") return this.emitEvent({ type, args } as any);\n else if (typeof type === \"object\") return this.emitEvent(type as any);\n else return false;\n }\n}\n"],"names":[],"mappings":";;;;;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAsFA;;IAEG;UACU,aAAa,CAAA;IAA1B,IAAA,WAAA,GAAA;YACU,IAAU,CAAA,UAAA,GAAuB,EAAE,CAAC;SA0C7C;QAxCC,gBAAgB,CAA2B,IAAO,EAAE,QAAsC,EAAA;IACxF,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACpE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,QAAA,OAAO,IAAI,CAAC;SACb;QAED,mBAAmB,CAA2B,IAAO,EAAE,QAAsC,EAAA;IAC3F,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,IAAI,CAAC;YACrD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC;IAC3E,QAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;IAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;;IACzD,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,QAAA,OAAO,IAAI,CAAC;SACb;IAED,IAAA,kBAAkB,CAA2B,IAAQ,EAAA;IACnD,QAAA,IAAI,IAAI;IAAE,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;;IAClC,YAAA,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IAC1B,QAAA,OAAO,IAAI,CAAC;SACb;IAED,IAAA,SAAS,CAA2B,KAA8C,EAAA;YAChF,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,KAAK,CAAC;IAC5D,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IACnD,QAAA,MAAM,CAAC,OAAO,CAAC,CAAC,QAAa,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9D,QAAA,OAAO,IAAI,CAAC;SACb;QAED,EAAE,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAW,EAAE,QAAe,CAAC,CAAC;SAC5D;QAED,GAAG,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC9C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAW,EAAE,QAAe,CAAC,CAAC;SAC/D;IAED,IAAA,IAAI,CAAC,IAAqB,EAAE,GAAG,IAAW,EAAA;YACxC,IAAI,OAAO,IAAI,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAS,CAAC,CAAC;iBACtE,IAAI,OAAO,IAAI,KAAK,QAAQ;IAAE,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAW,CAAC,CAAC;;IACjE,YAAA,OAAO,KAAK,CAAC;SACnB;IACF;;;;;;;;;;"}
@@ -29,11 +29,11 @@ class EventEmitter2 {
29
29
  off(type, listener) {
30
30
  return this.removeEventListener(type, listener);
31
31
  }
32
- emit(event, ...args) {
33
- if (typeof event === "string") return this.emitEvent({
34
- type: event,
32
+ emit(type, ...args) {
33
+ if (typeof type === "string") return this.emitEvent({
34
+ type: type,
35
35
  args: args
36
- }); else if (typeof event === "object") return this.emitEvent(event); else return false;
36
+ }); else if (typeof type === "object") return this.emitEvent(type); else return false;
37
37
  }
38
38
  }
39
39
 
@@ -1 +1 @@
1
- {"version":3,"file":"eventemitter2.module.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2021, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nexport interface IEvent {\n type: string;\n}\n\nexport interface IEventEmitter {\n addEventListener(type: string, listener: (event: IEvent) => void): this;\n removeEventListener(type: string, listener: (event: IEvent) => void): this;\n removeAllListeners(type?: string): this;\n emitEvent(event: IEvent): boolean;\n on(type: string, listener: (event: any) => void): this;\n off(type: string, listener: (event: any) => void): this;\n emit(event: string | object, ...args: any[]): boolean;\n}\n\n/**\n * The minimal basic Event that can be emitted by a {@link EventEmitter2}.\n */\nexport interface Event<T extends string = string> extends IEvent {\n type: T;\n}\n\n/**\n * Event emitter for custom objects.\n */\nexport class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {\n private _listeners: Record<any, any[]> = {};\n\n /**\n * Registers a new listener for an event type.\n *\n * @param type - The type of event to listen to.\n * @param listener - The function that gets called when the event is fired.\n */\n addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) this._listeners[type] = [];\n this._listeners[type].push(listener);\n return this;\n }\n\n /**\n * Removes the listener from an event type.\n *\n * @param type - The type of the listener that gets removed.\n * @param listener - The listener function that gets removed.\n */\n removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) return this;\n const listeners = this._listeners[type].filter((x: any) => x !== listener);\n if (listeners.length !== 0) this._listeners[type] = listeners;\n else delete this._listeners[type];\n return this;\n }\n\n /**\n * If `type` is specified, removes all registered listeners for type, otherwise removes all\n * registered listeners.\n *\n * @param type - The type of the listener that gets removed.\n */\n removeAllListeners<T extends keyof EventMap>(type?: T): this {\n if (type) delete this._listeners[type];\n else this._listeners = {};\n return this;\n }\n\n /**\n * Fires the event. Calls each of the listeners registered for the event type `event.type`,\n * in the order they were registered.\n *\n * @param event - The event that gets fired.\n */\n emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean {\n if (this._listeners[event.type] === undefined) return false;\n const invoke = this._listeners[event.type].slice();\n invoke.forEach((listener: any) => listener.call(this, event));\n return true;\n }\n\n // Node.js style, to emit custom events\n\n /**\n * Alias to {@link EventEmitter2.addEventListener()}\n */\n on(type: string, listener: (event: any) => void): this {\n return this.addEventListener(type as any, listener as any);\n }\n\n /**\n * Alias to {@link EventEmitter2.removeEventListener()}.\n */\n off(type: string, listener: (event: any) => void): this {\n return this.removeEventListener(type as any, listener as any);\n }\n\n /**\n * Alias to {@link EventEmitter2.emitEvent()}.\n */\n emit(event: string | object, ...args: any[]): boolean {\n if (typeof event === \"string\") return this.emitEvent({ type: event, args } as any);\n else if (typeof event === \"object\") return this.emitEvent(event as any);\n else return false;\n }\n}\n"],"names":["EventEmitter2","constructor","this","_listeners","addEventListener","type","listener","undefined","push","removeEventListener","listeners","filter","x","length","removeAllListeners","emitEvent","event","invoke","slice","forEach","call","on","off","emit","args"],"mappings":"MA+CaA;IAAb,WAAAC;QACUC,KAAUC,aAAuB;AA6E1C;IArEC,gBAAAC,CAA2CC,MAASC;QAClD,IAAIJ,KAAKC,WAAWE,UAAUE,WAAWL,KAAKC,WAAWE,QAAQ;QACjEH,KAAKC,WAAWE,MAAMG,KAAKF;QAC3B,OAAOJ;AACR;IAQD,mBAAAO,CAA8CJ,MAASC;QACrD,IAAIJ,KAAKC,WAAWE,UAAUE,WAAW,OAAOL;QAChD,MAAMQ,YAAYR,KAAKC,WAAWE,MAAMM,QAAQC,KAAWA,MAAMN;QACjE,IAAII,UAAUG,WAAW,GAAGX,KAAKC,WAAWE,QAAQK,uBACxCR,KAAKC,WAAWE;QAC5B,OAAOH;AACR;IAQD,kBAAAY,CAA6CT;QAC3C,IAAIA,aAAaH,KAAKC,WAAWE,YAC5BH,KAAKC,aAAa;QACvB,OAAOD;AACR;IAQD,SAAAa,CAAoCC;QAClC,IAAId,KAAKC,WAAWa,MAAMX,UAAUE,WAAW,OAAO;QACtD,MAAMU,SAASf,KAAKC,WAAWa,MAAMX,MAAMa;QAC3CD,OAAOE,SAASb,YAAkBA,SAASc,KAAKlB,MAAMc;QACtD,OAAO;AACR;IAOD,EAAAK,CAAGhB,MAAcC;QACf,OAAOJ,KAAKE,iBAAiBC,MAAaC;AAC3C;IAKD,GAAAgB,CAAIjB,MAAcC;QAChB,OAAOJ,KAAKO,oBAAoBJ,MAAaC;AAC9C;IAKD,IAAAiB,CAAKP,UAA2BQ;QAC9B,WAAWR,UAAU,UAAU,OAAOd,KAAKa,UAAU;YAAEV,MAAMW;YAAOQ;iBAC/D,WAAWR,UAAU,UAAU,OAAOd,KAAKa,UAAUC,aACrD,OAAO;AACb;;;"}
1
+ {"version":3,"file":"eventemitter2.module.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2024, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * The event interface for {@link IEventEmitter}.\n */\nexport interface IEvent {\n /**\n * Event type.\n */\n type: string;\n}\n\n/**\n * Event emitter interface.\n */\nexport interface IEventEmitter {\n /**\n * Registers a new listener for an event type.\n *\n * @param type - The type of event to listen to.\n * @param listener - The function that gets called when the event is fired.\n */\n addEventListener(type: string, listener: (event: IEvent) => void): this;\n\n /**\n * Removes the listener from an event type.\n *\n * @param type - The type of the event that gets removed.\n * @param listener - The listener function that gets removed.\n */\n removeEventListener(type: string, listener: (event: IEvent) => void): this;\n\n /**\n * If `type` is specified, removes all registered listeners for type, otherwise removes all\n * registered listeners.\n *\n * @param type - The type of the listener that gets removed.\n */\n removeAllListeners(type?: string): this;\n\n /**\n * Fires the event. Calls each of the listeners registered for the event type `event.type`,\n * in the order they were registered.\n *\n * @param event - The event that gets fired.\n */\n emitEvent(event: IEvent): boolean;\n\n // Node.js style, to emit custom eventsg\n\n /**\n * Registers a new listener for an event type. Alias to {@link addEventListener | addEventListener()}\n *\n * @param type - The type of event to listen to.\n * @param listener - The function that gets called when the event is fired.\n */\n on(type: string, listener: (event: any) => void): this;\n\n /**\n * Removes the listener from an event type. Alias to\n * {@link removeEventListener | removeEventListener()}.\n *\n * @param type - The type of the event that gets removed.\n * @param listener - The listener function that gets removed.\n */\n off(type: string, listener: (event: any) => void): this;\n\n /**\n * Fires the event. Alias to {@link emitEvent | emitEvent()}.\n *\n * @param type - The type of event that gets fired.\n * @param args - The event properties.\n */\n emit(type: string | object, ...args: any[]): boolean;\n}\n\n/**\n * The minimal basic event that can be emitted by a {@link EventEmitter2}.\n */\nexport interface Event<T extends string = string> extends IEvent {\n /**\n * Event type.\n */\n type: T;\n}\n\n/**\n * Event emitter for custom objects.\n */\nexport class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {\n private _listeners: Record<any, any[]> = {};\n\n addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) this._listeners[type] = [];\n this._listeners[type].push(listener);\n return this;\n }\n\n removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {\n if (this._listeners[type] === undefined) return this;\n const listeners = this._listeners[type].filter((x: any) => x !== listener);\n if (listeners.length !== 0) this._listeners[type] = listeners;\n else delete this._listeners[type];\n return this;\n }\n\n removeAllListeners<T extends keyof EventMap>(type?: T): this {\n if (type) delete this._listeners[type];\n else this._listeners = {};\n return this;\n }\n\n emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean {\n if (this._listeners[event.type] === undefined) return false;\n const invoke = this._listeners[event.type].slice();\n invoke.forEach((listener: any) => listener.call(this, event));\n return true;\n }\n\n on(type: string, listener: (event: any) => void): this {\n return this.addEventListener(type as any, listener as any);\n }\n\n off(type: string, listener: (event: any) => void): this {\n return this.removeEventListener(type as any, listener as any);\n }\n\n emit(type: string | object, ...args: any[]): boolean {\n if (typeof type === \"string\") return this.emitEvent({ type, args } as any);\n else if (typeof type === \"object\") return this.emitEvent(type as any);\n else return false;\n }\n}\n"],"names":["EventEmitter2","constructor","this","_listeners","addEventListener","type","listener","undefined","push","removeEventListener","listeners","filter","x","length","removeAllListeners","emitEvent","event","invoke","slice","forEach","call","on","off","emit","args"],"mappings":"MA8GaA;IAAb,WAAAC;QACUC,KAAUC,aAAuB;AA0C1C;IAxCC,gBAAAC,CAA2CC,MAASC;QAClD,IAAIJ,KAAKC,WAAWE,UAAUE,WAAWL,KAAKC,WAAWE,QAAQ;QACjEH,KAAKC,WAAWE,MAAMG,KAAKF;QAC3B,OAAOJ;AACR;IAED,mBAAAO,CAA8CJ,MAASC;QACrD,IAAIJ,KAAKC,WAAWE,UAAUE,WAAW,OAAOL;QAChD,MAAMQ,YAAYR,KAAKC,WAAWE,MAAMM,QAAQC,KAAWA,MAAMN;QACjE,IAAII,UAAUG,WAAW,GAAGX,KAAKC,WAAWE,QAAQK,uBACxCR,KAAKC,WAAWE;QAC5B,OAAOH;AACR;IAED,kBAAAY,CAA6CT;QAC3C,IAAIA,aAAaH,KAAKC,WAAWE,YAC5BH,KAAKC,aAAa;QACvB,OAAOD;AACR;IAED,SAAAa,CAAoCC;QAClC,IAAId,KAAKC,WAAWa,MAAMX,UAAUE,WAAW,OAAO;QACtD,MAAMU,SAASf,KAAKC,WAAWa,MAAMX,MAAMa;QAC3CD,OAAOE,SAASb,YAAkBA,SAASc,KAAKlB,MAAMc;QACtD,OAAO;AACR;IAED,EAAAK,CAAGhB,MAAcC;QACf,OAAOJ,KAAKE,iBAAiBC,MAAaC;AAC3C;IAED,GAAAgB,CAAIjB,MAAcC;QAChB,OAAOJ,KAAKO,oBAAoBJ,MAAaC;AAC9C;IAED,IAAAiB,CAAKlB,SAA0BmB;QAC7B,WAAWnB,SAAS,UAAU,OAAOH,KAAKa,UAAU;YAAEV;YAAMmB;iBACvD,WAAWnB,SAAS,UAAU,OAAOH,KAAKa,UAAUV,YACpD,OAAO;AACb;;;"}
package/lib/index.d.ts CHANGED
@@ -1,64 +1,86 @@
1
- export interface IEvent {
2
- type: string;
3
- }
4
- export interface IEventEmitter {
5
- addEventListener(type: string, listener: (event: IEvent) => void): this;
6
- removeEventListener(type: string, listener: (event: IEvent) => void): this;
7
- removeAllListeners(type?: string): this;
8
- emitEvent(event: IEvent): boolean;
9
- on(type: string, listener: (event: any) => void): this;
10
- off(type: string, listener: (event: any) => void): this;
11
- emit(event: string | object, ...args: any[]): boolean;
12
- }
13
1
  /**
14
- * The minimal basic Event that can be emitted by a {@link EventEmitter2}.
2
+ * The event interface for {@link IEventEmitter}.
15
3
  */
16
- export interface Event<T extends string = string> extends IEvent {
17
- type: T;
4
+ export interface IEvent {
5
+ /**
6
+ * Event type.
7
+ */
8
+ type: string;
18
9
  }
19
10
  /**
20
- * Event emitter for custom objects.
11
+ * Event emitter interface.
21
12
  */
22
- export declare class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {
23
- private _listeners;
13
+ export interface IEventEmitter {
24
14
  /**
25
15
  * Registers a new listener for an event type.
26
16
  *
27
17
  * @param type - The type of event to listen to.
28
18
  * @param listener - The function that gets called when the event is fired.
29
19
  */
30
- addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this;
20
+ addEventListener(type: string, listener: (event: IEvent) => void): this;
31
21
  /**
32
22
  * Removes the listener from an event type.
33
23
  *
34
- * @param type - The type of the listener that gets removed.
24
+ * @param type - The type of the event that gets removed.
35
25
  * @param listener - The listener function that gets removed.
36
26
  */
37
- removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this;
27
+ removeEventListener(type: string, listener: (event: IEvent) => void): this;
38
28
  /**
39
29
  * If `type` is specified, removes all registered listeners for type, otherwise removes all
40
30
  * registered listeners.
41
31
  *
42
32
  * @param type - The type of the listener that gets removed.
43
33
  */
44
- removeAllListeners<T extends keyof EventMap>(type?: T): this;
34
+ removeAllListeners(type?: string): this;
45
35
  /**
46
36
  * Fires the event. Calls each of the listeners registered for the event type `event.type`,
47
37
  * in the order they were registered.
48
38
  *
49
39
  * @param event - The event that gets fired.
50
40
  */
51
- emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean;
41
+ emitEvent(event: IEvent): boolean;
52
42
  /**
53
- * Alias to {@link EventEmitter2.addEventListener()}
43
+ * Registers a new listener for an event type. Alias to {@link addEventListener | addEventListener()}
44
+ *
45
+ * @param type - The type of event to listen to.
46
+ * @param listener - The function that gets called when the event is fired.
54
47
  */
55
48
  on(type: string, listener: (event: any) => void): this;
56
49
  /**
57
- * Alias to {@link EventEmitter2.removeEventListener()}.
50
+ * Removes the listener from an event type. Alias to
51
+ * {@link removeEventListener | removeEventListener()}.
52
+ *
53
+ * @param type - The type of the event that gets removed.
54
+ * @param listener - The listener function that gets removed.
58
55
  */
59
56
  off(type: string, listener: (event: any) => void): this;
60
57
  /**
61
- * Alias to {@link EventEmitter2.emitEvent()}.
58
+ * Fires the event. Alias to {@link emitEvent | emitEvent()}.
59
+ *
60
+ * @param type - The type of event that gets fired.
61
+ * @param args - The event properties.
62
+ */
63
+ emit(type: string | object, ...args: any[]): boolean;
64
+ }
65
+ /**
66
+ * The minimal basic event that can be emitted by a {@link EventEmitter2}.
67
+ */
68
+ export interface Event<T extends string = string> extends IEvent {
69
+ /**
70
+ * Event type.
62
71
  */
63
- emit(event: string | object, ...args: any[]): boolean;
72
+ type: T;
73
+ }
74
+ /**
75
+ * Event emitter for custom objects.
76
+ */
77
+ export declare class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {
78
+ private _listeners;
79
+ addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this;
80
+ removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this;
81
+ removeAllListeners<T extends keyof EventMap>(type?: T): this;
82
+ emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean;
83
+ on(type: string, listener: (event: any) => void): this;
84
+ off(type: string, listener: (event: any) => void): this;
85
+ emit(type: string | object, ...args: any[]): boolean;
64
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/eventemitter2",
3
- "version": "25.7.0",
3
+ "version": "25.7.1",
4
4
  "description": "JavaScript event emitter",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
2
+ // Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3
3
  // All rights reserved.
4
4
  //
5
5
  // This software and its documentation and related materials are owned by
@@ -14,31 +14,94 @@
14
14
  //
15
15
  // This application incorporates Open Design Alliance software pursuant to a
16
16
  // license agreement with Open Design Alliance.
17
- // Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18
18
  // All rights reserved.
19
19
  //
20
20
  // By use of this software, its documentation or related materials, you
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
+ /**
25
+ * The event interface for {@link IEventEmitter}.
26
+ */
24
27
  export interface IEvent {
28
+ /**
29
+ * Event type.
30
+ */
25
31
  type: string;
26
32
  }
27
33
 
34
+ /**
35
+ * Event emitter interface.
36
+ */
28
37
  export interface IEventEmitter {
38
+ /**
39
+ * Registers a new listener for an event type.
40
+ *
41
+ * @param type - The type of event to listen to.
42
+ * @param listener - The function that gets called when the event is fired.
43
+ */
29
44
  addEventListener(type: string, listener: (event: IEvent) => void): this;
45
+
46
+ /**
47
+ * Removes the listener from an event type.
48
+ *
49
+ * @param type - The type of the event that gets removed.
50
+ * @param listener - The listener function that gets removed.
51
+ */
30
52
  removeEventListener(type: string, listener: (event: IEvent) => void): this;
53
+
54
+ /**
55
+ * If `type` is specified, removes all registered listeners for type, otherwise removes all
56
+ * registered listeners.
57
+ *
58
+ * @param type - The type of the listener that gets removed.
59
+ */
31
60
  removeAllListeners(type?: string): this;
61
+
62
+ /**
63
+ * Fires the event. Calls each of the listeners registered for the event type `event.type`,
64
+ * in the order they were registered.
65
+ *
66
+ * @param event - The event that gets fired.
67
+ */
32
68
  emitEvent(event: IEvent): boolean;
69
+
70
+ // Node.js style, to emit custom eventsg
71
+
72
+ /**
73
+ * Registers a new listener for an event type. Alias to {@link addEventListener | addEventListener()}
74
+ *
75
+ * @param type - The type of event to listen to.
76
+ * @param listener - The function that gets called when the event is fired.
77
+ */
33
78
  on(type: string, listener: (event: any) => void): this;
79
+
80
+ /**
81
+ * Removes the listener from an event type. Alias to
82
+ * {@link removeEventListener | removeEventListener()}.
83
+ *
84
+ * @param type - The type of the event that gets removed.
85
+ * @param listener - The listener function that gets removed.
86
+ */
34
87
  off(type: string, listener: (event: any) => void): this;
35
- emit(event: string | object, ...args: any[]): boolean;
88
+
89
+ /**
90
+ * Fires the event. Alias to {@link emitEvent | emitEvent()}.
91
+ *
92
+ * @param type - The type of event that gets fired.
93
+ * @param args - The event properties.
94
+ */
95
+ emit(type: string | object, ...args: any[]): boolean;
36
96
  }
37
97
 
38
98
  /**
39
- * The minimal basic Event that can be emitted by a {@link EventEmitter2}.
99
+ * The minimal basic event that can be emitted by a {@link EventEmitter2}.
40
100
  */
41
101
  export interface Event<T extends string = string> extends IEvent {
102
+ /**
103
+ * Event type.
104
+ */
42
105
  type: T;
43
106
  }
44
107
 
@@ -48,24 +111,12 @@ export interface Event<T extends string = string> extends IEvent {
48
111
  export class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {
49
112
  private _listeners: Record<any, any[]> = {};
50
113
 
51
- /**
52
- * Registers a new listener for an event type.
53
- *
54
- * @param type - The type of event to listen to.
55
- * @param listener - The function that gets called when the event is fired.
56
- */
57
114
  addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {
58
115
  if (this._listeners[type] === undefined) this._listeners[type] = [];
59
116
  this._listeners[type].push(listener);
60
117
  return this;
61
118
  }
62
119
 
63
- /**
64
- * Removes the listener from an event type.
65
- *
66
- * @param type - The type of the listener that gets removed.
67
- * @param listener - The listener function that gets removed.
68
- */
69
120
  removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {
70
121
  if (this._listeners[type] === undefined) return this;
71
122
  const listeners = this._listeners[type].filter((x: any) => x !== listener);
@@ -74,24 +125,12 @@ export class EventEmitter2<EventMap extends Record<string, any> = Record<string,
74
125
  return this;
75
126
  }
76
127
 
77
- /**
78
- * If `type` is specified, removes all registered listeners for type, otherwise removes all
79
- * registered listeners.
80
- *
81
- * @param type - The type of the listener that gets removed.
82
- */
83
128
  removeAllListeners<T extends keyof EventMap>(type?: T): this {
84
129
  if (type) delete this._listeners[type];
85
130
  else this._listeners = {};
86
131
  return this;
87
132
  }
88
133
 
89
- /**
90
- * Fires the event. Calls each of the listeners registered for the event type `event.type`,
91
- * in the order they were registered.
92
- *
93
- * @param event - The event that gets fired.
94
- */
95
134
  emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean {
96
135
  if (this._listeners[event.type] === undefined) return false;
97
136
  const invoke = this._listeners[event.type].slice();
@@ -99,28 +138,17 @@ export class EventEmitter2<EventMap extends Record<string, any> = Record<string,
99
138
  return true;
100
139
  }
101
140
 
102
- // Node.js style, to emit custom events
103
-
104
- /**
105
- * Alias to {@link EventEmitter2.addEventListener()}
106
- */
107
141
  on(type: string, listener: (event: any) => void): this {
108
142
  return this.addEventListener(type as any, listener as any);
109
143
  }
110
144
 
111
- /**
112
- * Alias to {@link EventEmitter2.removeEventListener()}.
113
- */
114
145
  off(type: string, listener: (event: any) => void): this {
115
146
  return this.removeEventListener(type as any, listener as any);
116
147
  }
117
148
 
118
- /**
119
- * Alias to {@link EventEmitter2.emitEvent()}.
120
- */
121
- emit(event: string | object, ...args: any[]): boolean {
122
- if (typeof event === "string") return this.emitEvent({ type: event, args } as any);
123
- else if (typeof event === "object") return this.emitEvent(event as any);
149
+ emit(type: string | object, ...args: any[]): boolean {
150
+ if (typeof type === "string") return this.emitEvent({ type, args } as any);
151
+ else if (typeof type === "object") return this.emitEvent(type as any);
124
152
  else return false;
125
153
  }
126
154
  }