@hastehaul/common 3.11.0 → 3.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.
@@ -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/build/index.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  export * from "./connections-wrappers/redis-connection-wrapper";
8
8
  export * from "./connections-wrappers/redis-wrapper";
9
+ export * from "./connections-wrappers/emitter-wrapper";
9
10
  /**
10
11
  * Re-exports all the contents from the "socket-connection-wrapper" module.
11
12
  *
package/build/index.js CHANGED
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  */
24
24
  __exportStar(require("./connections-wrappers/redis-connection-wrapper"), exports);
25
25
  __exportStar(require("./connections-wrappers/redis-wrapper"), exports);
26
+ __exportStar(require("./connections-wrappers/emitter-wrapper"), exports);
26
27
  /**
27
28
  * Re-exports all the contents from the "socket-connection-wrapper" module.
28
29
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "3.11.0",
3
+ "version": "3.13.0",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",