@inweb/eventemitter2 26.9.2 → 26.9.4

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.
@@ -1,34 +1,32 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
1
24
  (function (global, factory) {
2
25
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
26
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
27
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ODA = global.ODA || {}));
5
28
  })(this, (function (exports) { 'use strict';
6
29
 
7
- ///////////////////////////////////////////////////////////////////////////////
8
- // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
9
- // All rights reserved.
10
- //
11
- // This software and its documentation and related materials are owned by
12
- // the Alliance. The software may only be incorporated into application
13
- // programs owned by members of the Alliance, subject to a signed
14
- // Membership Agreement and Supplemental Software License Agreement with the
15
- // Alliance. The structure and organization of this software are the valuable
16
- // trade secrets of the Alliance and its suppliers. The software is also
17
- // protected by copyright law and international treaty provisions. Application
18
- // programs incorporating this software must include the following statement
19
- // with their copyright notices:
20
- //
21
- // This application incorporates Open Design Alliance software pursuant to a
22
- // license agreement with Open Design Alliance.
23
- // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
24
- // All rights reserved.
25
- //
26
- // By use of this software, its documentation or related materials, you
27
- // acknowledge and accept the above terms.
28
- ///////////////////////////////////////////////////////////////////////////////
29
- /**
30
- * Event emitter for custom objects.
31
- */
32
30
  class EventEmitter2 {
33
31
  constructor() {
34
32
  this._listeners = {};
@@ -1 +1 @@
1
- {"version":3,"file":"eventemitter2.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, 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-2025 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 the 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 for the 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 registered\n * 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`, in the\n * 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 the 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;;QAE3C,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;YACnE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACpC,QAAA,OAAO,IAAI;;QAGb,mBAAmB,CAA2B,IAAO,EAAE,QAAsC,EAAA;IAC3F,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,IAAI;YACpD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,KAAK,CAAC,KAAK,QAAQ,CAAC;IAC1E,QAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;IAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS;;IACxD,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IACjC,QAAA,OAAO,IAAI;;IAGb,IAAA,kBAAkB,CAA2B,IAAQ,EAAA;IACnD,QAAA,IAAI,IAAI;IAAE,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;;IACjC,YAAA,IAAI,CAAC,UAAU,GAAG,EAAE;IACzB,QAAA,OAAO,IAAI;;IAGb,IAAA,SAAS,CAA2B,KAA8C,EAAA;YAChF,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,KAAK;IAC3D,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE;IAClD,QAAA,MAAM,CAAC,OAAO,CAAC,CAAC,QAAa,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7D,QAAA,OAAO,IAAI;;QAGb,EAAE,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAW,EAAE,QAAe,CAAC;;QAG5D,GAAG,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC9C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAW,EAAE,QAAe,CAAC;;IAG/D,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;iBACrE,IAAI,OAAO,IAAI,KAAK,QAAQ;IAAE,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAW,CAAC;;IAChE,YAAA,OAAO,KAAK;;IAEpB;;;;;;;;"}
1
+ {"version":3,"file":"eventemitter2.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, 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-2025 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 the 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 for the 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 registered\n * 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`, in the\n * 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 the 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8Ga,aAAa,CAAA;IAA1B,IAAA,WAAA,GAAA;YACU,IAAA,CAAA,UAAU,GAAuB,EAAE;QA0C7C;QAxCE,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;YACnE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACpC,QAAA,OAAO,IAAI;QACb;QAEA,mBAAmB,CAA2B,IAAO,EAAE,QAAsC,EAAA;IAC3F,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,IAAI;YACpD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,KAAK,CAAC,KAAK,QAAQ,CAAC;IAC1E,QAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;IAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS;;IACxD,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IACjC,QAAA,OAAO,IAAI;QACb;IAEA,IAAA,kBAAkB,CAA2B,IAAQ,EAAA;IACnD,QAAA,IAAI,IAAI;IAAE,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;;IACjC,YAAA,IAAI,CAAC,UAAU,GAAG,EAAE;IACzB,QAAA,OAAO,IAAI;QACb;IAEA,IAAA,SAAS,CAA2B,KAA8C,EAAA;YAChF,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;IAAE,YAAA,OAAO,KAAK;IAC3D,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE;IAClD,QAAA,MAAM,CAAC,OAAO,CAAC,CAAC,QAAa,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7D,QAAA,OAAO,IAAI;QACb;QAEA,EAAE,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAW,EAAE,QAAe,CAAC;QAC5D;QAEA,GAAG,CAAC,IAAY,EAAE,QAA8B,EAAA;YAC9C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAW,EAAE,QAAe,CAAC;QAC/D;IAEA,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;iBACrE,IAAI,OAAO,IAAI,KAAK,QAAQ;IAAE,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAW,CAAC;;IAChE,YAAA,OAAO,KAAK;QACnB;IACD;;;;;;;;"}
@@ -1 +1,24 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ODA=e.ODA||{})}(this,(function(e){"use strict";e.EventEmitter2=class{constructor(){this._listeners={}}addEventListener(e,t){return void 0===this._listeners[e]&&(this._listeners[e]=[]),this._listeners[e].push(t),this}removeEventListener(e,t){if(void 0===this._listeners[e])return this;const s=this._listeners[e].filter((e=>e!==t));return 0!==s.length?this._listeners[e]=s:delete this._listeners[e],this}removeAllListeners(e){return e?delete this._listeners[e]:this._listeners={},this}emitEvent(e){if(void 0===this._listeners[e.type])return!1;return this._listeners[e.type].slice().forEach((t=>t.call(this,e))),!0}on(e,t){return this.addEventListener(e,t)}off(e,t){return this.removeEventListener(e,t)}emit(e,...t){return"string"==typeof e?this.emitEvent({type:e,args:t}):"object"==typeof e&&this.emitEvent(e)}}}));
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ODA=e.ODA||{})}(this,function(e){"use strict";e.EventEmitter2=class{constructor(){this._listeners={}}addEventListener(e,t){return void 0===this._listeners[e]&&(this._listeners[e]=[]),this._listeners[e].push(t),this}removeEventListener(e,t){if(void 0===this._listeners[e])return this;const s=this._listeners[e].filter(e=>e!==t);return 0!==s.length?this._listeners[e]=s:delete this._listeners[e],this}removeAllListeners(e){return e?delete this._listeners[e]:this._listeners={},this}emitEvent(e){if(void 0===this._listeners[e.type])return!1;return this._listeners[e.type].slice().forEach(t=>t.call(this,e)),!0}on(e,t){return this.addEventListener(e,t)}off(e,t){return this.removeEventListener(e,t)}emit(e,...t){return"string"==typeof e?this.emitEvent({type:e,args:t}):"object"==typeof e&&this.emitEvent(e)}}});
@@ -1,26 +1,58 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
1
24
  class EventEmitter2 {
2
25
  constructor() {
3
26
  this._listeners = {};
4
27
  }
5
28
  addEventListener(type, listener) {
6
- if (this._listeners[type] === undefined) this._listeners[type] = [];
29
+ if (this._listeners[type] === undefined)
30
+ this._listeners[type] = [];
7
31
  this._listeners[type].push(listener);
8
32
  return this;
9
33
  }
10
34
  removeEventListener(type, listener) {
11
- if (this._listeners[type] === undefined) return this;
12
- const listeners = this._listeners[type].filter((x => x !== listener));
13
- if (listeners.length !== 0) this._listeners[type] = listeners; else delete this._listeners[type];
35
+ if (this._listeners[type] === undefined)
36
+ return this;
37
+ const listeners = this._listeners[type].filter((x) => x !== listener);
38
+ if (listeners.length !== 0)
39
+ this._listeners[type] = listeners;
40
+ else
41
+ delete this._listeners[type];
14
42
  return this;
15
43
  }
16
44
  removeAllListeners(type) {
17
- if (type) delete this._listeners[type]; else this._listeners = {};
45
+ if (type)
46
+ delete this._listeners[type];
47
+ else
48
+ this._listeners = {};
18
49
  return this;
19
50
  }
20
51
  emitEvent(event) {
21
- if (this._listeners[event.type] === undefined) return false;
52
+ if (this._listeners[event.type] === undefined)
53
+ return false;
22
54
  const invoke = this._listeners[event.type].slice();
23
- invoke.forEach((listener => listener.call(this, event)));
55
+ invoke.forEach((listener) => listener.call(this, event));
24
56
  return true;
25
57
  }
26
58
  on(type, listener) {
@@ -30,10 +62,12 @@ class EventEmitter2 {
30
62
  return this.removeEventListener(type, listener);
31
63
  }
32
64
  emit(type, ...args) {
33
- if (typeof type === "string") return this.emitEvent({
34
- type: type,
35
- args: args
36
- }); else if (typeof type === "object") return this.emitEvent(type); else return false;
65
+ if (typeof type === "string")
66
+ return this.emitEvent({ type, args });
67
+ else if (typeof type === "object")
68
+ return this.emitEvent(type);
69
+ else
70
+ return false;
37
71
  }
38
72
  }
39
73
 
@@ -1 +1 @@
1
- {"version":3,"file":"eventemitter2.module.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, 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-2025 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 the 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 for the 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 registered\n * 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`, in the\n * 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 the 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,CAAE;;IAE3C,gBAAAC,CAA2CC,MAASC;QAClD,IAAIJ,KAAKC,WAAWE,UAAUE,WAAWL,KAAKC,WAAWE,QAAQ;QACjEH,KAAKC,WAAWE,MAAMG,KAAKF;QAC3B,OAAOJ;;IAGT,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;;IAGT,kBAAAY,CAA6CT;QAC3C,IAAIA,aAAaH,KAAKC,WAAWE,YAC5BH,KAAKC,aAAa,CAAE;QACzB,OAAOD;;IAGT,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;;IAGT,EAAAK,CAAGhB,MAAcC;QACf,OAAOJ,KAAKE,iBAAiBC,MAAaC;;IAG5C,GAAAgB,CAAIjB,MAAcC;QAChB,OAAOJ,KAAKO,oBAAoBJ,MAAaC;;IAG/C,IAAAiB,CAAKlB,SAA0BmB;QAC7B,WAAWnB,SAAS,UAAU,OAAOH,KAAKa,UAAU;YAAEV;YAAMmB;iBACvD,WAAWnB,SAAS,UAAU,OAAOH,KAAKa,UAAUV,YACpD,OAAO;;;;"}
1
+ {"version":3,"file":"eventemitter2.module.js","sources":["../src/index.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, 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-2025 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 the 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 for the 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 registered\n * 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`, in the\n * 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 the 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":";;;;;;;;;;;;;;;;;;;;;;;MA8Ga,aAAa,CAAA;AAA1B,IAAA,WAAA,GAAA;QACU,IAAA,CAAA,UAAU,GAAuB,EAAE;IA0C7C;IAxCE,gBAAgB,CAA2B,IAAO,EAAE,QAAsC,EAAA;AACxF,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;AAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE;QACnE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;AACpC,QAAA,OAAO,IAAI;IACb;IAEA,mBAAmB,CAA2B,IAAO,EAAE,QAAsC,EAAA;AAC3F,QAAA,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS;AAAE,YAAA,OAAO,IAAI;QACpD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,KAAK,CAAC,KAAK,QAAQ,CAAC;AAC1E,QAAA,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;AAAE,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,SAAS;;AACxD,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;AACjC,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,kBAAkB,CAA2B,IAAQ,EAAA;AACnD,QAAA,IAAI,IAAI;AAAE,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;;AACjC,YAAA,IAAI,CAAC,UAAU,GAAG,EAAE;AACzB,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,SAAS,CAA2B,KAA8C,EAAA;QAChF,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS;AAAE,YAAA,OAAO,KAAK;AAC3D,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE;AAClD,QAAA,MAAM,CAAC,OAAO,CAAC,CAAC,QAAa,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7D,QAAA,OAAO,IAAI;IACb;IAEA,EAAE,CAAC,IAAY,EAAE,QAA8B,EAAA;QAC7C,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAW,EAAE,QAAe,CAAC;IAC5D;IAEA,GAAG,CAAC,IAAY,EAAE,QAA8B,EAAA;QAC9C,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAW,EAAE,QAAe,CAAC;IAC/D;AAEA,IAAA,IAAI,CAAC,IAAqB,EAAE,GAAG,IAAW,EAAA;QACxC,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAS,CAAC;aACrE,IAAI,OAAO,IAAI,KAAK,QAAQ;AAAE,YAAA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAW,CAAC;;AAChE,YAAA,OAAO,KAAK;IACnB;AACD;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/eventemitter2",
3
- "version": "26.9.2",
3
+ "version": "26.9.4",
4
4
  "description": "JavaScript event emitter",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",