@hastehaul/common 3.12.0 → 3.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'events';
2
- declare class SingletonEventEmitter {
3
- private _instance?;
4
- get instance(): EventEmitter;
5
- init(): void;
2
+ declare class SingletonEventEmitter extends EventEmitter {
3
+ private static _instance;
4
+ private constructor();
5
+ static get instance(): SingletonEventEmitter;
6
6
  }
7
7
  export declare const emitterWrapper: SingletonEventEmitter;
8
8
  export {};
@@ -2,14 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.emitterWrapper = void 0;
4
4
  const events_1 = require("events");
5
- class SingletonEventEmitter {
6
- get instance() {
7
- if (!this._instance)
8
- throw new Error("Can not access EVENT EMITTER client before connecting");
9
- return this._instance;
5
+ class SingletonEventEmitter extends events_1.EventEmitter {
6
+ constructor() {
7
+ super();
10
8
  }
11
- init() {
12
- this._instance = new events_1.EventEmitter();
9
+ static get instance() {
10
+ if (!this._instance) {
11
+ this._instance = new SingletonEventEmitter();
12
+ }
13
+ return this._instance;
13
14
  }
14
15
  }
15
- exports.emitterWrapper = new SingletonEventEmitter();
16
+ // Export the singleton instance
17
+ exports.emitterWrapper = SingletonEventEmitter.instance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "3.12.0",
3
+ "version": "3.13.0",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",