@imqueue/core 2.0.26 → 3.1.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.
Files changed (47) hide show
  1. package/README.md +73 -63
  2. package/index.d.ts +0 -1
  3. package/index.js +8 -9
  4. package/package.json +19 -71
  5. package/src/ClusterManager.d.ts +12 -3
  6. package/src/ClusterManager.js +21 -10
  7. package/src/ClusteredRedisQueue.d.ts +45 -14
  8. package/src/ClusteredRedisQueue.js +186 -168
  9. package/src/IMessageQueue.d.ts +89 -96
  10. package/src/IMessageQueue.js +2 -2
  11. package/src/RedisQueue.d.ts +193 -97
  12. package/src/RedisQueue.js +1328 -1068
  13. package/src/UDPClusterManager.d.ts +100 -26
  14. package/src/UDPClusterManager.js +225 -70
  15. package/src/UDPWorker.d.ts +53 -1
  16. package/src/UDPWorker.js +79 -40
  17. package/src/{promisify.d.ts → helpers/buildOptions.d.ts} +8 -15
  18. package/src/helpers/buildOptions.js +39 -0
  19. package/src/{copyEventEmitter.d.ts → helpers/copyEventEmitter.d.ts} +1 -1
  20. package/src/{copyEventEmitter.js → helpers/copyEventEmitter.js} +3 -4
  21. package/src/helpers/envInt.d.ts +32 -0
  22. package/src/helpers/envInt.js +39 -0
  23. package/src/helpers/escapeRegExp.d.ts +30 -0
  24. package/src/helpers/escapeRegExp.js +36 -0
  25. package/src/helpers/index.d.ts +31 -0
  26. package/src/helpers/index.js +48 -0
  27. package/src/helpers/pack.d.ts +7 -0
  28. package/src/helpers/pack.js +37 -0
  29. package/src/helpers/randomInt.d.ts +31 -0
  30. package/src/helpers/randomInt.js +37 -0
  31. package/src/helpers/sha1.d.ts +7 -0
  32. package/src/helpers/sha1.js +39 -0
  33. package/src/helpers/unpack.d.ts +7 -0
  34. package/src/helpers/unpack.js +37 -0
  35. package/src/index.d.ts +1 -14
  36. package/src/index.js +1 -19
  37. package/src/profile.d.ts +28 -38
  38. package/src/profile.js +100 -95
  39. package/src/redis.d.ts +1 -1
  40. package/src/redis.js +4 -2
  41. package/debug.d.ts +0 -1
  42. package/debug_getter.d.ts +0 -9
  43. package/debug_listener.d.ts +0 -1
  44. package/eslint.config.mjs +0 -98
  45. package/src/promisify.js +0 -106
  46. package/src/uuid.d.ts +0 -6
  47. package/src/uuid.js +0 -65
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sha1 = sha1;
4
+ /*!
5
+ * Helper: sha1
6
+ *
7
+ * I'm Queue Software Project
8
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
9
+ *
10
+ * This program is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+ *
23
+ * If you want to use this code in a closed source (commercial) project, you can
24
+ * purchase a proprietary commercial license. Please contact us at
25
+ * <support@imqueue.com> to get commercial licensing options.
26
+ */
27
+ const node_crypto_1 = require("node:crypto");
28
+ /**
29
+ * Returns SHA1 hash sum of the given string
30
+ *
31
+ * @param {string} str
32
+ * @returns {string}
33
+ */
34
+ function sha1(str) {
35
+ const sha = (0, node_crypto_1.createHash)('sha1');
36
+ sha.update(str);
37
+ return sha.digest('hex');
38
+ }
39
+ //# sourceMappingURL=sha1.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Decompresses a binary string and returns the decompressed data
3
+ *
4
+ * @param {string} data - compressed data string
5
+ * @returns {unknown} - decompressed data
6
+ */
7
+ export declare function unpack(data: string): unknown;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unpack = unpack;
4
+ /*!
5
+ * Helper: unpack
6
+ *
7
+ * I'm Queue Software Project
8
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
9
+ *
10
+ * This program is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
+ *
23
+ * If you want to use this code in a closed source (commercial) project, you can
24
+ * purchase a proprietary commercial license. Please contact us at
25
+ * <support@imqueue.com> to get commercial licensing options.
26
+ */
27
+ const node_zlib_1 = require("node:zlib");
28
+ /**
29
+ * Decompresses a binary string and returns the decompressed data
30
+ *
31
+ * @param {string} data - compressed data string
32
+ * @returns {unknown} - decompressed data
33
+ */
34
+ function unpack(data) {
35
+ return JSON.parse((0, node_zlib_1.gunzipSync)(Buffer.from(data, 'binary')).toString());
36
+ }
37
+ //# sourceMappingURL=unpack.js.map
package/src/index.d.ts CHANGED
@@ -19,23 +19,10 @@
19
19
  * purchase a proprietary commercial license. Please contact us at
20
20
  * <support@imqueue.com> to get commercial licensing options.
21
21
  */
22
- /**
23
- * Safely builds full options definition using default options and
24
- * partial given options
25
- *
26
- * @template T
27
- * @param {T} defaultOptions
28
- * @param {Partial<T>} givenOptions
29
- * @return {T}
30
- */
31
- export declare function buildOptions<T>(defaultOptions: T, givenOptions?: Partial<T>): T;
32
- export * from './IMQMode';
33
22
  export * from './profile';
34
- export * from './uuid';
35
- export * from './promisify';
36
23
  export * from './redis';
24
+ export * from './IMQMode';
37
25
  export * from './IMessageQueue';
38
26
  export * from './RedisQueue';
39
27
  export * from './ClusteredRedisQueue';
40
28
  export * from './UDPClusterManager';
41
- export * from './copyEventEmitter';
package/src/index.js CHANGED
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.buildOptions = buildOptions;
18
17
  /*!
19
18
  * I'm Queue Software Project
20
19
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -36,28 +35,11 @@ exports.buildOptions = buildOptions;
36
35
  * purchase a proprietary commercial license. Please contact us at
37
36
  * <support@imqueue.com> to get commercial licensing options.
38
37
  */
39
- // noinspection JSUnusedGlobalSymbols
40
- /**
41
- * Safely builds full options definition using default options and
42
- * partial given options
43
- *
44
- * @template T
45
- * @param {T} defaultOptions
46
- * @param {Partial<T>} givenOptions
47
- * @return {T}
48
- */
49
- // istanbul ignore next
50
- function buildOptions(defaultOptions, givenOptions) {
51
- return Object.assign({}, defaultOptions, givenOptions);
52
- }
53
- __exportStar(require("./IMQMode"), exports);
54
38
  __exportStar(require("./profile"), exports);
55
- __exportStar(require("./uuid"), exports);
56
- __exportStar(require("./promisify"), exports);
57
39
  __exportStar(require("./redis"), exports);
40
+ __exportStar(require("./IMQMode"), exports);
58
41
  __exportStar(require("./IMessageQueue"), exports);
59
42
  __exportStar(require("./RedisQueue"), exports);
60
43
  __exportStar(require("./ClusteredRedisQueue"), exports);
61
44
  __exportStar(require("./UDPClusterManager"), exports);
62
- __exportStar(require("./copyEventEmitter"), exports);
63
45
  //# sourceMappingURL=index.js.map
package/src/profile.d.ts CHANGED
@@ -21,7 +21,6 @@
21
21
  * purchase a proprietary commercial license. Please contact us at
22
22
  * <support@imqueue.com> to get commercial licensing options.
23
23
  */
24
- import 'reflect-metadata';
25
24
  import { ILogger } from '.';
26
25
  export declare enum LogLevel {
27
26
  LOG = "log",
@@ -39,51 +38,49 @@ export interface ProfileDecoratorOptions {
39
38
  */
40
39
  enableDebugArgs?: boolean;
41
40
  /**
42
- * Defines log/level for logger
43
- * By default is log
41
+ * Defines log/level for logger,
42
+ * By default, is a log
44
43
  */
45
44
  logLevel?: LogLevel;
46
45
  }
47
46
  /**
48
- * Checks if log level is set to proper value or returns default one
47
+ * Validates a log level value or returns the default
49
48
  *
50
- * @param {*} level
51
- * @return {LogLevel}
49
+ * @param {unknown} level - the level to validate
50
+ * @returns {LogLevel} - validated log level or INFO if invalid
52
51
  */
53
- export declare function verifyLogLevel(level: any): LogLevel;
52
+ export declare function verifyLogLevel(level: unknown): LogLevel;
54
53
  export declare const IMQ_LOG_LEVEL: LogLevel;
55
54
  export type AllowedTimeFormat = 'microseconds' | 'milliseconds' | 'seconds';
56
55
  /**
57
- * Environment variable IMQ_LOG_TIME=[1, 0] - enables/disables profiled
58
- * timings logging
56
+ * Environment variable IMQ_LOG_TIME=[1, 0]. Enable or disable profiled
57
+ * timing logging.
59
58
  *
60
59
  * @type {boolean}
61
60
  */
62
61
  export declare const IMQ_LOG_TIME: boolean;
63
62
  /**
64
- * Environment variable IMQ_LOG_ARGS=[1, 0] - enables/disables profiled
65
- * call arguments to be logged
63
+ * Environment variable IMQ_LOG_ARGS=[1, 0]. Enable or disable logging of
64
+ * profiled call arguments.
66
65
  *
67
66
  * @type {boolean}
68
67
  */
69
68
  export declare const IMQ_LOG_ARGS: boolean;
70
69
  /**
71
- * Environment variable IMQ_LOG_TIME_FORMAT=[
72
- * 'microseconds',
73
- * 'milliseconds',
74
- * 'seconds'
75
- * ]. Specifies profiled time logging format, by default is 'microseconds'
70
+ * Environment variable IMQ_LOG_TIME_FORMAT. Specifies the format for profiled
71
+ * time logging. Values: 'microseconds', 'milliseconds', 'seconds'.
72
+ * Default: 'microseconds'
76
73
  *
77
74
  * @type {AllowedTimeFormat | string}
78
75
  */
79
76
  export declare const IMQ_LOG_TIME_FORMAT: AllowedTimeFormat;
80
77
  export interface DebugInfoOptions {
81
78
  /**
82
- * Turns on/off time debugging
79
+ * Enable or disable execution time debugging
83
80
  */
84
81
  debugTime: boolean;
85
82
  /**
86
- * Turns on/off args debugging
83
+ * Enable or disable call arguments debugging
87
84
  */
88
85
  debugArgs: boolean;
89
86
  /**
@@ -93,35 +90,28 @@ export interface DebugInfoOptions {
93
90
  /**
94
91
  * Call arguments
95
92
  */
96
- args: any[];
93
+ args: unknown[];
97
94
  /**
98
95
  * Method name
99
96
  */
100
97
  methodName: string;
101
98
  /**
102
- * Execution start timestamp
99
+ * Execution start timestamp (from process.hrtime.bigint or milliseconds)
103
100
  */
104
- start: any;
101
+ start: bigint | number;
105
102
  /**
106
- * Logger implementation
103
+ * Logger implementation (absent when the target carries no logger)
107
104
  */
108
- logger: ILogger;
105
+ logger?: ILogger;
109
106
  /**
110
107
  * Log level to use for the call
111
108
  */
112
109
  logLevel: LogLevel;
113
110
  }
114
111
  /**
115
- * Prints debug information
112
+ * Logs debug information about a function call
116
113
  *
117
- * @param {boolean} debugTime
118
- * @param {boolean} debugArgs
119
- * @param {string} className
120
- * @param {any[]} args
121
- * @param {string} methodName
122
- * @param {number} start
123
- * @param {ILogger} logger
124
- * @param {LogLevel} logLevel
114
+ * @param {DebugInfoOptions} options - debug information options
125
115
  */
126
116
  export declare function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start, logger, logLevel, }: DebugInfoOptions): void;
127
117
  /**
@@ -138,17 +128,17 @@ export declare function logDebugInfo({ debugTime, debugArgs, className, args, me
138
128
  * // ...
139
129
  * }
140
130
  *
141
- * @profile() // profiling happened only depending on env DEBUG flag
131
+ * @profile() // profiling happens only depending on env DEBUG flag
142
132
  * private innerMethod() {
143
133
  * // ...
144
134
  * }
145
135
  * }
146
136
  * ~~~
147
137
  *
148
- * @return {(
149
- * target: any,
150
- * methodName: (string),
151
- * descriptor: TypedPropertyDescriptor<(...args: any[]) => any>
138
+ * @returns {(
139
+ * target: any,
140
+ * methodName: (string),
141
+ * descriptor: TypedPropertyDescriptor<(...args: any[]) => any>,
152
142
  * ) => void}
153
143
  */
154
- export declare function profile(options?: ProfileDecoratorOptions): (target: any, methodName: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>) => void;
144
+ export declare function profile(options?: ProfileDecoratorOptions): any;
package/src/profile.js CHANGED
@@ -4,43 +4,18 @@ exports.IMQ_LOG_TIME_FORMAT = exports.IMQ_LOG_ARGS = exports.IMQ_LOG_TIME = expo
4
4
  exports.verifyLogLevel = verifyLogLevel;
5
5
  exports.logDebugInfo = logDebugInfo;
6
6
  exports.profile = profile;
7
- /*!
8
- * Decorator: @profile
9
- *
10
- * I'm Queue Software Project
11
- * Copyright (C) 2025 imqueue.com <support@imqueue.com>
12
- *
13
- * This program is free software: you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation, either version 3 of the License, or
16
- * (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
25
- *
26
- * If you want to use this code in a closed source (commercial) project, you can
27
- * purchase a proprietary commercial license. Please contact us at
28
- * <support@imqueue.com> to get commercial licensing options.
29
- */
30
- require("reflect-metadata");
31
7
  var LogLevel;
32
8
  (function (LogLevel) {
33
- // noinspection JSUnusedGlobalSymbols
34
9
  LogLevel["LOG"] = "log";
35
10
  LogLevel["INFO"] = "info";
36
11
  LogLevel["WARN"] = "warn";
37
12
  LogLevel["ERROR"] = "error";
38
13
  })(LogLevel || (exports.LogLevel = LogLevel = {}));
39
14
  /**
40
- * Checks if log level is set to proper value or returns default one
15
+ * Validates a log level value or returns the default
41
16
  *
42
- * @param {*} level
43
- * @return {LogLevel}
17
+ * @param {unknown} level - the level to validate
18
+ * @returns {LogLevel} - validated log level or INFO if invalid
44
19
  */
45
20
  function verifyLogLevel(level) {
46
21
  switch (level) {
@@ -58,49 +33,39 @@ const DEFAULT_OPTIONS = {
58
33
  logLevel: exports.IMQ_LOG_LEVEL,
59
34
  };
60
35
  /**
61
- * Environment variable IMQ_LOG_TIME=[1, 0] - enables/disables profiled
62
- * timings logging
36
+ * Environment variable IMQ_LOG_TIME=[1, 0]. Enable or disable profiled
37
+ * timing logging.
63
38
  *
64
39
  * @type {boolean}
65
40
  */
66
41
  exports.IMQ_LOG_TIME = !!+(process.env.IMQ_LOG_TIME || 0);
67
42
  /**
68
- * Environment variable IMQ_LOG_ARGS=[1, 0] - enables/disables profiled
69
- * call arguments to be logged
43
+ * Environment variable IMQ_LOG_ARGS=[1, 0]. Enable or disable logging of
44
+ * profiled call arguments.
70
45
  *
71
46
  * @type {boolean}
72
47
  */
73
48
  exports.IMQ_LOG_ARGS = !!+(process.env.IMQ_LOG_ARGS || 0);
74
49
  /**
75
- * Environment variable IMQ_LOG_TIME_FORMAT=[
76
- * 'microseconds',
77
- * 'milliseconds',
78
- * 'seconds'
79
- * ]. Specifies profiled time logging format, by default is 'microseconds'
50
+ * Environment variable IMQ_LOG_TIME_FORMAT. Specifies the format for profiled
51
+ * time logging. Values: 'microseconds', 'milliseconds', 'seconds'.
52
+ * Default: 'microseconds'
80
53
  *
81
54
  * @type {AllowedTimeFormat | string}
82
55
  */
83
56
  exports.IMQ_LOG_TIME_FORMAT = process.env.IMQ_LOG_TIME_FORMAT || 'microseconds';
84
57
  /**
85
- * Prints debug information
58
+ * Logs debug information about a function call
86
59
  *
87
- * @param {boolean} debugTime
88
- * @param {boolean} debugArgs
89
- * @param {string} className
90
- * @param {any[]} args
91
- * @param {string} methodName
92
- * @param {number} start
93
- * @param {ILogger} logger
94
- * @param {LogLevel} logLevel
60
+ * @param {DebugInfoOptions} options - debug information options
95
61
  */
96
62
  function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start, logger, logLevel, }) {
97
63
  const log = logger && typeof logger[logLevel] === 'function'
98
- ? logger[logLevel].bind(logger) : undefined;
64
+ ? logger[logLevel].bind(logger)
65
+ : undefined;
99
66
  if (debugTime) {
100
- // noinspection TypeScriptUnresolvedFunction
101
- const time = parseInt((process.hrtime.bigint() - BigInt(start)), 10) / 1000;
67
+ const time = Number(process.hrtime.bigint() - BigInt(start)) / 1000;
102
68
  let timeStr;
103
- // istanbul ignore next
104
69
  switch (exports.IMQ_LOG_TIME_FORMAT) {
105
70
  case 'milliseconds':
106
71
  timeStr = (time / 1000).toFixed(3) + ' ms';
@@ -120,13 +85,13 @@ function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start
120
85
  let argStr = '';
121
86
  const cache = [];
122
87
  try {
123
- argStr = JSON.stringify(args, (key, value) => {
88
+ argStr = JSON.stringify(args, (_key, value) => {
124
89
  if (typeof value === 'object' && value !== null) {
125
90
  if (~cache.indexOf(value)) {
126
91
  try {
127
92
  return JSON.parse(JSON.stringify(value));
128
93
  }
129
- catch (error) {
94
+ catch {
130
95
  return;
131
96
  }
132
97
  }
@@ -136,13 +101,56 @@ function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start
136
101
  }, 2);
137
102
  }
138
103
  catch (err) {
139
- logger.error(err);
104
+ logger?.error(err);
140
105
  }
141
106
  if (log) {
142
107
  log(`${className}.${methodName}() called with args: ${argStr}`);
143
108
  }
144
109
  }
145
110
  }
111
+ /**
112
+ * Resolves the class name of a decorated call target — the class itself for
113
+ * a static call, or the instance's constructor for an instance call.
114
+ *
115
+ * @param {unknown} target
116
+ * @returns {string}
117
+ */
118
+ function resolveClassName(target) {
119
+ if (typeof target === 'function') {
120
+ return target.name;
121
+ }
122
+ if (typeof target === 'object' && target !== null) {
123
+ return (target.constructor?.name ??
124
+ '');
125
+ }
126
+ return '';
127
+ }
128
+ /**
129
+ * Extracts the logger instance from a decorated target, if present.
130
+ *
131
+ * @param {unknown} target - the decorated target object
132
+ * @returns {ILogger | undefined} - the logger instance or undefined
133
+ */
134
+ function resolveLogger(target) {
135
+ if (typeof target === 'object' && target !== null) {
136
+ return target.logger;
137
+ }
138
+ return undefined;
139
+ }
140
+ /**
141
+ * Type guard detecting a thenable (promise-like) value. Generic so that
142
+ * narrowing preserves the input type (T & PromiseLike) rather than widening
143
+ * to PromiseLike<unknown> — this keeps the guard usable on a generic return
144
+ * value under stricter/older compiler configurations used by consumers.
145
+ *
146
+ * @param {T} value
147
+ * @returns {value is T & PromiseLike<unknown>}
148
+ */
149
+ function isThenable(value) {
150
+ return ((typeof value === 'object' || typeof value === 'function') &&
151
+ value !== null &&
152
+ typeof value.then === 'function');
153
+ }
146
154
  /**
147
155
  * Implements '@profile' decorator.
148
156
  *
@@ -157,17 +165,17 @@ function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start
157
165
  * // ...
158
166
  * }
159
167
  *
160
- * @profile() // profiling happened only depending on env DEBUG flag
168
+ * @profile() // profiling happens only depending on env DEBUG flag
161
169
  * private innerMethod() {
162
170
  * // ...
163
171
  * }
164
172
  * }
165
173
  * ~~~
166
174
  *
167
- * @return {(
168
- * target: any,
169
- * methodName: (string),
170
- * descriptor: TypedPropertyDescriptor<(...args: any[]) => any>
175
+ * @returns {(
176
+ * target: any,
177
+ * methodName: (string),
178
+ * descriptor: TypedPropertyDescriptor<(...args: any[]) => any>,
171
179
  * ) => void}
172
180
  */
173
181
  function profile(options) {
@@ -181,44 +189,41 @@ function profile(options) {
181
189
  if (typeof enableDebugArgs === 'boolean') {
182
190
  debugArgs = enableDebugArgs;
183
191
  }
184
- return function wrapper(target, methodName, descriptor) {
185
- /* istanbul ignore next */
186
- const original = descriptor.value || target[methodName];
187
- descriptor.value = function (...args) {
188
- if (!(debugTime || debugArgs)) {
189
- return original.apply(this || target, args);
190
- }
191
- /* istanbul ignore next */
192
- const className = typeof target === 'function' && target.name
193
- ? target.name // static
194
- : target.constructor.name; // dynamic
195
- // noinspection TypeScriptUnresolvedFunction
196
- const start = process.hrtime.bigint();
197
- const result = original.apply(this || target, args);
198
- const debugOptions = {
199
- args,
200
- className,
201
- debugArgs,
202
- debugTime,
203
- logLevel: logLevel ? verifyLogLevel(logLevel) : exports.IMQ_LOG_LEVEL,
204
- logger: (this || target).logger,
205
- methodName,
206
- start,
207
- };
208
- /* istanbul ignore next */
209
- if (result && typeof result.then === 'function') {
210
- // async call detected
211
- result.then((res) => {
212
- logDebugInfo(debugOptions);
213
- return res;
214
- }).catch(() => {
215
- logDebugInfo(debugOptions);
216
- });
217
- return result;
218
- }
219
- logDebugInfo(debugOptions);
220
- return result;
192
+ const wrap = (original, methodName) => function wrapper(...args) {
193
+ if (!(debugTime || debugArgs)) {
194
+ return original.apply(this, args);
195
+ }
196
+ const className = resolveClassName(this);
197
+ const logger = resolveLogger(this);
198
+ const start = process.hrtime.bigint();
199
+ const result = original.apply(this, args);
200
+ const debugOptions = {
201
+ args,
202
+ className,
203
+ debugArgs,
204
+ debugTime,
205
+ logLevel: logLevel ? verifyLogLevel(logLevel) : exports.IMQ_LOG_LEVEL,
206
+ logger,
207
+ methodName,
208
+ start,
221
209
  };
210
+ if (isThenable(result)) {
211
+ // async call detected — log once it settles either way
212
+ const logAfter = () => logDebugInfo(debugOptions);
213
+ result.then(logAfter, logAfter);
214
+ return result;
215
+ }
216
+ logDebugInfo(debugOptions);
217
+ return result;
218
+ };
219
+ // Dual-mode: standard (TC39) invocations pass a context object with a
220
+ // `kind` property; legacy ones pass (target, propertyKey, descriptor).
221
+ return function (target, context, descriptor) {
222
+ if (context && typeof context === 'object' && 'kind' in context) {
223
+ return wrap(target, String(context.name));
224
+ }
225
+ descriptor.value = wrap(descriptor.value, String(context));
226
+ return descriptor;
222
227
  };
223
228
  }
224
229
  //# sourceMappingURL=profile.js.map
package/src/redis.d.ts CHANGED
@@ -23,7 +23,7 @@
23
23
  */
24
24
  import Redis from 'ioredis';
25
25
  /**
26
- * Extends default Redis type to allow dynamic properties access on it
26
+ * Extends the default Redis type to allow dynamic properties access on it
27
27
  *
28
28
  * @type {IRedisClient}
29
29
  */
package/src/redis.js CHANGED
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Redis = void 0;
4
7
  /*!
@@ -24,8 +27,7 @@ exports.Redis = void 0;
24
27
  * purchase a proprietary commercial license. Please contact us at
25
28
  * <support@imqueue.com> to get commercial licensing options.
26
29
  */
27
- /* tslint:disable */
28
- const ioredis_1 = require("ioredis");
30
+ const ioredis_1 = __importDefault(require("ioredis"));
29
31
  exports.Redis = ioredis_1.default;
30
32
  exports.default = ioredis_1.default;
31
33
  //# sourceMappingURL=redis.js.map
package/debug.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/debug_getter.d.ts DELETED
@@ -1,9 +0,0 @@
1
- declare class DebugGetter {
2
- name: string;
3
- static propertiesMap: Record<string, string>;
4
- private get property();
5
- private set property(value);
6
- constructor(name: string);
7
- addProperty(value: string): void;
8
- removeProperty(): void;
9
- }
@@ -1 +0,0 @@
1
- export {};