hookified 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,572 @@
1
- var m=Object.defineProperty;var E=(i,t,e)=>t in i?m(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>E(i,typeof t!="symbol"?t+"":t,e);var l=class{constructor(t){o(this,"_eventListeners");o(this,"_maxListeners");o(this,"_logger");o(this,"_throwOnEmitError",!1);this._eventListeners=new Map,this._maxListeners=100,this._logger=t?.logger,t?.throwOnEmitError!==void 0&&(this._throwOnEmitError=t.throwOnEmitError)}get logger(){return this._logger}set logger(t){this._logger=t}get throwOnEmitError(){return this._throwOnEmitError}set throwOnEmitError(t){this._throwOnEmitError=t}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};return this.on(t,r),this}listenerCount(t){if(t===void 0)return this.getAllListeners().length;let e=this._eventListeners.get(t);return e?e.length:0}eventNames(){return[...this._eventListeners.keys()]}rawListeners(t){return t===void 0?this.getAllListeners():this._eventListeners.get(t)??[]}prependListener(t,e){let r=this._eventListeners.get(t)??[];return r.unshift(e),this._eventListeners.set(t,r),this}prependOnceListener(t,e){let r=(...s)=>{this.off(t,r),e(...s)};return this.prependListener(t,r),this}maxListeners(){return this._maxListeners}addListener(t,e){return this.on(t,e),this}on(t,e){this._eventListeners.has(t)||this._eventListeners.set(t,[]);let r=this._eventListeners.get(t);return r&&(r.length>=this._maxListeners&&console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${r.length+1} ${t} listeners added. Use setMaxListeners() to increase limit.`),r.push(e)),this}removeListener(t,e){return this.off(t,e),this}off(t,e){let r=this._eventListeners.get(t)??[],s=r.indexOf(e);return s!==-1&&r.splice(s,1),r.length===0&&this._eventListeners.delete(t),this}emit(t,...e){let r=!1,s=this._eventListeners.get(t);if(s&&s.length>0)for(let n of s)n(...e),r=!0;if(t==="error"){let n=e[0]instanceof Error?e[0]:new Error(`${e[0]}`);if(this._throwOnEmitError&&!r)throw n}return r}listeners(t){return this._eventListeners.get(t)??[]}removeAllListeners(t){return t!==void 0?this._eventListeners.delete(t):this._eventListeners.clear(),this}setMaxListeners(t){this._maxListeners=t;for(let e of this._eventListeners.values())e.length>t&&e.splice(t)}getAllListeners(){let t=[];for(let e of this._eventListeners.values())t=[...t,...e];return t}};var g=class extends l{constructor(e){super({logger:e?.logger});o(this,"_hooks");o(this,"_throwHookErrors",!1);this._hooks=new Map,e?.throwHookErrors!==void 0&&(this._throwHookErrors=e.throwHookErrors)}get hooks(){return this._hooks}get throwHookErrors(){return this._throwHookErrors}set throwHookErrors(e){this._throwHookErrors=e}onHook(e,r){let s=this._hooks.get(e);s?s.push(r):this._hooks.set(e,[r])}onHookEntry(e){this.onHook(e.event,e.handler)}addHook(e,r){this.onHook(e,r)}onHooks(e){for(let r of e)this.onHook(r.event,r.handler)}prependHook(e,r){let s=this._hooks.get(e);s?s.unshift(r):this._hooks.set(e,[r])}prependOnceHook(e,r){let s=async(...n)=>(this.removeHook(e,s),r(...n));this.prependHook(e,s)}onceHook(e,r){let s=async(...n)=>(this.removeHook(e,s),r(...n));this.onHook(e,s)}removeHook(e,r){let s=this._hooks.get(e);if(s){let n=s.indexOf(r);n!==-1&&s.splice(n,1)}}removeHooks(e){for(let r of e)this.removeHook(r.event,r.handler)}async hook(e,...r){let s=this._hooks.get(e);if(s)for(let n of s)try{await n(...r)}catch(a){let h=`${e}: ${a.message}`;if(this.emit("error",new Error(h)),this.logger&&this.logger.error(h),this._throwHookErrors)throw new Error(h)}}async beforeHook(e,...r){await this.hook(`before:${e}`,...r)}async afterHook(e,...r){await this.hook(`after:${e}`,...r)}async callHook(e,...r){await this.hook(e,...r)}getHooks(e){return this._hooks.get(e)}clearHooks(){this._hooks.clear()}};export{l as Eventified,g as Hookified};
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/eventified.ts
6
+ var Eventified = class {
7
+ constructor(options) {
8
+ __publicField(this, "_eventListeners");
9
+ __publicField(this, "_maxListeners");
10
+ __publicField(this, "_logger");
11
+ __publicField(this, "_throwOnEmitError", false);
12
+ this._eventListeners = /* @__PURE__ */ new Map();
13
+ this._maxListeners = 100;
14
+ this._logger = options?.logger;
15
+ if (options?.throwOnEmitError !== void 0) {
16
+ this._throwOnEmitError = options.throwOnEmitError;
17
+ }
18
+ }
19
+ /**
20
+ * Gets the logger
21
+ * @returns {Logger}
22
+ */
23
+ get logger() {
24
+ return this._logger;
25
+ }
26
+ /**
27
+ * Sets the logger
28
+ * @param {Logger} logger
29
+ */
30
+ set logger(logger) {
31
+ this._logger = logger;
32
+ }
33
+ /**
34
+ * Gets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.
35
+ * @returns {boolean}
36
+ */
37
+ get throwOnEmitError() {
38
+ return this._throwOnEmitError;
39
+ }
40
+ /**
41
+ * Sets whether an error should be thrown when an emit throws an error. Default is false and only emits an error event.
42
+ * @param {boolean} value
43
+ */
44
+ set throwOnEmitError(value) {
45
+ this._throwOnEmitError = value;
46
+ }
47
+ /**
48
+ * Adds a handler function for a specific event that will run only once
49
+ * @param {string | symbol} eventName
50
+ * @param {EventListener} listener
51
+ * @returns {IEventEmitter} returns the instance of the class for chaining
52
+ */
53
+ once(eventName, listener) {
54
+ const onceListener = (...arguments_) => {
55
+ this.off(eventName, onceListener);
56
+ listener(...arguments_);
57
+ };
58
+ this.on(eventName, onceListener);
59
+ return this;
60
+ }
61
+ /**
62
+ * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners
63
+ * @param {string} eventName The event name. Not required
64
+ * @returns {number} The number of listeners
65
+ */
66
+ listenerCount(eventName) {
67
+ if (eventName === void 0) {
68
+ return this.getAllListeners().length;
69
+ }
70
+ const listeners = this._eventListeners.get(eventName);
71
+ return listeners ? listeners.length : 0;
72
+ }
73
+ /**
74
+ * Gets an array of event names
75
+ * @returns {Array<string | symbol>} An array of event names
76
+ */
77
+ eventNames() {
78
+ return [...this._eventListeners.keys()];
79
+ }
80
+ /**
81
+ * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners
82
+ * @param {string} [event] (Optional) The event name
83
+ * @returns {EventListener[]} An array of listeners
84
+ */
85
+ rawListeners(event) {
86
+ if (event === void 0) {
87
+ return this.getAllListeners();
88
+ }
89
+ return this._eventListeners.get(event) ?? [];
90
+ }
91
+ /**
92
+ * Prepends a listener to the beginning of the listeners array for the specified event
93
+ * @param {string | symbol} eventName
94
+ * @param {EventListener} listener
95
+ * @returns {IEventEmitter} returns the instance of the class for chaining
96
+ */
97
+ prependListener(eventName, listener) {
98
+ const listeners = this._eventListeners.get(eventName) ?? [];
99
+ listeners.unshift(listener);
100
+ this._eventListeners.set(eventName, listeners);
101
+ return this;
102
+ }
103
+ /**
104
+ * Prepends a one-time listener to the beginning of the listeners array for the specified event
105
+ * @param {string | symbol} eventName
106
+ * @param {EventListener} listener
107
+ * @returns {IEventEmitter} returns the instance of the class for chaining
108
+ */
109
+ prependOnceListener(eventName, listener) {
110
+ const onceListener = (...arguments_) => {
111
+ this.off(eventName, onceListener);
112
+ listener(...arguments_);
113
+ };
114
+ this.prependListener(eventName, onceListener);
115
+ return this;
116
+ }
117
+ /**
118
+ * Gets the maximum number of listeners that can be added for a single event
119
+ * @returns {number} The maximum number of listeners
120
+ */
121
+ maxListeners() {
122
+ return this._maxListeners;
123
+ }
124
+ /**
125
+ * Adds a listener for a specific event. It is an alias for the on() method
126
+ * @param {string | symbol} event
127
+ * @param {EventListener} listener
128
+ * @returns {IEventEmitter} returns the instance of the class for chaining
129
+ */
130
+ addListener(event, listener) {
131
+ this.on(event, listener);
132
+ return this;
133
+ }
134
+ /**
135
+ * Adds a listener for a specific event
136
+ * @param {string | symbol} event
137
+ * @param {EventListener} listener
138
+ * @returns {IEventEmitter} returns the instance of the class for chaining
139
+ */
140
+ on(event, listener) {
141
+ if (!this._eventListeners.has(event)) {
142
+ this._eventListeners.set(event, []);
143
+ }
144
+ const listeners = this._eventListeners.get(event);
145
+ if (listeners) {
146
+ if (listeners.length >= this._maxListeners) {
147
+ console.warn(
148
+ `MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event} listeners added. Use setMaxListeners() to increase limit.`
149
+ );
150
+ }
151
+ listeners.push(listener);
152
+ }
153
+ return this;
154
+ }
155
+ /**
156
+ * Removes a listener for a specific event. It is an alias for the off() method
157
+ * @param {string | symbol} event
158
+ * @param {EventListener} listener
159
+ * @returns {IEventEmitter} returns the instance of the class for chaining
160
+ */
161
+ removeListener(event, listener) {
162
+ this.off(event, listener);
163
+ return this;
164
+ }
165
+ /**
166
+ * Removes a listener for a specific event
167
+ * @param {string | symbol} event
168
+ * @param {EventListener} listener
169
+ * @returns {IEventEmitter} returns the instance of the class for chaining
170
+ */
171
+ off(event, listener) {
172
+ const listeners = this._eventListeners.get(event) ?? [];
173
+ const index = listeners.indexOf(listener);
174
+ if (index !== -1) {
175
+ listeners.splice(index, 1);
176
+ }
177
+ if (listeners.length === 0) {
178
+ this._eventListeners.delete(event);
179
+ }
180
+ return this;
181
+ }
182
+ /**
183
+ * Calls all listeners for a specific event
184
+ * @param {string | symbol} event
185
+ * @param arguments_ The arguments to pass to the listeners
186
+ * @returns {boolean} Returns true if the event had listeners, false otherwise
187
+ */
188
+ emit(event, ...arguments_) {
189
+ let result = false;
190
+ const listeners = this._eventListeners.get(event);
191
+ if (listeners && listeners.length > 0) {
192
+ for (const listener of listeners) {
193
+ listener(...arguments_);
194
+ result = true;
195
+ }
196
+ }
197
+ if (event === "error") {
198
+ const error = arguments_[0] instanceof Error ? arguments_[0] : new Error(`${arguments_[0]}`);
199
+ if (this._throwOnEmitError && !result) {
200
+ throw error;
201
+ }
202
+ }
203
+ return result;
204
+ }
205
+ /**
206
+ * Gets all listeners for a specific event. If no event is provided, it returns all listeners
207
+ * @param {string} [event] (Optional) The event name
208
+ * @returns {EventListener[]} An array of listeners
209
+ */
210
+ listeners(event) {
211
+ return this._eventListeners.get(event) ?? [];
212
+ }
213
+ /**
214
+ * Removes all listeners for a specific event. If no event is provided, it removes all listeners
215
+ * @param {string} [event] (Optional) The event name
216
+ * @returns {IEventEmitter} returns the instance of the class for chaining
217
+ */
218
+ removeAllListeners(event) {
219
+ if (event !== void 0) {
220
+ this._eventListeners.delete(event);
221
+ } else {
222
+ this._eventListeners.clear();
223
+ }
224
+ return this;
225
+ }
226
+ /**
227
+ * Sets the maximum number of listeners that can be added for a single event
228
+ * @param {number} n The maximum number of listeners
229
+ * @returns {void}
230
+ */
231
+ setMaxListeners(n) {
232
+ this._maxListeners = n;
233
+ for (const listeners of this._eventListeners.values()) {
234
+ if (listeners.length > n) {
235
+ listeners.splice(n);
236
+ }
237
+ }
238
+ }
239
+ /**
240
+ * Gets all listeners
241
+ * @returns {EventListener[]} An array of listeners
242
+ */
243
+ getAllListeners() {
244
+ let result = [];
245
+ for (const listeners of this._eventListeners.values()) {
246
+ result = [...result, ...listeners];
247
+ }
248
+ return result;
249
+ }
250
+ };
251
+
252
+ // src/index.ts
253
+ var Hookified = class extends Eventified {
254
+ constructor(options) {
255
+ super({ logger: options?.logger });
256
+ __publicField(this, "_hooks");
257
+ __publicField(this, "_throwHookErrors", false);
258
+ __publicField(this, "_enforceBeforeAfter", false);
259
+ __publicField(this, "_deprecatedHooks");
260
+ __publicField(this, "_allowDeprecated", true);
261
+ this._hooks = /* @__PURE__ */ new Map();
262
+ this._deprecatedHooks = options?.deprecatedHooks ? new Map(options.deprecatedHooks) : /* @__PURE__ */ new Map();
263
+ if (options?.throwHookErrors !== void 0) {
264
+ this._throwHookErrors = options.throwHookErrors;
265
+ }
266
+ if (options?.enforceBeforeAfter !== void 0) {
267
+ this._enforceBeforeAfter = options.enforceBeforeAfter;
268
+ }
269
+ if (options?.allowDeprecated !== void 0) {
270
+ this._allowDeprecated = options.allowDeprecated;
271
+ }
272
+ }
273
+ /**
274
+ * Gets all hooks
275
+ * @returns {Map<string, Hook[]>}
276
+ */
277
+ get hooks() {
278
+ return this._hooks;
279
+ }
280
+ /**
281
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
282
+ * @returns {boolean}
283
+ */
284
+ get throwHookErrors() {
285
+ return this._throwHookErrors;
286
+ }
287
+ /**
288
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
289
+ * @param {boolean} value
290
+ */
291
+ set throwHookErrors(value) {
292
+ this._throwHookErrors = value;
293
+ }
294
+ /**
295
+ * Gets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
296
+ * @returns {boolean}
297
+ * @default false
298
+ */
299
+ get enforceBeforeAfter() {
300
+ return this._enforceBeforeAfter;
301
+ }
302
+ /**
303
+ * Sets whether to enforce that all hook names start with 'before' or 'after'. Default is false.
304
+ * @param {boolean} value
305
+ */
306
+ set enforceBeforeAfter(value) {
307
+ this._enforceBeforeAfter = value;
308
+ }
309
+ /**
310
+ * Gets the map of deprecated hook names to deprecation messages.
311
+ * @returns {Map<string, string>}
312
+ */
313
+ get deprecatedHooks() {
314
+ return this._deprecatedHooks;
315
+ }
316
+ /**
317
+ * Sets the map of deprecated hook names to deprecation messages.
318
+ * @param {Map<string, string>} value
319
+ */
320
+ set deprecatedHooks(value) {
321
+ this._deprecatedHooks = value;
322
+ }
323
+ /**
324
+ * Gets whether deprecated hooks are allowed to be registered and executed. Default is true.
325
+ * @returns {boolean}
326
+ */
327
+ get allowDeprecated() {
328
+ return this._allowDeprecated;
329
+ }
330
+ /**
331
+ * Sets whether deprecated hooks are allowed to be registered and executed. Default is true.
332
+ * @param {boolean} value
333
+ */
334
+ set allowDeprecated(value) {
335
+ this._allowDeprecated = value;
336
+ }
337
+ /**
338
+ * Validates hook event name if enforceBeforeAfter is enabled
339
+ * @param {string} event - The event name to validate
340
+ * @throws {Error} If enforceBeforeAfter is true and event doesn't start with 'before' or 'after'
341
+ */
342
+ validateHookName(event) {
343
+ if (this._enforceBeforeAfter) {
344
+ const eventValue = event.trim().toLocaleLowerCase();
345
+ if (!eventValue.startsWith("before") && !eventValue.startsWith("after")) {
346
+ throw new Error(
347
+ `Hook event "${event}" must start with "before" or "after" when enforceBeforeAfter is enabled`
348
+ );
349
+ }
350
+ }
351
+ }
352
+ /**
353
+ * Checks if a hook is deprecated and emits a warning if it is
354
+ * @param {string} event - The event name to check
355
+ * @returns {boolean} - Returns true if the hook should proceed, false if it should be blocked
356
+ */
357
+ checkDeprecatedHook(event) {
358
+ if (this._deprecatedHooks.has(event)) {
359
+ const message = this._deprecatedHooks.get(event);
360
+ const warningMessage = `Hook "${event}" is deprecated${message ? `: ${message}` : ""}`;
361
+ this.emit("warn", { hook: event, message: warningMessage });
362
+ if (this.logger?.warn) {
363
+ this.logger.warn(warningMessage);
364
+ }
365
+ return this._allowDeprecated;
366
+ }
367
+ return true;
368
+ }
369
+ /**
370
+ * Adds a handler function for a specific event
371
+ * @param {string} event
372
+ * @param {Hook} handler - this can be async or sync
373
+ * @returns {void}
374
+ */
375
+ onHook(event, handler) {
376
+ this.validateHookName(event);
377
+ if (!this.checkDeprecatedHook(event)) {
378
+ return;
379
+ }
380
+ const eventHandlers = this._hooks.get(event);
381
+ if (eventHandlers) {
382
+ eventHandlers.push(handler);
383
+ } else {
384
+ this._hooks.set(event, [handler]);
385
+ }
386
+ }
387
+ /**
388
+ * Adds a handler function for a specific event that runs before all other handlers
389
+ * @param {HookEntry} hookEntry
390
+ * @returns {void}
391
+ */
392
+ onHookEntry(hookEntry) {
393
+ this.onHook(hookEntry.event, hookEntry.handler);
394
+ }
395
+ /**
396
+ * Alias for onHook. This is provided for compatibility with other libraries that use the `addHook` method.
397
+ * @param {string} event
398
+ * @param {Hook} handler - this can be async or sync
399
+ * @returns {void}
400
+ */
401
+ addHook(event, handler) {
402
+ this.onHook(event, handler);
403
+ }
404
+ /**
405
+ * Adds a handler function for a specific event
406
+ * @param {Array<HookEntry>} hooks
407
+ * @returns {void}
408
+ */
409
+ onHooks(hooks) {
410
+ for (const hook of hooks) {
411
+ this.onHook(hook.event, hook.handler);
412
+ }
413
+ }
414
+ /**
415
+ * Adds a handler function for a specific event that runs before all other handlers
416
+ * @param {string} event
417
+ * @param {Hook} handler - this can be async or sync
418
+ * @returns {void}
419
+ */
420
+ prependHook(event, handler) {
421
+ this.validateHookName(event);
422
+ if (!this.checkDeprecatedHook(event)) {
423
+ return;
424
+ }
425
+ const eventHandlers = this._hooks.get(event);
426
+ if (eventHandlers) {
427
+ eventHandlers.unshift(handler);
428
+ } else {
429
+ this._hooks.set(event, [handler]);
430
+ }
431
+ }
432
+ /**
433
+ * Adds a handler that only executes once for a specific event before all other handlers
434
+ * @param event
435
+ * @param handler
436
+ */
437
+ prependOnceHook(event, handler) {
438
+ this.validateHookName(event);
439
+ if (!this.checkDeprecatedHook(event)) {
440
+ return;
441
+ }
442
+ const hook = async (...arguments_) => {
443
+ this.removeHook(event, hook);
444
+ return handler(...arguments_);
445
+ };
446
+ this.prependHook(event, hook);
447
+ }
448
+ /**
449
+ * Adds a handler that only executes once for a specific event
450
+ * @param event
451
+ * @param handler
452
+ */
453
+ onceHook(event, handler) {
454
+ this.validateHookName(event);
455
+ if (!this.checkDeprecatedHook(event)) {
456
+ return;
457
+ }
458
+ const hook = async (...arguments_) => {
459
+ this.removeHook(event, hook);
460
+ return handler(...arguments_);
461
+ };
462
+ this.onHook(event, hook);
463
+ }
464
+ /**
465
+ * Removes a handler function for a specific event
466
+ * @param {string} event
467
+ * @param {Hook} handler
468
+ * @returns {void}
469
+ */
470
+ removeHook(event, handler) {
471
+ this.validateHookName(event);
472
+ if (!this.checkDeprecatedHook(event)) {
473
+ return;
474
+ }
475
+ const eventHandlers = this._hooks.get(event);
476
+ if (eventHandlers) {
477
+ const index = eventHandlers.indexOf(handler);
478
+ if (index !== -1) {
479
+ eventHandlers.splice(index, 1);
480
+ }
481
+ }
482
+ }
483
+ /**
484
+ * Removes all handlers for a specific event
485
+ * @param {Array<HookEntry>} hooks
486
+ * @returns {void}
487
+ */
488
+ removeHooks(hooks) {
489
+ for (const hook of hooks) {
490
+ this.removeHook(hook.event, hook.handler);
491
+ }
492
+ }
493
+ /**
494
+ * Calls all handlers for a specific event
495
+ * @param {string} event
496
+ * @param {T[]} arguments_
497
+ * @returns {Promise<void>}
498
+ */
499
+ async hook(event, ...arguments_) {
500
+ this.validateHookName(event);
501
+ if (!this.checkDeprecatedHook(event)) {
502
+ return;
503
+ }
504
+ const eventHandlers = this._hooks.get(event);
505
+ if (eventHandlers) {
506
+ for (const handler of eventHandlers) {
507
+ try {
508
+ await handler(...arguments_);
509
+ } catch (error) {
510
+ const message = `${event}: ${error.message}`;
511
+ this.emit("error", new Error(message));
512
+ if (this.logger) {
513
+ this.logger.error(message);
514
+ }
515
+ if (this._throwHookErrors) {
516
+ throw new Error(message);
517
+ }
518
+ }
519
+ }
520
+ }
521
+ }
522
+ /**
523
+ * Prepends the word `before` to your hook. Example is event is `test`, the before hook is `before:test`.
524
+ * @param {string} event - The event name
525
+ * @param {T[]} arguments_ - The arguments to pass to the hook
526
+ */
527
+ async beforeHook(event, ...arguments_) {
528
+ await this.hook(`before:${event}`, ...arguments_);
529
+ }
530
+ /**
531
+ * Prepends the word `after` to your hook. Example is event is `test`, the after hook is `after:test`.
532
+ * @param {string} event - The event name
533
+ * @param {T[]} arguments_ - The arguments to pass to the hook
534
+ */
535
+ async afterHook(event, ...arguments_) {
536
+ await this.hook(`after:${event}`, ...arguments_);
537
+ }
538
+ /**
539
+ * Calls all handlers for a specific event. This is an alias for `hook` and is provided for
540
+ * compatibility with other libraries that use the `callHook` method.
541
+ * @param {string} event
542
+ * @param {T[]} arguments_
543
+ * @returns {Promise<void>}
544
+ */
545
+ async callHook(event, ...arguments_) {
546
+ await this.hook(event, ...arguments_);
547
+ }
548
+ /**
549
+ * Gets all hooks for a specific event
550
+ * @param {string} event
551
+ * @returns {Hook[]}
552
+ */
553
+ getHooks(event) {
554
+ this.validateHookName(event);
555
+ if (!this.checkDeprecatedHook(event)) {
556
+ return void 0;
557
+ }
558
+ return this._hooks.get(event);
559
+ }
560
+ /**
561
+ * Removes all hooks
562
+ * @returns {void}
563
+ */
564
+ clearHooks() {
565
+ this._hooks.clear();
566
+ }
567
+ };
568
+ export {
569
+ Eventified,
570
+ Hookified
571
+ };
2
572
  //# sourceMappingURL=index.js.map