mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-24 20:06:55 +01:00
We're migrating to ESM, which will allow us to import the latest versions of our dependencies. Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
15 lines
473 B
TypeScript
15 lines
473 B
TypeScript
import EventEmitter from 'node:events';
|
|
|
|
export const ANY_EVENT = '*';
|
|
|
|
// Extends the built-in EventEmitter with support for listening for any event.
|
|
// See https://stackoverflow.com/a/54431931.
|
|
export class AnyEventEmitter extends EventEmitter {
|
|
emit(type: string, ...args: any[]): boolean {
|
|
super.emit(ANY_EVENT, ...args);
|
|
return super.emit(type, ...args) || super.emit('', ...args);
|
|
}
|
|
}
|
|
|
|
export const sharedEventEmitter = new AnyEventEmitter();
|