hookified 1.12.2 → 1.13.0

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/README.md CHANGED
@@ -28,7 +28,7 @@
28
28
  - [Usage](#usage)
29
29
  - [Using it in the Browser](#using-it-in-the-browser)
30
30
  - [API - Hooks](#api---hooks)
31
- - [.throwHookErrors](#throwhookerrors)
31
+ - [.throwOnHookError](#throwhookerror)
32
32
  - [.logger](#logger)
33
33
  - [.enforceBeforeAfter](#enforcebeforeafter)
34
34
  - [.deprecatedHooks](#deprecatedhooks)
@@ -51,6 +51,7 @@
51
51
  - [.clearHooks(eventName)](#clearhookeventname)
52
52
  - [API - Events](#api---events)
53
53
  - [.throwOnEmitError](#throwonemitterror)
54
+ - [.throwOnEmptyListeners](#throwonemptylisteners)
54
55
  - [.on(eventName, handler)](#oneventname-handler)
55
56
  - [.off(eventName, handler)](#offeventname-handler)
56
57
  - [.emit(eventName, ...args)](#emiteventname-args)
@@ -174,7 +175,7 @@ if you are not using ESM modules, you can use the following:
174
175
 
175
176
  # API - Hooks
176
177
 
177
- ## .throwHookErrors
178
+ ## .throwOnHookError
178
179
 
179
180
  If set to true, errors thrown in hooks will be thrown. If set to false, errors will be only emitted.
180
181
 
@@ -183,13 +184,13 @@ import { Hookified } from 'hookified';
183
184
 
184
185
  class MyClass extends Hookified {
185
186
  constructor() {
186
- super({ throwHookErrors: true });
187
+ super({ throwOnHookError: true });
187
188
  }
188
189
  }
189
190
 
190
191
  const myClass = new MyClass();
191
192
 
192
- console.log(myClass.throwHookErrors); // true. because it is set in super
193
+ console.log(myClass.throwOnHookError); // true. because it is set in super
193
194
 
194
195
  try {
195
196
  myClass.onHook('error-event', async () => {
@@ -201,8 +202,8 @@ try {
201
202
  console.log(error.message); // error
202
203
  }
203
204
 
204
- myClass.throwHookErrors = false;
205
- console.log(myClass.throwHookErrors); // false
205
+ myClass.throwOnHookError = false;
206
+ console.log(myClass.throwOnHookError); // false
206
207
  ```
207
208
 
208
209
  ## .logger
@@ -911,6 +912,48 @@ class MyClass extends Hookified {
911
912
  }
912
913
  ```
913
914
 
915
+ ## .throwOnEmptyListeners
916
+
917
+ If set to true, errors will be thrown when emitting an `error` event with no listeners. This follows the standard Node.js EventEmitter behavior. Default is false. In version 2, this will be set to true by default.
918
+
919
+ ```javascript
920
+ import { Hookified } from 'hookified';
921
+
922
+ class MyClass extends Hookified {
923
+ constructor() {
924
+ super({ throwOnEmptyListeners: true });
925
+ }
926
+ }
927
+
928
+ const myClass = new MyClass();
929
+
930
+ console.log(myClass.throwOnEmptyListeners); // true
931
+
932
+ // This will throw because there are no error listeners
933
+ try {
934
+ myClass.emit('error', new Error('Something went wrong'));
935
+ } catch (error) {
936
+ console.log(error.message); // Something went wrong
937
+ }
938
+
939
+ // Add an error listener - now it won't throw
940
+ myClass.on('error', (error) => {
941
+ console.log('Error caught:', error.message);
942
+ });
943
+
944
+ myClass.emit('error', new Error('This will be caught')); // No throw, listener handles it
945
+
946
+ // You can also change it dynamically
947
+ myClass.throwOnEmptyListeners = false;
948
+ console.log(myClass.throwOnEmptyListeners); // false
949
+ ```
950
+
951
+ **Difference between `throwOnEmitError` and `throwOnEmptyListeners`:**
952
+ - `throwOnEmitError`: Throws when emitting 'error' event every time.
953
+ - `throwOnEmptyListeners`: Throws only when there are NO error listeners registered
954
+
955
+ When both are set to `true`, `throwOnEmitError` takes precedence.
956
+
914
957
  ## .on(eventName, handler)
915
958
 
916
959
  Subscribe to an event.
@@ -1204,8 +1247,8 @@ We are doing very simple benchmarking to see how this compares to other librarie
1204
1247
 
1205
1248
  | name | summary | ops/sec | time/op | margin | samples |
1206
1249
  |-----------------------|:---------:|----------:|----------:|:--------:|----------:|
1207
- | Hookified (v1.12.1) | 🥇 | 5M | 243ns | ±0.89% | 4M |
1208
- | Hookable (v5.5.3) | -69% | 1M | 835ns | ±2.23% | 1M |
1250
+ | Hookified (v1.13.0) | 🥇 | 5M | 238ns | ±1.06% | 4M |
1251
+ | Hookable (v5.5.3) | -68% | 1M | 826ns | ±2.25% | 1M |
1209
1252
 
1210
1253
  ## Emits
1211
1254
 
@@ -1213,10 +1256,10 @@ This shows how on par `hookified` is to the native `EventEmitter` and popular `e
1213
1256
 
1214
1257
  | name | summary | ops/sec | time/op | margin | samples |
1215
1258
  |---------------------------|:---------:|----------:|----------:|:--------:|----------:|
1216
- | Hookified (v1.12.1) | 🥇 | 12M | 89ns | ±2.56% | 11M |
1217
- | EventEmitter3 (v5.0.1) | -1.7% | 12M | 91ns | ±3.31% | 11M |
1218
- | EventEmitter (v20.17.0) | -4% | 11M | 92ns | ±0.38% | 11M |
1219
- | Emittery (v1.2.0) | -91% | 1M | 1µs | ±1.59% | 993K |
1259
+ | Hookified (v1.13.0) | 🥇 | 12M | 90ns | ±3.17% | 11M |
1260
+ | EventEmitter3 (v5.0.1) | -0.52% | 12M | 89ns | ±1.66% | 11M |
1261
+ | EventEmitter (v20.17.0) | -3.5% | 12M | 91ns | ±0.42% | 11M |
1262
+ | Emittery (v1.2.0) | -91% | 1M | 1µs | ±3.33% | 959K |
1220
1263
 
1221
1264
  _Note: the `EventEmitter` version is Nodejs versioning._
1222
1265
 
@@ -11,12 +11,17 @@
11
11
  __publicField(this, "_maxListeners");
12
12
  __publicField(this, "_logger");
13
13
  __publicField(this, "_throwOnEmitError", false);
14
+ __publicField(this, "_throwOnEmptyListeners", false);
15
+ __publicField(this, "_errorEvent", "error");
14
16
  this._eventListeners = /* @__PURE__ */ new Map();
15
17
  this._maxListeners = 100;
16
18
  this._logger = options?.logger;
17
19
  if (options?.throwOnEmitError !== void 0) {
18
20
  this._throwOnEmitError = options.throwOnEmitError;
19
21
  }
22
+ if (options?.throwOnEmptyListeners !== void 0) {
23
+ this._throwOnEmptyListeners = options.throwOnEmptyListeners;
24
+ }
20
25
  }
21
26
  /**
22
27
  * Gets the logger
@@ -46,6 +51,20 @@
46
51
  set throwOnEmitError(value) {
47
52
  this._throwOnEmitError = value;
48
53
  }
54
+ /**
55
+ * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
56
+ * @returns {boolean}
57
+ */
58
+ get throwOnEmptyListeners() {
59
+ return this._throwOnEmptyListeners;
60
+ }
61
+ /**
62
+ * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
63
+ * @param {boolean} value
64
+ */
65
+ set throwOnEmptyListeners(value) {
66
+ this._throwOnEmptyListeners = value;
67
+ }
49
68
  /**
50
69
  * Adds a handler function for a specific event that will run only once
51
70
  * @param {string | symbol} eventName
@@ -196,10 +215,14 @@
196
215
  result = true;
197
216
  }
198
217
  }
199
- if (event === "error") {
218
+ if (event === this._errorEvent) {
200
219
  const error = arguments_[0] instanceof Error ? arguments_[0] : new Error(`${arguments_[0]}`);
201
220
  if (this._throwOnEmitError && !result) {
202
221
  throw error;
222
+ } else {
223
+ if (this.listeners(this._errorEvent).length === 0 && this._throwOnEmptyListeners === true) {
224
+ throw error;
225
+ }
203
226
  }
204
227
  }
205
228
  return result;
@@ -254,16 +277,22 @@
254
277
  // src/index.ts
255
278
  var Hookified = class extends Eventified {
256
279
  constructor(options) {
257
- super({ logger: options?.logger });
280
+ super({
281
+ logger: options?.logger,
282
+ throwOnEmitError: options?.throwOnEmitError,
283
+ throwOnEmptyListeners: options?.throwOnEmptyListeners
284
+ });
258
285
  __publicField(this, "_hooks");
259
- __publicField(this, "_throwHookErrors", false);
286
+ __publicField(this, "_throwOnHookError", false);
260
287
  __publicField(this, "_enforceBeforeAfter", false);
261
288
  __publicField(this, "_deprecatedHooks");
262
289
  __publicField(this, "_allowDeprecated", true);
263
290
  this._hooks = /* @__PURE__ */ new Map();
264
291
  this._deprecatedHooks = options?.deprecatedHooks ? new Map(options.deprecatedHooks) : /* @__PURE__ */ new Map();
265
- if (options?.throwHookErrors !== void 0) {
266
- this._throwHookErrors = options.throwHookErrors;
292
+ if (options?.throwOnHookError !== void 0) {
293
+ this._throwOnHookError = options.throwOnHookError;
294
+ } else if (options?.throwHookErrors !== void 0) {
295
+ this._throwOnHookError = options.throwHookErrors;
267
296
  }
268
297
  if (options?.enforceBeforeAfter !== void 0) {
269
298
  this._enforceBeforeAfter = options.enforceBeforeAfter;
@@ -282,16 +311,32 @@
282
311
  /**
283
312
  * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
284
313
  * @returns {boolean}
314
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
285
315
  */
286
316
  get throwHookErrors() {
287
- return this._throwHookErrors;
317
+ return this._throwOnHookError;
288
318
  }
289
319
  /**
290
320
  * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
291
321
  * @param {boolean} value
322
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
292
323
  */
293
324
  set throwHookErrors(value) {
294
- this._throwHookErrors = value;
325
+ this._throwOnHookError = value;
326
+ }
327
+ /**
328
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
329
+ * @returns {boolean}
330
+ */
331
+ get throwOnHookError() {
332
+ return this._throwOnHookError;
333
+ }
334
+ /**
335
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
336
+ * @param {boolean} value
337
+ */
338
+ set throwOnHookError(value) {
339
+ this._throwOnHookError = value;
295
340
  }
296
341
  /**
297
342
  * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
@@ -514,7 +559,7 @@
514
559
  if (this.logger) {
515
560
  this.logger.error(message);
516
561
  }
517
- if (this._throwHookErrors) {
562
+ if (this._throwOnHookError) {
518
563
  throw new Error(message);
519
564
  }
520
565
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["// biome-ignore-all lint/suspicious/noExplicitAny: this is for event emitter compatibility\nimport type { Logger } from \"logger.js\";\n\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array<string | symbol>;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(\n\t\teventName: string | symbol,\n\t): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport type EventEmitterOptions = {\n\t/**\n\t * Logger instance for logging errors.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * Whether to throw an error when emit 'error' and there are no listeners. Default is false and only emits an error event.\n\t */\n\tthrowOnEmitError?: boolean;\n};\n\nexport class Eventified implements IEventEmitter {\n\tprivate readonly _eventListeners: Map<string | symbol, EventListener[]>;\n\tprivate _maxListeners: number;\n\tprivate _logger?: Logger;\n\tprivate _throwOnEmitError = false;\n\n\tconstructor(options?: EventEmitterOptions) {\n\t\tthis._eventListeners = new Map<string | symbol, EventListener[]>();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\n\t\tthis._logger = options?.logger;\n\n\t\tif (options?.throwOnEmitError !== undefined) {\n\t\t\tthis._throwOnEmitError = options.throwOnEmitError;\n\t\t}\n\t}\n\n\t/**\n\t * Gets the logger\n\t * @returns {Logger}\n\t */\n\tpublic get logger(): Logger | undefined {\n\t\treturn this._logger;\n\t}\n\n\t/**\n\t * Sets the logger\n\t * @param {Logger} logger\n\t */\n\tpublic set logger(logger: Logger | undefined) {\n\t\tthis._logger = logger;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnEmitError(): boolean {\n\t\treturn this._throwOnEmitError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnEmitError(value: boolean) {\n\t\tthis._throwOnEmitError = value;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic once(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tpublic listenerCount(eventName?: string | symbol): number {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array<string | symbol>} An array of event names\n\t */\n\tpublic eventNames(): Array<string | symbol> {\n\t\treturn [...this._eventListeners.keys()];\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic rawListeners(event?: string | symbol): EventListener[] {\n\t\tif (event === undefined) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(\n\t\tevent: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\tif (event === \"error\") {\n\t\t\tconst error =\n\t\t\t\targuments_[0] instanceof Error\n\t\t\t\t\t? arguments_[0]\n\t\t\t\t\t: new Error(`${arguments_[0]}`);\n\n\t\t\tif (this._throwOnEmitError && !result) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string | symbol): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string | symbol): IEventEmitter {\n\t\tif (event !== undefined) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result: EventListener[] = [];\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = [...result, ...listeners];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { type EventEmitterOptions, Eventified } from \"./eventified.js\";\n\n// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\nexport type Hook = (...arguments_: any[]) => Promise<void> | void;\n\nexport type HookEntry = {\n\t/**\n\t * The event name for the hook\n\t */\n\tevent: string;\n\t/**\n\t * The handler function for the hook\n\t */\n\thandler: Hook;\n};\n\nexport type HookifiedOptions = {\n\t/**\n\t * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t */\n\tthrowHookErrors?: boolean;\n\t/**\n\t * Whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @type {boolean}\n\t * @default false\n\t */\n\tenforceBeforeAfter?: boolean;\n\t/**\n\t * Map of deprecated hook names to deprecation messages. When a deprecated hook is used, a warning will be emitted.\n\t * @type {Map<string, string>}\n\t * @default new Map()\n\t */\n\tdeprecatedHooks?: Map<string, string>;\n\t/**\n\t * Whether to allow deprecated hooks to be registered and executed. Default is true.\n\t * @type {boolean}\n\t * @default true\n\t */\n\tallowDeprecated?: boolean;\n} & EventEmitterOptions;\n\nexport class Hookified extends Eventified {\n\tprivate readonly _hooks: Map<string, Hook[]>;\n\tprivate _throwHookErrors = false;\n\tprivate _enforceBeforeAfter = false;\n\tprivate _deprecatedHooks: Map<string, string>;\n\tprivate _allowDeprecated = true;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper({ logger: options?.logger });\n\t\tthis._hooks = new Map();\n\t\tthis._deprecatedHooks = options?.deprecatedHooks\n\t\t\t? new Map(options.deprecatedHooks)\n\t\t\t: new Map();\n\n\t\tif (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwHookErrors = options.throwHookErrors;\n\t\t}\n\n\t\tif (options?.enforceBeforeAfter !== undefined) {\n\t\t\tthis._enforceBeforeAfter = options.enforceBeforeAfter;\n\t\t}\n\n\t\tif (options?.allowDeprecated !== undefined) {\n\t\t\tthis._allowDeprecated = options.allowDeprecated;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map<string, Hook[]>}\n\t */\n\tpublic get hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwHookErrors() {\n\t\treturn this._throwHookErrors;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwHookErrors(value) {\n\t\tthis._throwHookErrors = value;\n\t}\n\n\t/**\n\t * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @returns {boolean}\n\t * @default false\n\t */\n\tpublic get enforceBeforeAfter() {\n\t\treturn this._enforceBeforeAfter;\n\t}\n\n\t/**\n\t * Sets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @param {boolean} value\n\t */\n\tpublic set enforceBeforeAfter(value) {\n\t\tthis._enforceBeforeAfter = value;\n\t}\n\n\t/**\n\t * Gets the map of deprecated hook names to deprecation messages.\n\t * @returns {Map<string, string>}\n\t */\n\tpublic get deprecatedHooks() {\n\t\treturn this._deprecatedHooks;\n\t}\n\n\t/**\n\t * Sets the map of deprecated hook names to deprecation messages.\n\t * @param {Map<string, string>} value\n\t */\n\tpublic set deprecatedHooks(value) {\n\t\tthis._deprecatedHooks = value;\n\t}\n\n\t/**\n\t * Gets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @returns {boolean}\n\t */\n\tpublic get allowDeprecated() {\n\t\treturn this._allowDeprecated;\n\t}\n\n\t/**\n\t * Sets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @param {boolean} value\n\t */\n\tpublic set allowDeprecated(value) {\n\t\tthis._allowDeprecated = value;\n\t}\n\n\t/**\n\t * Validates hook event name if enforceBeforeAfter is enabled\n\t * @param {string} event - The event name to validate\n\t * @throws {Error} If enforceBeforeAfter is true and event doesn't start with 'before' or 'after'\n\t */\n\tprivate validateHookName(event: string): void {\n\t\tif (this._enforceBeforeAfter) {\n\t\t\tconst eventValue = event.trim().toLocaleLowerCase();\n\t\t\tif (!eventValue.startsWith(\"before\") && !eventValue.startsWith(\"after\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook event \"${event}\" must start with \"before\" or \"after\" when enforceBeforeAfter is enabled`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if a hook is deprecated and emits a warning if it is\n\t * @param {string} event - The event name to check\n\t * @returns {boolean} - Returns true if the hook should proceed, false if it should be blocked\n\t */\n\tprivate checkDeprecatedHook(event: string): boolean {\n\t\tif (this._deprecatedHooks.has(event)) {\n\t\t\tconst message = this._deprecatedHooks.get(event);\n\t\t\tconst warningMessage = `Hook \"${event}\" is deprecated${message ? `: ${message}` : \"\"}`;\n\n\t\t\t// Emit deprecation warning event\n\t\t\tthis.emit(\"warn\", { hook: event, message: warningMessage });\n\n\t\t\t// Log to logger if available\n\t\t\tif (this.logger?.warn) {\n\t\t\t\tthis.logger.warn(warningMessage);\n\t\t\t}\n\n\t\t\t// Return false if deprecated hooks are not allowed\n\t\t\treturn this._allowDeprecated;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic onHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {HookEntry} hookEntry\n\t * @returns {void}\n\t */\n\tpublic onHookEntry(hookEntry: HookEntry) {\n\t\tthis.onHook(hookEntry.event, hookEntry.handler);\n\t}\n\n\t/**\n\t * Alias for onHook. This is provided for compatibility with other libraries that use the `addHook` method.\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic addHook(event: string, handler: Hook) {\n\t\t// Alias for onHook\n\t\tthis.onHook(event, handler);\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic onHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.onHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic prependHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tpublic prependOnceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tpublic onceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tpublic removeHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip removal if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all handlers for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic removeHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.removeHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async hook<T>(event: string, ...arguments_: T[]) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip execution if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit(\"error\", new Error(message));\n\t\t\t\t\tif (this.logger) {\n\t\t\t\t\t\tthis.logger.error(message);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._throwHookErrors) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Prepends the word `before` to your hook. Example is event is `test`, the before hook is `before:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async beforeHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`before:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Prepends the word `after` to your hook. Example is event is `test`, the after hook is `after:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async afterHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`after:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event. This is an alias for `hook` and is provided for\n\t * compatibility with other libraries that use the `callHook` method.\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async callHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(event, ...arguments_);\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tpublic getHooks(event: string) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn undefined; // Return undefined if deprecated hooks are not allowed\n\t\t}\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tpublic clearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport { Eventified, type EventListener } from \"./eventified.js\";\nexport type { Logger } from \"./logger.js\";\n"],"mappings":";;;;;;;AAoMO,MAAM,aAAN,MAA0C;AAAA,IAMhD,YAAY,SAA+B;AAL3C,0BAAiB;AACjB,0BAAQ;AACR,0BAAQ;AACR,0BAAQ,qBAAoB;AAG3B,WAAK,kBAAkB,oBAAI,IAAsC;AACjE,WAAK,gBAAgB;AAErB,WAAK,UAAU,SAAS;AAExB,UAAI,SAAS,qBAAqB,QAAW;AAC5C,aAAK,oBAAoB,QAAQ;AAAA,MAClC;AAAA,IACD;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,SAA6B;AACvC,aAAO,KAAK;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,OAAO,QAA4B;AAC7C,WAAK,UAAU;AAAA,IAChB;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,mBAA4B;AACtC,aAAO,KAAK;AAAA,IACb;AAAA;AAAA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kB,YAAiB;AAC3D,YAAM,KAAK,KAAK,OAAO,GAAG,UAAU;AAAA,IACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOO,SAAS,OAAe;AAC9B,WAAK,iBAAiB,KAAK;AAC3B,UAAI,CAAC,KAAK,oBAAoB,KAAK,GAAG;AACrC,eAAO;AAAA,MACR;AACA,aAAO,KAAK,OAAO,IAAI,KAAK;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,IAMO,aAAa;AACnB,WAAK,OAAO,MAAM;AAAA,IACnB;AAAA,EACD;","names":[]}
1
+ {"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["// biome-ignore-all lint/suspicious/noExplicitAny: this is for event emitter compatibility\nimport type { Logger } from \"logger.js\";\n\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array<string | symbol>;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(\n\t\teventName: string | symbol,\n\t): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport type EventEmitterOptions = {\n\t/**\n\t * Logger instance for logging errors.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * Whether to throw an error when emit 'error' and there are no listeners. Default is false and only emits an error event.\n\t */\n\tthrowOnEmitError?: boolean;\n\n\t/**\n\t * Whether to throw on 'error' when there are no listeners. This is the standard functionality in EventEmitter\n\t * @default false - in v2 this will be set to true by default\n\t */\n\tthrowOnEmptyListeners?: boolean;\n};\n\nexport class Eventified implements IEventEmitter {\n\tprivate readonly _eventListeners: Map<string | symbol, EventListener[]>;\n\tprivate _maxListeners: number;\n\tprivate _logger?: Logger;\n\tprivate _throwOnEmitError = false;\n\tprivate _throwOnEmptyListeners = false;\n\tprivate _errorEvent = \"error\";\n\n\tconstructor(options?: EventEmitterOptions) {\n\t\tthis._eventListeners = new Map<string | symbol, EventListener[]>();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\n\t\tthis._logger = options?.logger;\n\n\t\tif (options?.throwOnEmitError !== undefined) {\n\t\t\tthis._throwOnEmitError = options.throwOnEmitError;\n\t\t}\n\n\t\tif (options?.throwOnEmptyListeners !== undefined) {\n\t\t\tthis._throwOnEmptyListeners = options.throwOnEmptyListeners;\n\t\t}\n\t}\n\n\t/**\n\t * Gets the logger\n\t * @returns {Logger}\n\t */\n\tpublic get logger(): Logger | undefined {\n\t\treturn this._logger;\n\t}\n\n\t/**\n\t * Sets the logger\n\t * @param {Logger} logger\n\t */\n\tpublic set logger(logger: Logger | undefined) {\n\t\tthis._logger = logger;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnEmitError(): boolean {\n\t\treturn this._throwOnEmitError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnEmitError(value: boolean) {\n\t\tthis._throwOnEmitError = value;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnEmptyListeners(): boolean {\n\t\treturn this._throwOnEmptyListeners;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnEmptyListeners(value: boolean) {\n\t\tthis._throwOnEmptyListeners = value;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic once(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tpublic listenerCount(eventName?: string | symbol): number {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array<string | symbol>} An array of event names\n\t */\n\tpublic eventNames(): Array<string | symbol> {\n\t\treturn [...this._eventListeners.keys()];\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic rawListeners(event?: string | symbol): EventListener[] {\n\t\tif (event === undefined) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(\n\t\tevent: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\tif (event === this._errorEvent) {\n\t\t\tconst error =\n\t\t\t\targuments_[0] instanceof Error\n\t\t\t\t\t? arguments_[0]\n\t\t\t\t\t: new Error(`${arguments_[0]}`);\n\n\t\t\tif (this._throwOnEmitError && !result) {\n\t\t\t\tthrow error;\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tthis.listeners(this._errorEvent).length === 0 &&\n\t\t\t\t\tthis._throwOnEmptyListeners === true\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string | symbol): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string | symbol): IEventEmitter {\n\t\tif (event !== undefined) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result: EventListener[] = [];\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = [...result, ...listeners];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { type EventEmitterOptions, Eventified } from \"./eventified.js\";\n\n// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\nexport type Hook = (...arguments_: any[]) => Promise<void> | void;\n\nexport type HookEntry = {\n\t/**\n\t * The event name for the hook\n\t */\n\tevent: string;\n\t/**\n\t * The handler function for the hook\n\t */\n\thandler: Hook;\n};\n\nexport type HookifiedOptions = {\n\t/**\n\t * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.\n\t */\n\tthrowHookErrors?: boolean;\n\t/**\n\t * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t */\n\tthrowOnHookError?: boolean;\n\t/**\n\t * Whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @type {boolean}\n\t * @default false\n\t */\n\tenforceBeforeAfter?: boolean;\n\t/**\n\t * Map of deprecated hook names to deprecation messages. When a deprecated hook is used, a warning will be emitted.\n\t * @type {Map<string, string>}\n\t * @default new Map()\n\t */\n\tdeprecatedHooks?: Map<string, string>;\n\t/**\n\t * Whether to allow deprecated hooks to be registered and executed. Default is true.\n\t * @type {boolean}\n\t * @default true\n\t */\n\tallowDeprecated?: boolean;\n} & EventEmitterOptions;\n\nexport class Hookified extends Eventified {\n\tprivate readonly _hooks: Map<string, Hook[]>;\n\tprivate _throwOnHookError = false;\n\tprivate _enforceBeforeAfter = false;\n\tprivate _deprecatedHooks: Map<string, string>;\n\tprivate _allowDeprecated = true;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper({\n\t\t\tlogger: options?.logger,\n\t\t\tthrowOnEmitError: options?.throwOnEmitError,\n\t\t\tthrowOnEmptyListeners: options?.throwOnEmptyListeners,\n\t\t});\n\t\tthis._hooks = new Map();\n\t\tthis._deprecatedHooks = options?.deprecatedHooks\n\t\t\t? new Map(options.deprecatedHooks)\n\t\t\t: new Map();\n\n\t\tif (options?.throwOnHookError !== undefined) {\n\t\t\tthis._throwOnHookError = options.throwOnHookError;\n\t\t} else if (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwOnHookError = options.throwHookErrors;\n\t\t}\n\n\t\tif (options?.enforceBeforeAfter !== undefined) {\n\t\t\tthis._enforceBeforeAfter = options.enforceBeforeAfter;\n\t\t}\n\n\t\tif (options?.allowDeprecated !== undefined) {\n\t\t\tthis._allowDeprecated = options.allowDeprecated;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map<string, Hook[]>}\n\t */\n\tpublic get hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.\n\t */\n\tpublic get throwHookErrors() {\n\t\treturn this._throwOnHookError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.\n\t */\n\tpublic set throwHookErrors(value) {\n\t\tthis._throwOnHookError = value;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnHookError() {\n\t\treturn this._throwOnHookError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnHookError(value) {\n\t\tthis._throwOnHookError = value;\n\t}\n\n\t/**\n\t * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @returns {boolean}\n\t * @default false\n\t */\n\tpublic get enforceBeforeAfter() {\n\t\treturn this._enforceBeforeAfter;\n\t}\n\n\t/**\n\t * Sets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @param {boolean} value\n\t */\n\tpublic set enforceBeforeAfter(value) {\n\t\tthis._enforceBeforeAfter = value;\n\t}\n\n\t/**\n\t * Gets the map of deprecated hook names to deprecation messages.\n\t * @returns {Map<string, string>}\n\t */\n\tpublic get deprecatedHooks() {\n\t\treturn this._deprecatedHooks;\n\t}\n\n\t/**\n\t * Sets the map of deprecated hook names to deprecation messages.\n\t * @param {Map<string, string>} value\n\t */\n\tpublic set deprecatedHooks(value) {\n\t\tthis._deprecatedHooks = value;\n\t}\n\n\t/**\n\t * Gets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @returns {boolean}\n\t */\n\tpublic get allowDeprecated() {\n\t\treturn this._allowDeprecated;\n\t}\n\n\t/**\n\t * Sets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @param {boolean} value\n\t */\n\tpublic set allowDeprecated(value) {\n\t\tthis._allowDeprecated = value;\n\t}\n\n\t/**\n\t * Validates hook event name if enforceBeforeAfter is enabled\n\t * @param {string} event - The event name to validate\n\t * @throws {Error} If enforceBeforeAfter is true and event doesn't start with 'before' or 'after'\n\t */\n\tprivate validateHookName(event: string): void {\n\t\tif (this._enforceBeforeAfter) {\n\t\t\tconst eventValue = event.trim().toLocaleLowerCase();\n\t\t\tif (!eventValue.startsWith(\"before\") && !eventValue.startsWith(\"after\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook event \"${event}\" must start with \"before\" or \"after\" when enforceBeforeAfter is enabled`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if a hook is deprecated and emits a warning if it is\n\t * @param {string} event - The event name to check\n\t * @returns {boolean} - Returns true if the hook should proceed, false if it should be blocked\n\t */\n\tprivate checkDeprecatedHook(event: string): boolean {\n\t\tif (this._deprecatedHooks.has(event)) {\n\t\t\tconst message = this._deprecatedHooks.get(event);\n\t\t\tconst warningMessage = `Hook \"${event}\" is deprecated${message ? `: ${message}` : \"\"}`;\n\n\t\t\t// Emit deprecation warning event\n\t\t\tthis.emit(\"warn\", { hook: event, message: warningMessage });\n\n\t\t\t// Log to logger if available\n\t\t\tif (this.logger?.warn) {\n\t\t\t\tthis.logger.warn(warningMessage);\n\t\t\t}\n\n\t\t\t// Return false if deprecated hooks are not allowed\n\t\t\treturn this._allowDeprecated;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic onHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {HookEntry} hookEntry\n\t * @returns {void}\n\t */\n\tpublic onHookEntry(hookEntry: HookEntry) {\n\t\tthis.onHook(hookEntry.event, hookEntry.handler);\n\t}\n\n\t/**\n\t * Alias for onHook. This is provided for compatibility with other libraries that use the `addHook` method.\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic addHook(event: string, handler: Hook) {\n\t\t// Alias for onHook\n\t\tthis.onHook(event, handler);\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic onHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.onHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic prependHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tpublic prependOnceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tpublic onceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tpublic removeHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip removal if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all handlers for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic removeHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.removeHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async hook<T>(event: string, ...arguments_: T[]) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip execution if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit(\"error\", new Error(message));\n\t\t\t\t\tif (this.logger) {\n\t\t\t\t\t\tthis.logger.error(message);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._throwOnHookError) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Prepends the word `before` to your hook. Example is event is `test`, the before hook is `before:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async beforeHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`before:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Prepends the word `after` to your hook. Example is event is `test`, the after hook is `after:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async afterHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`after:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event. This is an alias for `hook` and is provided for\n\t * compatibility with other libraries that use the `callHook` method.\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async callHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(event, ...arguments_);\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tpublic getHooks(event: string) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn undefined; // Return undefined if deprecated hooks are not allowed\n\t\t}\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tpublic clearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport { Eventified, type EventListener } from \"./eventified.js\";\nexport type { Logger } from \"./logger.js\";\n"],"mappings":";;;;;;;AA0MO,MAAM,aAAN,MAA0C;AAAA,IAQhD,YAAY,SAA+B;AAP3C,0BAAiB;AACjB,0BAAQ;AACR,0BAAQ;AACR,0BAAQ,qBAAoB;AAC5B,0BAAQ,0BAAyB;AACjC,0BAAQ,eAAc;AAGrB,WAAK,kBAAkB,oBAAI,IAAsC;AACjE,WAAK,gBAAgB;AAErB,WAAK,UAAU,SAAS;AAExB,UAAI,SAAS,qBAAqB,QAAW;AAC5C,aAAK,oBAAoB,QAAQ;AAAA,MAClC;AAEA,UAAI,SAAS,0BAA0B,QAAW;AACjD,aAAK,yBAAyB,QAAQ;AAAA,MACvC;AAAA,IACD;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,SAA6B;AACvC,aAAO,KAAK;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,OAAO,QAA4B;AAC7C,WAAK,UAAU;AAAA,IAChB;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,mBAA4B;AACtC,aAAO,KAAK;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,iBAAiB,OAAgB;AAC3C,WAAK,oBAAoB;AAAA,IAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,wBAAiC;AAC3C,aAAO,KAAK;AAAA,IACb;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,IAAW,sBAAsB,OAAgB;AAChD,WAAK,yBAAyB;AAAA,IAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQO,KACN,WACA,UACgB;AAChB,YAAM,eAA8B,IAAI,eAAsB;AAC7D,aAAK,IAAI,WAAqB,YAAY;AAC1C,iBAAS,GAAG,UAAU;AAAA,MACvB;AAEA,W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AAA;AAAA,IAOA,MAAa,UAAa,UAAkB,YAAiB;AAC5D,YAAM,KAAK,KAAK,SAAS,KAAK,IAAI,GAAG,UAAU;AAAA,IAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,MAAa,SAAY,UAAkB,YAAiB;AAC3D,YAAM,KAAK,KAAK,OAAO,GAAG,UAAU;AAAA,IACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOO,SAAS,OAAe;AAC9B,WAAK,iBAAiB,KAAK;AAC3B,UAAI,CAAC,KAAK,oBAAoB,KAAK,GAAG;AACrC,eAAO;AAAA,MACR;AACA,aAAO,KAAK,OAAO,IAAI,KAAK;AAAA,IAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,IAMO,aAAa;AACnB,WAAK,OAAO,MAAM;AAAA,IACnB;AAAA,EACD;","names":[]}
@@ -9,12 +9,17 @@ var Eventified = class {
9
9
  __publicField(this, "_maxListeners");
10
10
  __publicField(this, "_logger");
11
11
  __publicField(this, "_throwOnEmitError", false);
12
+ __publicField(this, "_throwOnEmptyListeners", false);
13
+ __publicField(this, "_errorEvent", "error");
12
14
  this._eventListeners = /* @__PURE__ */ new Map();
13
15
  this._maxListeners = 100;
14
16
  this._logger = options?.logger;
15
17
  if (options?.throwOnEmitError !== void 0) {
16
18
  this._throwOnEmitError = options.throwOnEmitError;
17
19
  }
20
+ if (options?.throwOnEmptyListeners !== void 0) {
21
+ this._throwOnEmptyListeners = options.throwOnEmptyListeners;
22
+ }
18
23
  }
19
24
  /**
20
25
  * Gets the logger
@@ -44,6 +49,20 @@ var Eventified = class {
44
49
  set throwOnEmitError(value) {
45
50
  this._throwOnEmitError = value;
46
51
  }
52
+ /**
53
+ * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
54
+ * @returns {boolean}
55
+ */
56
+ get throwOnEmptyListeners() {
57
+ return this._throwOnEmptyListeners;
58
+ }
59
+ /**
60
+ * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
61
+ * @param {boolean} value
62
+ */
63
+ set throwOnEmptyListeners(value) {
64
+ this._throwOnEmptyListeners = value;
65
+ }
47
66
  /**
48
67
  * Adds a handler function for a specific event that will run only once
49
68
  * @param {string | symbol} eventName
@@ -194,10 +213,14 @@ var Eventified = class {
194
213
  result = true;
195
214
  }
196
215
  }
197
- if (event === "error") {
216
+ if (event === this._errorEvent) {
198
217
  const error = arguments_[0] instanceof Error ? arguments_[0] : new Error(`${arguments_[0]}`);
199
218
  if (this._throwOnEmitError && !result) {
200
219
  throw error;
220
+ } else {
221
+ if (this.listeners(this._errorEvent).length === 0 && this._throwOnEmptyListeners === true) {
222
+ throw error;
223
+ }
201
224
  }
202
225
  }
203
226
  return result;
@@ -252,16 +275,22 @@ var Eventified = class {
252
275
  // src/index.ts
253
276
  var Hookified = class extends Eventified {
254
277
  constructor(options) {
255
- super({ logger: options?.logger });
278
+ super({
279
+ logger: options?.logger,
280
+ throwOnEmitError: options?.throwOnEmitError,
281
+ throwOnEmptyListeners: options?.throwOnEmptyListeners
282
+ });
256
283
  __publicField(this, "_hooks");
257
- __publicField(this, "_throwHookErrors", false);
284
+ __publicField(this, "_throwOnHookError", false);
258
285
  __publicField(this, "_enforceBeforeAfter", false);
259
286
  __publicField(this, "_deprecatedHooks");
260
287
  __publicField(this, "_allowDeprecated", true);
261
288
  this._hooks = /* @__PURE__ */ new Map();
262
289
  this._deprecatedHooks = options?.deprecatedHooks ? new Map(options.deprecatedHooks) : /* @__PURE__ */ new Map();
263
- if (options?.throwHookErrors !== void 0) {
264
- this._throwHookErrors = options.throwHookErrors;
290
+ if (options?.throwOnHookError !== void 0) {
291
+ this._throwOnHookError = options.throwOnHookError;
292
+ } else if (options?.throwHookErrors !== void 0) {
293
+ this._throwOnHookError = options.throwHookErrors;
265
294
  }
266
295
  if (options?.enforceBeforeAfter !== void 0) {
267
296
  this._enforceBeforeAfter = options.enforceBeforeAfter;
@@ -280,16 +309,32 @@ var Hookified = class extends Eventified {
280
309
  /**
281
310
  * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
282
311
  * @returns {boolean}
312
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
283
313
  */
284
314
  get throwHookErrors() {
285
- return this._throwHookErrors;
315
+ return this._throwOnHookError;
286
316
  }
287
317
  /**
288
318
  * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
289
319
  * @param {boolean} value
320
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
290
321
  */
291
322
  set throwHookErrors(value) {
292
- this._throwHookErrors = value;
323
+ this._throwOnHookError = value;
324
+ }
325
+ /**
326
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
327
+ * @returns {boolean}
328
+ */
329
+ get throwOnHookError() {
330
+ return this._throwOnHookError;
331
+ }
332
+ /**
333
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
334
+ * @param {boolean} value
335
+ */
336
+ set throwOnHookError(value) {
337
+ this._throwOnHookError = value;
293
338
  }
294
339
  /**
295
340
  * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
@@ -512,7 +557,7 @@ var Hookified = class extends Eventified {
512
557
  if (this.logger) {
513
558
  this.logger.error(message);
514
559
  }
515
- if (this._throwHookErrors) {
560
+ if (this._throwOnHookError) {
516
561
  throw new Error(message);
517
562
  }
518
563
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["// biome-ignore-all lint/suspicious/noExplicitAny: this is for event emitter compatibility\nimport type { Logger } from \"logger.js\";\n\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array<string | symbol>;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(\n\t\teventName: string | symbol,\n\t): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport type EventEmitterOptions = {\n\t/**\n\t * Logger instance for logging errors.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * Whether to throw an error when emit 'error' and there are no listeners. Default is false and only emits an error event.\n\t */\n\tthrowOnEmitError?: boolean;\n};\n\nexport class Eventified implements IEventEmitter {\n\tprivate readonly _eventListeners: Map<string | symbol, EventListener[]>;\n\tprivate _maxListeners: number;\n\tprivate _logger?: Logger;\n\tprivate _throwOnEmitError = false;\n\n\tconstructor(options?: EventEmitterOptions) {\n\t\tthis._eventListeners = new Map<string | symbol, EventListener[]>();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\n\t\tthis._logger = options?.logger;\n\n\t\tif (options?.throwOnEmitError !== undefined) {\n\t\t\tthis._throwOnEmitError = options.throwOnEmitError;\n\t\t}\n\t}\n\n\t/**\n\t * Gets the logger\n\t * @returns {Logger}\n\t */\n\tpublic get logger(): Logger | undefined {\n\t\treturn this._logger;\n\t}\n\n\t/**\n\t * Sets the logger\n\t * @param {Logger} logger\n\t */\n\tpublic set logger(logger: Logger | undefined) {\n\t\tthis._logger = logger;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnEmitError(): boolean {\n\t\treturn this._throwOnEmitError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnEmitError(value: boolean) {\n\t\tthis._throwOnEmitError = value;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic once(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tpublic listenerCount(eventName?: string | symbol): number {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array<string | symbol>} An array of event names\n\t */\n\tpublic eventNames(): Array<string | symbol> {\n\t\treturn [...this._eventListeners.keys()];\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic rawListeners(event?: string | symbol): EventListener[] {\n\t\tif (event === undefined) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(\n\t\tevent: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\tif (event === \"error\") {\n\t\t\tconst error =\n\t\t\t\targuments_[0] instanceof Error\n\t\t\t\t\t? arguments_[0]\n\t\t\t\t\t: new Error(`${arguments_[0]}`);\n\n\t\t\tif (this._throwOnEmitError && !result) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string | symbol): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string | symbol): IEventEmitter {\n\t\tif (event !== undefined) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result: EventListener[] = [];\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = [...result, ...listeners];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { type EventEmitterOptions, Eventified } from \"./eventified.js\";\n\n// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\nexport type Hook = (...arguments_: any[]) => Promise<void> | void;\n\nexport type HookEntry = {\n\t/**\n\t * The event name for the hook\n\t */\n\tevent: string;\n\t/**\n\t * The handler function for the hook\n\t */\n\thandler: Hook;\n};\n\nexport type HookifiedOptions = {\n\t/**\n\t * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t */\n\tthrowHookErrors?: boolean;\n\t/**\n\t * Whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @type {boolean}\n\t * @default false\n\t */\n\tenforceBeforeAfter?: boolean;\n\t/**\n\t * Map of deprecated hook names to deprecation messages. When a deprecated hook is used, a warning will be emitted.\n\t * @type {Map<string, string>}\n\t * @default new Map()\n\t */\n\tdeprecatedHooks?: Map<string, string>;\n\t/**\n\t * Whether to allow deprecated hooks to be registered and executed. Default is true.\n\t * @type {boolean}\n\t * @default true\n\t */\n\tallowDeprecated?: boolean;\n} & EventEmitterOptions;\n\nexport class Hookified extends Eventified {\n\tprivate readonly _hooks: Map<string, Hook[]>;\n\tprivate _throwHookErrors = false;\n\tprivate _enforceBeforeAfter = false;\n\tprivate _deprecatedHooks: Map<string, string>;\n\tprivate _allowDeprecated = true;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper({ logger: options?.logger });\n\t\tthis._hooks = new Map();\n\t\tthis._deprecatedHooks = options?.deprecatedHooks\n\t\t\t? new Map(options.deprecatedHooks)\n\t\t\t: new Map();\n\n\t\tif (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwHookErrors = options.throwHookErrors;\n\t\t}\n\n\t\tif (options?.enforceBeforeAfter !== undefined) {\n\t\t\tthis._enforceBeforeAfter = options.enforceBeforeAfter;\n\t\t}\n\n\t\tif (options?.allowDeprecated !== undefined) {\n\t\t\tthis._allowDeprecated = options.allowDeprecated;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map<string, Hook[]>}\n\t */\n\tpublic get hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwHookErrors() {\n\t\treturn this._throwHookErrors;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwHookErrors(value) {\n\t\tthis._throwHookErrors = value;\n\t}\n\n\t/**\n\t * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @returns {boolean}\n\t * @default false\n\t */\n\tpublic get enforceBeforeAfter() {\n\t\treturn this._enforceBeforeAfter;\n\t}\n\n\t/**\n\t * Sets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @param {boolean} value\n\t */\n\tpublic set enforceBeforeAfter(value) {\n\t\tthis._enforceBeforeAfter = value;\n\t}\n\n\t/**\n\t * Gets the map of deprecated hook names to deprecation messages.\n\t * @returns {Map<string, string>}\n\t */\n\tpublic get deprecatedHooks() {\n\t\treturn this._deprecatedHooks;\n\t}\n\n\t/**\n\t * Sets the map of deprecated hook names to deprecation messages.\n\t * @param {Map<string, string>} value\n\t */\n\tpublic set deprecatedHooks(value) {\n\t\tthis._deprecatedHooks = value;\n\t}\n\n\t/**\n\t * Gets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @returns {boolean}\n\t */\n\tpublic get allowDeprecated() {\n\t\treturn this._allowDeprecated;\n\t}\n\n\t/**\n\t * Sets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @param {boolean} value\n\t */\n\tpublic set allowDeprecated(value) {\n\t\tthis._allowDeprecated = value;\n\t}\n\n\t/**\n\t * Validates hook event name if enforceBeforeAfter is enabled\n\t * @param {string} event - The event name to validate\n\t * @throws {Error} If enforceBeforeAfter is true and event doesn't start with 'before' or 'after'\n\t */\n\tprivate validateHookName(event: string): void {\n\t\tif (this._enforceBeforeAfter) {\n\t\t\tconst eventValue = event.trim().toLocaleLowerCase();\n\t\t\tif (!eventValue.startsWith(\"before\") && !eventValue.startsWith(\"after\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook event \"${event}\" must start with \"before\" or \"after\" when enforceBeforeAfter is enabled`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if a hook is deprecated and emits a warning if it is\n\t * @param {string} event - The event name to check\n\t * @returns {boolean} - Returns true if the hook should proceed, false if it should be blocked\n\t */\n\tprivate checkDeprecatedHook(event: string): boolean {\n\t\tif (this._deprecatedHooks.has(event)) {\n\t\t\tconst message = this._deprecatedHooks.get(event);\n\t\t\tconst warningMessage = `Hook \"${event}\" is deprecated${message ? `: ${message}` : \"\"}`;\n\n\t\t\t// Emit deprecation warning event\n\t\t\tthis.emit(\"warn\", { hook: event, message: warningMessage });\n\n\t\t\t// Log to logger if available\n\t\t\tif (this.logger?.warn) {\n\t\t\t\tthis.logger.warn(warningMessage);\n\t\t\t}\n\n\t\t\t// Return false if deprecated hooks are not allowed\n\t\t\treturn this._allowDeprecated;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic onHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {HookEntry} hookEntry\n\t * @returns {void}\n\t */\n\tpublic onHookEntry(hookEntry: HookEntry) {\n\t\tthis.onHook(hookEntry.event, hookEntry.handler);\n\t}\n\n\t/**\n\t * Alias for onHook. This is provided for compatibility with other libraries that use the `addHook` method.\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic addHook(event: string, handler: Hook) {\n\t\t// Alias for onHook\n\t\tthis.onHook(event, handler);\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic onHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.onHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic prependHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tpublic prependOnceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tpublic onceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tpublic removeHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip removal if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all handlers for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic removeHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.removeHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async hook<T>(event: string, ...arguments_: T[]) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip execution if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit(\"error\", new Error(message));\n\t\t\t\t\tif (this.logger) {\n\t\t\t\t\t\tthis.logger.error(message);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._throwHookErrors) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Prepends the word `before` to your hook. Example is event is `test`, the before hook is `before:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async beforeHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`before:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Prepends the word `after` to your hook. Example is event is `test`, the after hook is `after:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async afterHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`after:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event. This is an alias for `hook` and is provided for\n\t * compatibility with other libraries that use the `callHook` method.\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async callHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(event, ...arguments_);\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tpublic getHooks(event: string) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn undefined; // Return undefined if deprecated hooks are not allowed\n\t\t}\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tpublic clearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport { Eventified, type EventListener } from \"./eventified.js\";\nexport type { Logger } from \"./logger.js\";\n"],"mappings":";;;;;AAoMO,IAAM,aAAN,MAA0C;AAAA,EAMhD,YAAY,SAA+B;AAL3C,wBAAiB;AACjB,wBAAQ;AACR,wBAAQ;AACR,wBAAQ,qBAAoB;AAG3B,SAAK,kBAAkB,oBAAI,IAAsC;AACjE,SAAK,gBAAgB;AAErB,SAAK,UAAU,SAAS;AAExB,QAAI,SAAS,qBAAqB,QAAW;AAC5C,WAAK,oBAAoB,QAAQ;AAAA,IAClC;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,SAA6B;AACvC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,OAAO,QAA4B;AAC7C,SAAK,UAAU;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,mBAA4B;AACtC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,iBAAiB,OAAgB;AAC3C,SAAK,oBAAoB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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B,KAAK;AAC3B,QAAI,CAAC,KAAK,oBAAoB,KAAK,GAAG;AACrC,aAAO;AAAA,IACR;AACA,WAAO,KAAK,OAAO,IAAI,KAAK;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,aAAa;AACnB,SAAK,OAAO,MAAM;AAAA,EACnB;AACD;","names":[]}
1
+ {"version":3,"sources":["../../src/eventified.ts","../../src/index.ts"],"sourcesContent":["// biome-ignore-all lint/suspicious/noExplicitAny: this is for event emitter compatibility\nimport type { Logger } from \"logger.js\";\n\nexport type IEventEmitter = {\n\t/**\n\t * Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.on('data', (message) => {\n\t * console.log(message);\n\t * });\n\t */\n\ton(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `on`. Registers a listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\taddListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Registers a one-time listener for the specified event. The listener is removed after it is called once.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.once('close', () => {\n\t * console.log('The connection was closed.');\n\t * });\n\t */\n\tonce(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.off('data', myListener);\n\t */\n\toff(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Alias for `off`. Removes a previously registered listener for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to stop listening for.\n\t * @param listener - The specific callback function to remove.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t */\n\tremoveListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Emits the specified event, invoking all registered listeners with the provided arguments.\n\t *\n\t * @param eventName - The name (or symbol) of the event to emit.\n\t * @param args - Arguments passed to each listener.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t *\n\t * @example\n\t * emitter.emit('data', 'Hello World');\n\t */\n\temit(eventName: string | symbol, ...arguments_: any[]): boolean;\n\n\t/**\n\t * Returns the number of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns The number of registered listeners.\n\t *\n\t * @example\n\t * const count = emitter.listenerCount('data');\n\t * console.log(count); // e.g., 2\n\t */\n\tlistenerCount(eventName: string | symbol): number;\n\n\t/**\n\t * Removes all listeners for the specified event. If no event is specified, it removes all listeners for all events.\n\t *\n\t * @param eventName - (Optional) The name (or symbol) of the event.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.removeAllListeners('data');\n\t */\n\tremoveAllListeners(eventName?: string | symbol): IEventEmitter;\n\n\t/**\n\t * Returns an array of event names for which listeners have been registered.\n\t *\n\t * @returns An array of event names (or symbols).\n\t *\n\t * @example\n\t * const events = emitter.eventNames();\n\t * console.log(events); // e.g., ['data', 'close']\n\t */\n\teventNames(): Array<string | symbol>;\n\n\t/**\n\t * Returns an array of listeners registered for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of listener functions.\n\t *\n\t * @example\n\t * const listeners = emitter.listeners('data');\n\t * console.log(listeners.length); // e.g., 2\n\t */\n\tlisteners(eventName: string | symbol): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Returns an array of raw listeners for the specified event. This includes listeners wrapped by internal mechanisms (e.g., once-only listeners).\n\t *\n\t * @param eventName - The name (or symbol) of the event.\n\t * @returns An array of raw listener functions.\n\t *\n\t * @example\n\t * const rawListeners = emitter.rawListeners('data');\n\t */\n\trawListeners(\n\t\teventName: string | symbol,\n\t): Array<(...arguments_: any[]) => void>;\n\n\t/**\n\t * Adds a listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependListener('data', (message) => {\n\t * console.log('This will run first.');\n\t * });\n\t */\n\tprependListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n\n\t/**\n\t * Adds a one-time listener to the beginning of the listeners array for the specified event.\n\t *\n\t * @param eventName - The name (or symbol) of the event to listen for.\n\t * @param listener - A callback function that will be invoked once when the event is emitted.\n\t * @returns The current instance of EventEmitter for method chaining.\n\t *\n\t * @example\n\t * emitter.prependOnceListener('data', (message) => {\n\t * console.log('This will run first and only once.');\n\t * });\n\t */\n\tprependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: (...arguments_: any[]) => void,\n\t): IEventEmitter;\n};\n\nexport type EventListener = (...arguments_: any[]) => void;\n\nexport type EventEmitterOptions = {\n\t/**\n\t * Logger instance for logging errors.\n\t */\n\tlogger?: Logger;\n\t/**\n\t * Whether to throw an error when emit 'error' and there are no listeners. Default is false and only emits an error event.\n\t */\n\tthrowOnEmitError?: boolean;\n\n\t/**\n\t * Whether to throw on 'error' when there are no listeners. This is the standard functionality in EventEmitter\n\t * @default false - in v2 this will be set to true by default\n\t */\n\tthrowOnEmptyListeners?: boolean;\n};\n\nexport class Eventified implements IEventEmitter {\n\tprivate readonly _eventListeners: Map<string | symbol, EventListener[]>;\n\tprivate _maxListeners: number;\n\tprivate _logger?: Logger;\n\tprivate _throwOnEmitError = false;\n\tprivate _throwOnEmptyListeners = false;\n\tprivate _errorEvent = \"error\";\n\n\tconstructor(options?: EventEmitterOptions) {\n\t\tthis._eventListeners = new Map<string | symbol, EventListener[]>();\n\t\tthis._maxListeners = 100; // Default maximum number of listeners\n\n\t\tthis._logger = options?.logger;\n\n\t\tif (options?.throwOnEmitError !== undefined) {\n\t\t\tthis._throwOnEmitError = options.throwOnEmitError;\n\t\t}\n\n\t\tif (options?.throwOnEmptyListeners !== undefined) {\n\t\t\tthis._throwOnEmptyListeners = options.throwOnEmptyListeners;\n\t\t}\n\t}\n\n\t/**\n\t * Gets the logger\n\t * @returns {Logger}\n\t */\n\tpublic get logger(): Logger | undefined {\n\t\treturn this._logger;\n\t}\n\n\t/**\n\t * Sets the logger\n\t * @param {Logger} logger\n\t */\n\tpublic set logger(logger: Logger | undefined) {\n\t\tthis._logger = logger;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnEmitError(): boolean {\n\t\treturn this._throwOnEmitError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnEmitError(value: boolean) {\n\t\tthis._throwOnEmitError = value;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnEmptyListeners(): boolean {\n\t\treturn this._throwOnEmptyListeners;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnEmptyListeners(value: boolean) {\n\t\tthis._throwOnEmptyListeners = value;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that will run only once\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic once(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.on(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners\n\t * @param {string} eventName The event name. Not required\n\t * @returns {number} The number of listeners\n\t */\n\tpublic listenerCount(eventName?: string | symbol): number {\n\t\tif (eventName === undefined) {\n\t\t\treturn this.getAllListeners().length;\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(eventName);\n\t\treturn listeners ? listeners.length : 0;\n\t}\n\n\t/**\n\t * Gets an array of event names\n\t * @returns {Array<string | symbol>} An array of event names\n\t */\n\tpublic eventNames(): Array<string | symbol> {\n\t\treturn [...this._eventListeners.keys()];\n\t}\n\n\t/**\n\t * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic rawListeners(event?: string | symbol): EventListener[] {\n\t\tif (event === undefined) {\n\t\t\treturn this.getAllListeners();\n\t\t}\n\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Prepends a listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(eventName) ?? [];\n\t\tlisteners.unshift(listener);\n\t\tthis._eventListeners.set(eventName, listeners);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends a one-time listener to the beginning of the listeners array for the specified event\n\t * @param {string | symbol} eventName\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic prependOnceListener(\n\t\teventName: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tconst onceListener: EventListener = (...arguments_: any[]) => {\n\t\t\tthis.off(eventName as string, onceListener);\n\t\t\tlistener(...arguments_);\n\t\t};\n\n\t\tthis.prependListener(eventName as string, onceListener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Gets the maximum number of listeners that can be added for a single event\n\t * @returns {number} The maximum number of listeners\n\t */\n\tpublic maxListeners(): number {\n\t\treturn this._maxListeners;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event. It is an alias for the on() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic addListener(\n\t\tevent: string | symbol,\n\t\tlistener: EventListener,\n\t): IEventEmitter {\n\t\tthis.on(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic on(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tif (!this._eventListeners.has(event)) {\n\t\t\tthis._eventListeners.set(event, []);\n\t\t}\n\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners) {\n\t\t\tif (listeners.length >= this._maxListeners) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event as string} listeners added. Use setMaxListeners() to increase limit.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlisteners.push(listener);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event. It is an alias for the off() method\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeListener(event: string, listener: EventListener): IEventEmitter {\n\t\tthis.off(event, listener);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes a listener for a specific event\n\t * @param {string | symbol} event\n\t * @param {EventListener} listener\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic off(event: string | symbol, listener: EventListener): IEventEmitter {\n\t\tconst listeners = this._eventListeners.get(event) ?? [];\n\t\tconst index = listeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\n\t\tif (listeners.length === 0) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Calls all listeners for a specific event\n\t * @param {string | symbol} event\n\t * @param arguments_ The arguments to pass to the listeners\n\t * @returns {boolean} Returns true if the event had listeners, false otherwise\n\t */\n\tpublic emit(event: string | symbol, ...arguments_: any[]): boolean {\n\t\tlet result = false;\n\t\tconst listeners = this._eventListeners.get(event);\n\n\t\tif (listeners && listeners.length > 0) {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\tlistener(...arguments_);\n\t\t\t\tresult = true;\n\t\t\t}\n\t\t}\n\n\t\tif (event === this._errorEvent) {\n\t\t\tconst error =\n\t\t\t\targuments_[0] instanceof Error\n\t\t\t\t\t? arguments_[0]\n\t\t\t\t\t: new Error(`${arguments_[0]}`);\n\n\t\t\tif (this._throwOnEmitError && !result) {\n\t\t\t\tthrow error;\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tthis.listeners(this._errorEvent).length === 0 &&\n\t\t\t\t\tthis._throwOnEmptyListeners === true\n\t\t\t\t) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Gets all listeners for a specific event. If no event is provided, it returns all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic listeners(event: string | symbol): EventListener[] {\n\t\treturn this._eventListeners.get(event) ?? [];\n\t}\n\n\t/**\n\t * Removes all listeners for a specific event. If no event is provided, it removes all listeners\n\t * @param {string} [event] (Optional) The event name\n\t * @returns {IEventEmitter} returns the instance of the class for chaining\n\t */\n\tpublic removeAllListeners(event?: string | symbol): IEventEmitter {\n\t\tif (event !== undefined) {\n\t\t\tthis._eventListeners.delete(event);\n\t\t} else {\n\t\t\tthis._eventListeners.clear();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum number of listeners that can be added for a single event\n\t * @param {number} n The maximum number of listeners\n\t * @returns {void}\n\t */\n\tpublic setMaxListeners(n: number): void {\n\t\tthis._maxListeners = n;\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tif (listeners.length > n) {\n\t\t\t\tlisteners.splice(n);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Gets all listeners\n\t * @returns {EventListener[]} An array of listeners\n\t */\n\tpublic getAllListeners(): EventListener[] {\n\t\tlet result: EventListener[] = [];\n\t\tfor (const listeners of this._eventListeners.values()) {\n\t\t\tresult = [...result, ...listeners];\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { type EventEmitterOptions, Eventified } from \"./eventified.js\";\n\n// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\nexport type Hook = (...arguments_: any[]) => Promise<void> | void;\n\nexport type HookEntry = {\n\t/**\n\t * The event name for the hook\n\t */\n\tevent: string;\n\t/**\n\t * The handler function for the hook\n\t */\n\thandler: Hook;\n};\n\nexport type HookifiedOptions = {\n\t/**\n\t * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.\n\t */\n\tthrowHookErrors?: boolean;\n\t/**\n\t * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t */\n\tthrowOnHookError?: boolean;\n\t/**\n\t * Whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @type {boolean}\n\t * @default false\n\t */\n\tenforceBeforeAfter?: boolean;\n\t/**\n\t * Map of deprecated hook names to deprecation messages. When a deprecated hook is used, a warning will be emitted.\n\t * @type {Map<string, string>}\n\t * @default new Map()\n\t */\n\tdeprecatedHooks?: Map<string, string>;\n\t/**\n\t * Whether to allow deprecated hooks to be registered and executed. Default is true.\n\t * @type {boolean}\n\t * @default true\n\t */\n\tallowDeprecated?: boolean;\n} & EventEmitterOptions;\n\nexport class Hookified extends Eventified {\n\tprivate readonly _hooks: Map<string, Hook[]>;\n\tprivate _throwOnHookError = false;\n\tprivate _enforceBeforeAfter = false;\n\tprivate _deprecatedHooks: Map<string, string>;\n\tprivate _allowDeprecated = true;\n\n\tconstructor(options?: HookifiedOptions) {\n\t\tsuper({\n\t\t\tlogger: options?.logger,\n\t\t\tthrowOnEmitError: options?.throwOnEmitError,\n\t\t\tthrowOnEmptyListeners: options?.throwOnEmptyListeners,\n\t\t});\n\t\tthis._hooks = new Map();\n\t\tthis._deprecatedHooks = options?.deprecatedHooks\n\t\t\t? new Map(options.deprecatedHooks)\n\t\t\t: new Map();\n\n\t\tif (options?.throwOnHookError !== undefined) {\n\t\t\tthis._throwOnHookError = options.throwOnHookError;\n\t\t} else if (options?.throwHookErrors !== undefined) {\n\t\t\tthis._throwOnHookError = options.throwHookErrors;\n\t\t}\n\n\t\tif (options?.enforceBeforeAfter !== undefined) {\n\t\t\tthis._enforceBeforeAfter = options.enforceBeforeAfter;\n\t\t}\n\n\t\tif (options?.allowDeprecated !== undefined) {\n\t\t\tthis._allowDeprecated = options.allowDeprecated;\n\t\t}\n\t}\n\n\t/**\n\t * Gets all hooks\n\t * @returns {Map<string, Hook[]>}\n\t */\n\tpublic get hooks() {\n\t\treturn this._hooks;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.\n\t */\n\tpublic get throwHookErrors() {\n\t\treturn this._throwOnHookError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.\n\t */\n\tpublic set throwHookErrors(value) {\n\t\tthis._throwOnHookError = value;\n\t}\n\n\t/**\n\t * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @returns {boolean}\n\t */\n\tpublic get throwOnHookError() {\n\t\treturn this._throwOnHookError;\n\t}\n\n\t/**\n\t * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.\n\t * @param {boolean} value\n\t */\n\tpublic set throwOnHookError(value) {\n\t\tthis._throwOnHookError = value;\n\t}\n\n\t/**\n\t * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @returns {boolean}\n\t * @default false\n\t */\n\tpublic get enforceBeforeAfter() {\n\t\treturn this._enforceBeforeAfter;\n\t}\n\n\t/**\n\t * Sets whether to enforce that all hook names start with 'before' or 'after'. Default is false.\n\t * @param {boolean} value\n\t */\n\tpublic set enforceBeforeAfter(value) {\n\t\tthis._enforceBeforeAfter = value;\n\t}\n\n\t/**\n\t * Gets the map of deprecated hook names to deprecation messages.\n\t * @returns {Map<string, string>}\n\t */\n\tpublic get deprecatedHooks() {\n\t\treturn this._deprecatedHooks;\n\t}\n\n\t/**\n\t * Sets the map of deprecated hook names to deprecation messages.\n\t * @param {Map<string, string>} value\n\t */\n\tpublic set deprecatedHooks(value) {\n\t\tthis._deprecatedHooks = value;\n\t}\n\n\t/**\n\t * Gets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @returns {boolean}\n\t */\n\tpublic get allowDeprecated() {\n\t\treturn this._allowDeprecated;\n\t}\n\n\t/**\n\t * Sets whether deprecated hooks are allowed to be registered and executed. Default is true.\n\t * @param {boolean} value\n\t */\n\tpublic set allowDeprecated(value) {\n\t\tthis._allowDeprecated = value;\n\t}\n\n\t/**\n\t * Validates hook event name if enforceBeforeAfter is enabled\n\t * @param {string} event - The event name to validate\n\t * @throws {Error} If enforceBeforeAfter is true and event doesn't start with 'before' or 'after'\n\t */\n\tprivate validateHookName(event: string): void {\n\t\tif (this._enforceBeforeAfter) {\n\t\t\tconst eventValue = event.trim().toLocaleLowerCase();\n\t\t\tif (!eventValue.startsWith(\"before\") && !eventValue.startsWith(\"after\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hook event \"${event}\" must start with \"before\" or \"after\" when enforceBeforeAfter is enabled`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if a hook is deprecated and emits a warning if it is\n\t * @param {string} event - The event name to check\n\t * @returns {boolean} - Returns true if the hook should proceed, false if it should be blocked\n\t */\n\tprivate checkDeprecatedHook(event: string): boolean {\n\t\tif (this._deprecatedHooks.has(event)) {\n\t\t\tconst message = this._deprecatedHooks.get(event);\n\t\t\tconst warningMessage = `Hook \"${event}\" is deprecated${message ? `: ${message}` : \"\"}`;\n\n\t\t\t// Emit deprecation warning event\n\t\t\tthis.emit(\"warn\", { hook: event, message: warningMessage });\n\n\t\t\t// Log to logger if available\n\t\t\tif (this.logger?.warn) {\n\t\t\t\tthis.logger.warn(warningMessage);\n\t\t\t}\n\n\t\t\t// Return false if deprecated hooks are not allowed\n\t\t\treturn this._allowDeprecated;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic onHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.push(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {HookEntry} hookEntry\n\t * @returns {void}\n\t */\n\tpublic onHookEntry(hookEntry: HookEntry) {\n\t\tthis.onHook(hookEntry.event, hookEntry.handler);\n\t}\n\n\t/**\n\t * Alias for onHook. This is provided for compatibility with other libraries that use the `addHook` method.\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic addHook(event: string, handler: Hook) {\n\t\t// Alias for onHook\n\t\tthis.onHook(event, handler);\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic onHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.onHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler function for a specific event that runs before all other handlers\n\t * @param {string} event\n\t * @param {Hook} handler - this can be async or sync\n\t * @returns {void}\n\t */\n\tpublic prependHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\teventHandlers.unshift(handler);\n\t\t} else {\n\t\t\tthis._hooks.set(event, [handler]);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event before all other handlers\n\t * @param event\n\t * @param handler\n\t */\n\tpublic prependOnceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.prependHook(event, hook);\n\t}\n\n\t/**\n\t * Adds a handler that only executes once for a specific event\n\t * @param event\n\t * @param handler\n\t */\n\tpublic onceHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip registration if deprecated hooks are not allowed\n\t\t}\n\t\t// biome-ignore lint/suspicious/noExplicitAny: this is for any parameter compatibility\n\t\tconst hook = async (...arguments_: any[]) => {\n\t\t\tthis.removeHook(event, hook);\n\t\t\treturn handler(...arguments_);\n\t\t};\n\n\t\tthis.onHook(event, hook);\n\t}\n\n\t/**\n\t * Removes a handler function for a specific event\n\t * @param {string} event\n\t * @param {Hook} handler\n\t * @returns {void}\n\t */\n\tpublic removeHook(event: string, handler: Hook) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip removal if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tconst index = eventHandlers.indexOf(handler);\n\t\t\tif (index !== -1) {\n\t\t\t\teventHandlers.splice(index, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes all handlers for a specific event\n\t * @param {Array<HookEntry>} hooks\n\t * @returns {void}\n\t */\n\tpublic removeHooks(hooks: HookEntry[]) {\n\t\tfor (const hook of hooks) {\n\t\t\tthis.removeHook(hook.event, hook.handler);\n\t\t}\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async hook<T>(event: string, ...arguments_: T[]) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn; // Skip execution if deprecated hooks are not allowed\n\t\t}\n\t\tconst eventHandlers = this._hooks.get(event);\n\t\tif (eventHandlers) {\n\t\t\tfor (const handler of eventHandlers) {\n\t\t\t\ttry {\n\t\t\t\t\tawait handler(...arguments_);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = `${event}: ${(error as Error).message}`;\n\t\t\t\t\tthis.emit(\"error\", new Error(message));\n\t\t\t\t\tif (this.logger) {\n\t\t\t\t\t\tthis.logger.error(message);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._throwOnHookError) {\n\t\t\t\t\t\tthrow new Error(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Prepends the word `before` to your hook. Example is event is `test`, the before hook is `before:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async beforeHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`before:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Prepends the word `after` to your hook. Example is event is `test`, the after hook is `after:test`.\n\t * @param {string} event - The event name\n\t * @param {T[]} arguments_ - The arguments to pass to the hook\n\t */\n\tpublic async afterHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(`after:${event}`, ...arguments_);\n\t}\n\n\t/**\n\t * Calls all handlers for a specific event. This is an alias for `hook` and is provided for\n\t * compatibility with other libraries that use the `callHook` method.\n\t * @param {string} event\n\t * @param {T[]} arguments_\n\t * @returns {Promise<void>}\n\t */\n\tpublic async callHook<T>(event: string, ...arguments_: T[]) {\n\t\tawait this.hook(event, ...arguments_);\n\t}\n\n\t/**\n\t * Gets all hooks for a specific event\n\t * @param {string} event\n\t * @returns {Hook[]}\n\t */\n\tpublic getHooks(event: string) {\n\t\tthis.validateHookName(event);\n\t\tif (!this.checkDeprecatedHook(event)) {\n\t\t\treturn undefined; // Return undefined if deprecated hooks are not allowed\n\t\t}\n\t\treturn this._hooks.get(event);\n\t}\n\n\t/**\n\t * Removes all hooks\n\t * @returns {void}\n\t */\n\tpublic clearHooks() {\n\t\tthis._hooks.clear();\n\t}\n}\n\nexport { Eventified, type EventListener } from \"./eventified.js\";\nexport type { Logger } from \"./logger.js\";\n"],"mappings":";;;;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SAAY,UAAkB,YAAiB;AAC3D,UAAM,KAAK,KAAK,OAAO,GAAG,UAAU;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,SAAS,OAAe;AAC9B,SAAK,iBAAiB,KAAK;AAC3B,QAAI,CAAC,KAAK,oBAAoB,KAAK,GAAG;AACrC,aAAO;AAAA,IACR;AACA,WAAO,KAAK,OAAO,IAAI,KAAK;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,aAAa;AACnB,SAAK,OAAO,MAAM;AAAA,EACnB;AACD;","names":[]}
@@ -31,6 +31,8 @@ var Eventified = class {
31
31
  _maxListeners;
32
32
  _logger;
33
33
  _throwOnEmitError = false;
34
+ _throwOnEmptyListeners = false;
35
+ _errorEvent = "error";
34
36
  constructor(options) {
35
37
  this._eventListeners = /* @__PURE__ */ new Map();
36
38
  this._maxListeners = 100;
@@ -38,6 +40,9 @@ var Eventified = class {
38
40
  if (options?.throwOnEmitError !== void 0) {
39
41
  this._throwOnEmitError = options.throwOnEmitError;
40
42
  }
43
+ if (options?.throwOnEmptyListeners !== void 0) {
44
+ this._throwOnEmptyListeners = options.throwOnEmptyListeners;
45
+ }
41
46
  }
42
47
  /**
43
48
  * Gets the logger
@@ -67,6 +72,20 @@ var Eventified = class {
67
72
  set throwOnEmitError(value) {
68
73
  this._throwOnEmitError = value;
69
74
  }
75
+ /**
76
+ * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
77
+ * @returns {boolean}
78
+ */
79
+ get throwOnEmptyListeners() {
80
+ return this._throwOnEmptyListeners;
81
+ }
82
+ /**
83
+ * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
84
+ * @param {boolean} value
85
+ */
86
+ set throwOnEmptyListeners(value) {
87
+ this._throwOnEmptyListeners = value;
88
+ }
70
89
  /**
71
90
  * Adds a handler function for a specific event that will run only once
72
91
  * @param {string | symbol} eventName
@@ -217,10 +236,14 @@ var Eventified = class {
217
236
  result = true;
218
237
  }
219
238
  }
220
- if (event === "error") {
239
+ if (event === this._errorEvent) {
221
240
  const error = arguments_[0] instanceof Error ? arguments_[0] : new Error(`${arguments_[0]}`);
222
241
  if (this._throwOnEmitError && !result) {
223
242
  throw error;
243
+ } else {
244
+ if (this.listeners(this._errorEvent).length === 0 && this._throwOnEmptyListeners === true) {
245
+ throw error;
246
+ }
224
247
  }
225
248
  }
226
249
  return result;
@@ -275,16 +298,22 @@ var Eventified = class {
275
298
  // src/index.ts
276
299
  var Hookified = class extends Eventified {
277
300
  _hooks;
278
- _throwHookErrors = false;
301
+ _throwOnHookError = false;
279
302
  _enforceBeforeAfter = false;
280
303
  _deprecatedHooks;
281
304
  _allowDeprecated = true;
282
305
  constructor(options) {
283
- super({ logger: options?.logger });
306
+ super({
307
+ logger: options?.logger,
308
+ throwOnEmitError: options?.throwOnEmitError,
309
+ throwOnEmptyListeners: options?.throwOnEmptyListeners
310
+ });
284
311
  this._hooks = /* @__PURE__ */ new Map();
285
312
  this._deprecatedHooks = options?.deprecatedHooks ? new Map(options.deprecatedHooks) : /* @__PURE__ */ new Map();
286
- if (options?.throwHookErrors !== void 0) {
287
- this._throwHookErrors = options.throwHookErrors;
313
+ if (options?.throwOnHookError !== void 0) {
314
+ this._throwOnHookError = options.throwOnHookError;
315
+ } else if (options?.throwHookErrors !== void 0) {
316
+ this._throwOnHookError = options.throwHookErrors;
288
317
  }
289
318
  if (options?.enforceBeforeAfter !== void 0) {
290
319
  this._enforceBeforeAfter = options.enforceBeforeAfter;
@@ -303,16 +332,32 @@ var Hookified = class extends Eventified {
303
332
  /**
304
333
  * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
305
334
  * @returns {boolean}
335
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
306
336
  */
307
337
  get throwHookErrors() {
308
- return this._throwHookErrors;
338
+ return this._throwOnHookError;
309
339
  }
310
340
  /**
311
341
  * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
312
342
  * @param {boolean} value
343
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
313
344
  */
314
345
  set throwHookErrors(value) {
315
- this._throwHookErrors = value;
346
+ this._throwOnHookError = value;
347
+ }
348
+ /**
349
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
350
+ * @returns {boolean}
351
+ */
352
+ get throwOnHookError() {
353
+ return this._throwOnHookError;
354
+ }
355
+ /**
356
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
357
+ * @param {boolean} value
358
+ */
359
+ set throwOnHookError(value) {
360
+ this._throwOnHookError = value;
316
361
  }
317
362
  /**
318
363
  * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
@@ -535,7 +580,7 @@ var Hookified = class extends Eventified {
535
580
  if (this.logger) {
536
581
  this.logger.error(message);
537
582
  }
538
- if (this._throwHookErrors) {
583
+ if (this._throwOnHookError) {
539
584
  throw new Error(message);
540
585
  }
541
586
  }
@@ -161,12 +161,19 @@ type EventEmitterOptions = {
161
161
  * Whether to throw an error when emit 'error' and there are no listeners. Default is false and only emits an error event.
162
162
  */
163
163
  throwOnEmitError?: boolean;
164
+ /**
165
+ * Whether to throw on 'error' when there are no listeners. This is the standard functionality in EventEmitter
166
+ * @default false - in v2 this will be set to true by default
167
+ */
168
+ throwOnEmptyListeners?: boolean;
164
169
  };
165
170
  declare class Eventified implements IEventEmitter {
166
171
  private readonly _eventListeners;
167
172
  private _maxListeners;
168
173
  private _logger?;
169
174
  private _throwOnEmitError;
175
+ private _throwOnEmptyListeners;
176
+ private _errorEvent;
170
177
  constructor(options?: EventEmitterOptions);
171
178
  /**
172
179
  * Gets the logger
@@ -188,6 +195,16 @@ declare class Eventified implements IEventEmitter {
188
195
  * @param {boolean} value
189
196
  */
190
197
  set throwOnEmitError(value: boolean);
198
+ /**
199
+ * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
200
+ * @returns {boolean}
201
+ */
202
+ get throwOnEmptyListeners(): boolean;
203
+ /**
204
+ * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
205
+ * @param {boolean} value
206
+ */
207
+ set throwOnEmptyListeners(value: boolean);
191
208
  /**
192
209
  * Adds a handler function for a specific event that will run only once
193
210
  * @param {string | symbol} eventName
@@ -305,8 +322,13 @@ type HookEntry = {
305
322
  type HookifiedOptions = {
306
323
  /**
307
324
  * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
325
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
308
326
  */
309
327
  throwHookErrors?: boolean;
328
+ /**
329
+ * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
330
+ */
331
+ throwOnHookError?: boolean;
310
332
  /**
311
333
  * Whether to enforce that all hook names start with 'before' or 'after'. Default is false.
312
334
  * @type {boolean}
@@ -328,7 +350,7 @@ type HookifiedOptions = {
328
350
  } & EventEmitterOptions;
329
351
  declare class Hookified extends Eventified {
330
352
  private readonly _hooks;
331
- private _throwHookErrors;
353
+ private _throwOnHookError;
332
354
  private _enforceBeforeAfter;
333
355
  private _deprecatedHooks;
334
356
  private _allowDeprecated;
@@ -341,13 +363,25 @@ declare class Hookified extends Eventified {
341
363
  /**
342
364
  * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
343
365
  * @returns {boolean}
366
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
344
367
  */
345
368
  get throwHookErrors(): boolean;
346
369
  /**
347
370
  * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
348
371
  * @param {boolean} value
372
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
349
373
  */
350
374
  set throwHookErrors(value: boolean);
375
+ /**
376
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
377
+ * @returns {boolean}
378
+ */
379
+ get throwOnHookError(): boolean;
380
+ /**
381
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
382
+ * @param {boolean} value
383
+ */
384
+ set throwOnHookError(value: boolean);
351
385
  /**
352
386
  * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
353
387
  * @returns {boolean}
@@ -161,12 +161,19 @@ type EventEmitterOptions = {
161
161
  * Whether to throw an error when emit 'error' and there are no listeners. Default is false and only emits an error event.
162
162
  */
163
163
  throwOnEmitError?: boolean;
164
+ /**
165
+ * Whether to throw on 'error' when there are no listeners. This is the standard functionality in EventEmitter
166
+ * @default false - in v2 this will be set to true by default
167
+ */
168
+ throwOnEmptyListeners?: boolean;
164
169
  };
165
170
  declare class Eventified implements IEventEmitter {
166
171
  private readonly _eventListeners;
167
172
  private _maxListeners;
168
173
  private _logger?;
169
174
  private _throwOnEmitError;
175
+ private _throwOnEmptyListeners;
176
+ private _errorEvent;
170
177
  constructor(options?: EventEmitterOptions);
171
178
  /**
172
179
  * Gets the logger
@@ -188,6 +195,16 @@ declare class Eventified implements IEventEmitter {
188
195
  * @param {boolean} value
189
196
  */
190
197
  set throwOnEmitError(value: boolean);
198
+ /**
199
+ * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
200
+ * @returns {boolean}
201
+ */
202
+ get throwOnEmptyListeners(): boolean;
203
+ /**
204
+ * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
205
+ * @param {boolean} value
206
+ */
207
+ set throwOnEmptyListeners(value: boolean);
191
208
  /**
192
209
  * Adds a handler function for a specific event that will run only once
193
210
  * @param {string | symbol} eventName
@@ -305,8 +322,13 @@ type HookEntry = {
305
322
  type HookifiedOptions = {
306
323
  /**
307
324
  * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
325
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
308
326
  */
309
327
  throwHookErrors?: boolean;
328
+ /**
329
+ * Whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
330
+ */
331
+ throwOnHookError?: boolean;
310
332
  /**
311
333
  * Whether to enforce that all hook names start with 'before' or 'after'. Default is false.
312
334
  * @type {boolean}
@@ -328,7 +350,7 @@ type HookifiedOptions = {
328
350
  } & EventEmitterOptions;
329
351
  declare class Hookified extends Eventified {
330
352
  private readonly _hooks;
331
- private _throwHookErrors;
353
+ private _throwOnHookError;
332
354
  private _enforceBeforeAfter;
333
355
  private _deprecatedHooks;
334
356
  private _allowDeprecated;
@@ -341,13 +363,25 @@ declare class Hookified extends Eventified {
341
363
  /**
342
364
  * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
343
365
  * @returns {boolean}
366
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
344
367
  */
345
368
  get throwHookErrors(): boolean;
346
369
  /**
347
370
  * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
348
371
  * @param {boolean} value
372
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
349
373
  */
350
374
  set throwHookErrors(value: boolean);
375
+ /**
376
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
377
+ * @returns {boolean}
378
+ */
379
+ get throwOnHookError(): boolean;
380
+ /**
381
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
382
+ * @param {boolean} value
383
+ */
384
+ set throwOnHookError(value: boolean);
351
385
  /**
352
386
  * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
353
387
  * @returns {boolean}
@@ -4,6 +4,8 @@ var Eventified = class {
4
4
  _maxListeners;
5
5
  _logger;
6
6
  _throwOnEmitError = false;
7
+ _throwOnEmptyListeners = false;
8
+ _errorEvent = "error";
7
9
  constructor(options) {
8
10
  this._eventListeners = /* @__PURE__ */ new Map();
9
11
  this._maxListeners = 100;
@@ -11,6 +13,9 @@ var Eventified = class {
11
13
  if (options?.throwOnEmitError !== void 0) {
12
14
  this._throwOnEmitError = options.throwOnEmitError;
13
15
  }
16
+ if (options?.throwOnEmptyListeners !== void 0) {
17
+ this._throwOnEmptyListeners = options.throwOnEmptyListeners;
18
+ }
14
19
  }
15
20
  /**
16
21
  * Gets the logger
@@ -40,6 +45,20 @@ var Eventified = class {
40
45
  set throwOnEmitError(value) {
41
46
  this._throwOnEmitError = value;
42
47
  }
48
+ /**
49
+ * Gets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
50
+ * @returns {boolean}
51
+ */
52
+ get throwOnEmptyListeners() {
53
+ return this._throwOnEmptyListeners;
54
+ }
55
+ /**
56
+ * Sets whether an error should be thrown when emitting 'error' event with no listeners. Default is false.
57
+ * @param {boolean} value
58
+ */
59
+ set throwOnEmptyListeners(value) {
60
+ this._throwOnEmptyListeners = value;
61
+ }
43
62
  /**
44
63
  * Adds a handler function for a specific event that will run only once
45
64
  * @param {string | symbol} eventName
@@ -190,10 +209,14 @@ var Eventified = class {
190
209
  result = true;
191
210
  }
192
211
  }
193
- if (event === "error") {
212
+ if (event === this._errorEvent) {
194
213
  const error = arguments_[0] instanceof Error ? arguments_[0] : new Error(`${arguments_[0]}`);
195
214
  if (this._throwOnEmitError && !result) {
196
215
  throw error;
216
+ } else {
217
+ if (this.listeners(this._errorEvent).length === 0 && this._throwOnEmptyListeners === true) {
218
+ throw error;
219
+ }
197
220
  }
198
221
  }
199
222
  return result;
@@ -248,16 +271,22 @@ var Eventified = class {
248
271
  // src/index.ts
249
272
  var Hookified = class extends Eventified {
250
273
  _hooks;
251
- _throwHookErrors = false;
274
+ _throwOnHookError = false;
252
275
  _enforceBeforeAfter = false;
253
276
  _deprecatedHooks;
254
277
  _allowDeprecated = true;
255
278
  constructor(options) {
256
- super({ logger: options?.logger });
279
+ super({
280
+ logger: options?.logger,
281
+ throwOnEmitError: options?.throwOnEmitError,
282
+ throwOnEmptyListeners: options?.throwOnEmptyListeners
283
+ });
257
284
  this._hooks = /* @__PURE__ */ new Map();
258
285
  this._deprecatedHooks = options?.deprecatedHooks ? new Map(options.deprecatedHooks) : /* @__PURE__ */ new Map();
259
- if (options?.throwHookErrors !== void 0) {
260
- this._throwHookErrors = options.throwHookErrors;
286
+ if (options?.throwOnHookError !== void 0) {
287
+ this._throwOnHookError = options.throwOnHookError;
288
+ } else if (options?.throwHookErrors !== void 0) {
289
+ this._throwOnHookError = options.throwHookErrors;
261
290
  }
262
291
  if (options?.enforceBeforeAfter !== void 0) {
263
292
  this._enforceBeforeAfter = options.enforceBeforeAfter;
@@ -276,16 +305,32 @@ var Hookified = class extends Eventified {
276
305
  /**
277
306
  * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
278
307
  * @returns {boolean}
308
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
279
309
  */
280
310
  get throwHookErrors() {
281
- return this._throwHookErrors;
311
+ return this._throwOnHookError;
282
312
  }
283
313
  /**
284
314
  * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
285
315
  * @param {boolean} value
316
+ * @deprecated - this will be deprecated in version 2. Please use throwOnHookError.
286
317
  */
287
318
  set throwHookErrors(value) {
288
- this._throwHookErrors = value;
319
+ this._throwOnHookError = value;
320
+ }
321
+ /**
322
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
323
+ * @returns {boolean}
324
+ */
325
+ get throwOnHookError() {
326
+ return this._throwOnHookError;
327
+ }
328
+ /**
329
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
330
+ * @param {boolean} value
331
+ */
332
+ set throwOnHookError(value) {
333
+ this._throwOnHookError = value;
289
334
  }
290
335
  /**
291
336
  * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
@@ -508,7 +553,7 @@ var Hookified = class extends Eventified {
508
553
  if (this.logger) {
509
554
  this.logger.error(message);
510
555
  }
511
- if (this._throwHookErrors) {
556
+ if (this._throwOnHookError) {
512
557
  throw new Error(message);
513
558
  }
514
559
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hookified",
3
- "version": "1.12.2",
3
+ "version": "1.13.0",
4
4
  "description": "Event Emitting and Middleware Hooks",
5
5
  "type": "module",
6
6
  "main": "dist/node/index.cjs",
@@ -61,21 +61,21 @@
61
61
  },
62
62
  "homepage": "https://github.com/jaredwray/hookified#readme",
63
63
  "devDependencies": {
64
- "@biomejs/biome": "^2.2.6",
64
+ "@biomejs/biome": "^2.3.5",
65
65
  "@monstermann/tinybench-pretty-printer": "^0.2.0",
66
- "@types/node": "^24.7.2",
67
- "@vitest/coverage-v8": "^3.2.4",
68
- "docula": "^0.30.0",
66
+ "@types/node": "^24.10.0",
67
+ "@vitest/coverage-v8": "^4.0.8",
68
+ "docula": "^0.31.0",
69
69
  "emittery": "^1.2.0",
70
70
  "eventemitter3": "^5.0.1",
71
71
  "hookable": "^5.5.3",
72
- "pino": "^10.0.0",
73
- "rimraf": "^6.0.1",
74
- "tinybench": "^5.0.1",
72
+ "pino": "^10.1.0",
73
+ "rimraf": "^6.1.0",
74
+ "tinybench": "^5.1.0",
75
75
  "tsup": "^8.5.0",
76
76
  "tsx": "^4.20.6",
77
77
  "typescript": "^5.9.3",
78
- "vitest": "^3.2.4"
78
+ "vitest": "^4.0.8"
79
79
  },
80
80
  "files": [
81
81
  "dist",