@imqueue/core 3.1.0 → 3.2.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.
package/index.d.ts CHANGED
@@ -21,8 +21,8 @@
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 { IMessageQueue, IMQMode, IMQOptions } from './src';
25
- export * from './src';
24
+ import { type IMessageQueue, IMQMode, type IMQOptions } from './src/index.js';
25
+ export * from './src/index.js';
26
26
  /**
27
27
  * Message Queue Factory
28
28
  */
package/index.js CHANGED
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  /*!
18
2
  * Message Queue factory for @imqueue/core
19
3
  *
@@ -37,12 +21,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
21
  * purchase a proprietary commercial license. Please contact us at
38
22
  * <support@imqueue.com> to get commercial licensing options.
39
23
  */
40
- const src_1 = require("./src");
41
- __exportStar(require("./src"), exports);
24
+ import { IMQMode, } from './src/index.js';
25
+ import { ClusteredRedisQueue } from './src/index.js';
26
+ import { RedisQueue } from './src/index.js';
27
+ export * from './src/index.js';
28
+ // ES modules provide no synchronous dynamic loading, so the queue adapters
29
+ // are registered statically; the map key matches the previously used
30
+ // `${vendor}Queue` / `Clustered${vendor}Queue` file naming convention
31
+ const ADAPTERS = {
32
+ RedisQueue: RedisQueue,
33
+ ClusteredRedisQueue: ClusteredRedisQueue,
34
+ };
42
35
  /**
43
36
  * Message Queue Factory
44
37
  */
45
- class IMQ {
38
+ export default class IMQ {
46
39
  /**
47
40
  * Base generic queue factory options
48
41
  *
@@ -59,15 +52,17 @@ class IMQ {
59
52
  * @param {IMQMode} mode
60
53
  * @return {IMessageQueue}
61
54
  */
62
- static create(name, options = {}, mode = src_1.IMQMode.BOTH) {
55
+ static create(name, options = {}, mode = IMQMode.BOTH) {
63
56
  options = Object.assign({}, IMQ.options, options);
64
57
  let ClassName = `${options.vendor}Queue`;
65
58
  if (options.cluster || options.clusterManagers) {
66
59
  ClassName = `Clustered${ClassName}`;
67
60
  }
68
- const Adapter = require(`${__dirname}/src/${ClassName}.js`)[ClassName];
61
+ const Adapter = ADAPTERS[ClassName];
62
+ if (!Adapter) {
63
+ throw new TypeError(`IMQ: unknown queue vendor requested: ${options.vendor}`);
64
+ }
69
65
  return new Adapter(name, options, mode);
70
66
  }
71
67
  }
72
- exports.default = IMQ;
73
68
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imqueue/core",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Simple JSON-based messaging queue for inter service communication",
5
5
  "keywords": [
6
6
  "message-queue",
@@ -18,9 +18,9 @@
18
18
  "lint": "oxlint",
19
19
  "format": "oxfmt \"index.ts\" \"src/**/*.ts\" \"test/**/*.ts\" \"benchmark/**/*.ts\"",
20
20
  "format:check": "oxfmt --check \"index.ts\" \"src/**/*.ts\" \"test/**/*.ts\" \"benchmark/**/*.ts\"",
21
- "test": "npm run build && node --experimental-test-module-mocks --test --test-timeout=15000 $(find test -name '*.spec.js')",
22
- "test-coverage": "npm run build && node --experimental-test-module-mocks --enable-source-maps --test --experimental-test-coverage --test-timeout=15000 $(find test -name '*.spec.js')",
23
- "test-lcov": "npm run build && mkdir -p coverage && node --experimental-test-module-mocks --enable-source-maps --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-timeout=15000 $(find test -name '*.spec.js'); node scripts/strip-comment-coverage.mjs coverage/lcov.info",
21
+ "test": "npm run build && node --experimental-test-module-mocks --import ./test/mocks/index.js --test --test-timeout=15000 $(find test -name '*.spec.js')",
22
+ "test-coverage": "npm run build && node --experimental-test-module-mocks --enable-source-maps --import ./test/mocks/index.js --test --experimental-test-coverage --test-timeout=15000 $(find test -name '*.spec.js')",
23
+ "test-lcov": "npm run build && mkdir -p coverage && node --experimental-test-module-mocks --enable-source-maps --import ./test/mocks/index.js --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-timeout=15000 $(find test -name '*.spec.js'); node scripts/strip-comment-coverage.mjs coverage/lcov.info",
24
24
  "test-coverage-html": "npm run test-lcov; genhtml coverage/lcov.info --output-directory coverage/html --ignore-errors inconsistent,corrupt,format,mismatch && echo \"Coverage report: file://$(pwd)/coverage/html/index.html\"",
25
25
  "test-dev": "npm run test && npm run clean-js && npm run clean-typedefs && npm run clean-maps",
26
26
  "clean-typedefs": "find . -name '*.d.ts' -not -wholename '*node_modules*' -not -wholename '*generator*' -type f -delete",
@@ -50,5 +50,20 @@
50
50
  "typescript": "^7.0.2"
51
51
  },
52
52
  "main": "index.js",
53
- "types": "index.d.ts"
53
+ "types": "index.d.ts",
54
+ "type": "module",
55
+ "engines": {
56
+ "node": ">=22.12.0"
57
+ },
58
+ "exports": {
59
+ ".": {
60
+ "types": "./index.d.ts",
61
+ "default": "./index.js"
62
+ },
63
+ "./debug": {
64
+ "types": "./debug.d.ts",
65
+ "default": "./debug.js"
66
+ },
67
+ "./package.json": "./package.json"
68
+ }
54
69
  }
@@ -1,27 +1,4 @@
1
- /*!
2
- * Clustered messaging queue over Redis implementation
3
- *
4
- * I'm Queue Software Project
5
- * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
- *
20
- * If you want to use this code in a closed source (commercial) project, you can
21
- * purchase a proprietary commercial license. Please contact us at
22
- * <support@imqueue.com> to get commercial licensing options.
23
- */
24
- import { IMessageQueueConnection, IServerInput } from './IMessageQueue';
1
+ import { type IMessageQueueConnection, type IServerInput } from './IMessageQueue.js';
25
2
  export interface ICluster {
26
3
  add: (server: IServerInput) => IMessageQueueConnection;
27
4
  remove: (server: IServerInput) => void;
@@ -1,14 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClusterManager = void 0;
4
- const node_crypto_1 = require("node:crypto");
5
- class ClusterManager {
1
+ /*!
2
+ * Clustered messaging queue over Redis implementation
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ import { randomUUID } from 'node:crypto';
25
+ import {} from './IMessageQueue.js';
26
+ export class ClusterManager {
6
27
  clusters = [];
7
28
  constructor() { }
8
29
  init(cluster) {
9
30
  const initializedCluster = {
10
31
  ...cluster,
11
- id: (0, node_crypto_1.randomUUID)(),
32
+ id: randomUUID(),
12
33
  };
13
34
  this.clusters.push(initializedCluster);
14
35
  return initializedCluster;
@@ -35,5 +56,4 @@ class ClusterManager {
35
56
  }
36
57
  }
37
58
  }
38
- exports.ClusterManager = ClusterManager;
39
59
  //# sourceMappingURL=ClusterManager.js.map
@@ -22,7 +22,7 @@
22
22
  * <support@imqueue.com> to get commercial licensing options.
23
23
  */
24
24
  import { EventEmitter } from 'node:events';
25
- import { EventMap, ILogger, IMessageQueue, IMessageQueueConnection, IMQMode, IMQOptions, IServerInput, JsonObject, RedisQueue } from '.';
25
+ import { type EventMap, type ILogger, type IMessageQueue, type IMessageQueueConnection, IMQMode, type IMQOptions, type IServerInput, type JsonObject, RedisQueue } from './index.js';
26
26
  interface ClusterServer extends IMessageQueueConnection {
27
27
  imq?: RedisQueue;
28
28
  }
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClusteredRedisQueue = void 0;
4
1
  /*!
5
2
  * Clustered messaging queue over Redis implementation
6
3
  *
@@ -24,9 +21,10 @@ exports.ClusteredRedisQueue = void 0;
24
21
  * purchase a proprietary commercial license. Please contact us at
25
22
  * <support@imqueue.com> to get commercial licensing options.
26
23
  */
27
- const node_events_1 = require("node:events");
28
- const helpers_1 = require("./helpers");
29
- const _1 = require(".");
24
+ import { EventEmitter } from 'node:events';
25
+ import {} from './ClusterManager.js';
26
+ import { buildOptions, copyEventEmitter } from './helpers/index.js';
27
+ import { DEFAULT_IMQ_OPTIONS, IMQMode, RedisQueue, } from './index.js';
30
28
  /**
31
29
  * Time (ms) send() waits for the first cluster server to become available
32
30
  * before rejecting, when the cluster is still empty. Configurable via the
@@ -38,7 +36,7 @@ const SEND_INIT_TIMEOUT = +(process.env.IMQ_SEND_INIT_TIMEOUT || 0) || 30000;
38
36
  Implements the possibility to scale queues horizontally between several
39
37
  * redis instances.
40
38
  */
41
- class ClusteredRedisQueue {
39
+ export class ClusteredRedisQueue {
42
40
  name;
43
41
  /**
44
42
  * Logger instance associated with this queue instance
@@ -113,11 +111,11 @@ class ClusteredRedisQueue {
113
111
  * @param {Partial<IMQOptions>} options
114
112
  * @param {IMQMode} [_mode]
115
113
  */
116
- constructor(name, options, _mode = _1.IMQMode.BOTH) {
114
+ constructor(name, options, _mode = IMQMode.BOTH) {
117
115
  this.name = name;
118
- this.templateEmitter = new node_events_1.EventEmitter();
119
- this.clusterEmitter = new node_events_1.EventEmitter();
120
- this.options = (0, helpers_1.buildOptions)(_1.DEFAULT_IMQ_OPTIONS, options);
116
+ this.templateEmitter = new EventEmitter();
117
+ this.clusterEmitter = new EventEmitter();
118
+ this.options = buildOptions(DEFAULT_IMQ_OPTIONS, options);
121
119
  this.logger = this.options.logger || console;
122
120
  if (!this.options.cluster && !this.options.clusterManagers?.length) {
123
121
  throw new TypeError('ClusteredRedisQueue: cluster ' + 'configuration is missing!');
@@ -429,8 +427,8 @@ class ClusteredRedisQueue {
429
427
  port: server.port,
430
428
  };
431
429
  const opts = { ...this.mqOptions, ...newServer };
432
- const imq = new _1.RedisQueue(this.name, opts);
433
- (0, helpers_1.copyEventEmitter)(this.templateEmitter, imq);
430
+ const imq = new RedisQueue(this.name, opts);
431
+ copyEventEmitter(this.templateEmitter, imq);
434
432
  if (initializeQueue) {
435
433
  this.initializeQueue(imq).then(() => {
436
434
  this.clusterEmitter.emit('initialized', {
@@ -470,5 +468,4 @@ class ClusteredRedisQueue {
470
468
  return sameId || sameAddress;
471
469
  }
472
470
  }
473
- exports.ClusteredRedisQueue = ClusteredRedisQueue;
474
471
  //# sourceMappingURL=ClusteredRedisQueue.js.map
package/src/IMQMode.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IMQMode = void 0;
4
1
  /*!
5
2
  * I'm Queue Software Project
6
3
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -22,10 +19,10 @@ exports.IMQMode = void 0;
22
19
  * purchase a proprietary commercial license. Please contact us at
23
20
  * <support@imqueue.com> to get commercial licensing options.
24
21
  */
25
- var IMQMode;
22
+ export var IMQMode;
26
23
  (function (IMQMode) {
27
24
  IMQMode[IMQMode["BOTH"] = 0] = "BOTH";
28
25
  IMQMode[IMQMode["WORKER"] = 1] = "WORKER";
29
26
  IMQMode[IMQMode["PUBLISHER"] = 2] = "PUBLISHER";
30
- })(IMQMode || (exports.IMQMode = IMQMode = {}));
27
+ })(IMQMode || (IMQMode = {}));
31
28
  //# sourceMappingURL=IMQMode.js.map
@@ -22,8 +22,8 @@
22
22
  * <support@imqueue.com> to get commercial licensing options.
23
23
  */
24
24
  import { EventEmitter } from 'node:events';
25
- import { IMQMode } from './IMQMode';
26
- import { ClusterManager } from './ClusterManager';
25
+ import { IMQMode } from './IMQMode.js';
26
+ import { ClusterManager } from './ClusterManager.js';
27
27
  export { EventEmitter } from 'node:events';
28
28
  /**
29
29
  * Represents any JSON-serializable value
@@ -1,6 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventEmitter = void 0;
4
- var node_events_1 = require("node:events");
5
- Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return node_events_1.EventEmitter; } });
1
+ /*!
2
+ * Basic types and interfaces
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ import { EventEmitter } from 'node:events';
25
+ import { IMQMode } from './IMQMode.js';
26
+ import { ClusterManager } from './ClusterManager.js';
27
+ export { EventEmitter } from 'node:events';
6
28
  //# sourceMappingURL=IMessageQueue.js.map
@@ -22,7 +22,7 @@
22
22
  * <support@imqueue.com> to get commercial licensing options.
23
23
  */
24
24
  import { EventEmitter } from 'node:events';
25
- import { IMessageQueue, JsonObject, IMQOptions, IMQMode, EventMap } from '.';
25
+ import { type IMessageQueue, type JsonObject, type IMQOptions, IMQMode, type EventMap } from './index.js';
26
26
  export declare const DEFAULT_IMQ_OPTIONS: IMQOptions;
27
27
  export declare const IMQ_SHUTDOWN_TIMEOUT: number;
28
28
  /**
package/src/RedisQueue.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
2
  var useValue = arguments.length > 2;
4
3
  for (var i = 0; i < initializers.length; i++) {
@@ -33,11 +32,6 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
33
32
  if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
33
  done = true;
35
34
  };
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.RedisQueue = exports.IMQ_CONNECTION_QUIT_TIMEOUT = exports.IMQ_SHUTDOWN_TIMEOUT = exports.DEFAULT_IMQ_OPTIONS = void 0;
41
35
  /*!
42
36
  * Fast messaging queue over Redis
43
37
  *
@@ -61,12 +55,12 @@ exports.RedisQueue = exports.IMQ_CONNECTION_QUIT_TIMEOUT = exports.IMQ_SHUTDOWN_
61
55
  * purchase a proprietary commercial license. Please contact us at
62
56
  * <support@imqueue.com> to get commercial licensing options.
63
57
  */
64
- const node_events_1 = require("node:events");
65
- const node_crypto_1 = require("node:crypto");
66
- const node_os_1 = require("node:os");
67
- const _1 = require(".");
68
- const helpers_1 = require("./helpers");
69
- const redis_1 = __importDefault(require("./redis"));
58
+ import { EventEmitter } from 'node:events';
59
+ import { randomUUID } from 'node:crypto';
60
+ import { hostname } from 'node:os';
61
+ import { IMQMode, profile, } from './index.js';
62
+ import { buildOptions, escapeRegExp, randomInt, pack, sha1, unpack, envInt, } from './helpers/index.js';
63
+ import Redis from './redis.js';
70
64
  const RX_CLIENT_NAME = /name=(\S+)/g;
71
65
  const RX_CLIENT_TEST = /:(reader|writer|watcher)/;
72
66
  const RX_CLIENT_CLEAN = /:(reader|writer|watcher).*$/;
@@ -94,7 +88,7 @@ function noRetryStrategy() {
94
88
  function delay(ms) {
95
89
  return new Promise(resolve => setTimeout(resolve, ms));
96
90
  }
97
- exports.DEFAULT_IMQ_OPTIONS = {
91
+ export const DEFAULT_IMQ_OPTIONS = {
98
92
  host: 'localhost',
99
93
  port: 6379,
100
94
  cleanup: false,
@@ -107,21 +101,21 @@ exports.DEFAULT_IMQ_OPTIONS = {
107
101
  watcherCheckDelay: 5000,
108
102
  handleSignals: true,
109
103
  };
110
- exports.IMQ_SHUTDOWN_TIMEOUT = (0, helpers_1.envInt)('IMQ_SHUTDOWN_TIMEOUT', 1000);
104
+ export const IMQ_SHUTDOWN_TIMEOUT = envInt('IMQ_SHUTDOWN_TIMEOUT', 1000);
111
105
  /**
112
106
  * Grace period (ms) for a graceful QUIT to complete before a channel is
113
107
  * forcibly disconnected. A reader blocked on an infinite BRPOP/BLMOVE can
114
108
  * never let QUIT through, so without this the socket would leak and keep
115
109
  * the process alive.
116
110
  */
117
- exports.IMQ_CONNECTION_QUIT_TIMEOUT = (0, helpers_1.envInt)('IMQ_CONNECTION_QUIT_TIMEOUT', 1000);
118
- const IMQ_REDIS_MAX_LISTENERS_LIMIT = (0, helpers_1.envInt)('IMQ_REDIS_MAX_LISTENERS_LIMIT', 10000);
111
+ export const IMQ_CONNECTION_QUIT_TIMEOUT = envInt('IMQ_CONNECTION_QUIT_TIMEOUT', 1000);
112
+ const IMQ_REDIS_MAX_LISTENERS_LIMIT = envInt('IMQ_REDIS_MAX_LISTENERS_LIMIT', 10000);
119
113
  /**
120
114
  * Class RedisQueue
121
115
  * Implements a simple messaging queue over redis.
122
116
  */
123
117
  let RedisQueue = (() => {
124
- let _classSuper = node_events_1.EventEmitter;
118
+ let _classSuper = EventEmitter;
125
119
  let _instanceExtraInitializers = [];
126
120
  let _stop_decorators;
127
121
  let _destroy_decorators;
@@ -133,13 +127,13 @@ let RedisQueue = (() => {
133
127
  return class RedisQueue extends _classSuper {
134
128
  static {
135
129
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
136
- _stop_decorators = [(0, _1.profile)()];
137
- _destroy_decorators = [(0, _1.profile)()];
138
- _clear_decorators = [(0, _1.profile)()];
139
- _queueLength_decorators = [(0, _1.profile)()];
140
- _destroyWatcher_decorators = [(0, _1.profile)()];
141
- _destroyWriter_decorators = [(0, _1.profile)()];
142
- _destroyChannel_decorators = [(0, _1.profile)()];
130
+ _stop_decorators = [profile()];
131
+ _destroy_decorators = [profile()];
132
+ _clear_decorators = [profile()];
133
+ _queueLength_decorators = [profile()];
134
+ _destroyWatcher_decorators = [profile()];
135
+ _destroyWriter_decorators = [profile()];
136
+ _destroyChannel_decorators = [profile()];
143
137
  __esDecorate(this, null, _stop_decorators, { kind: "method", name: "stop", static: false, private: false, access: { has: obj => "stop" in obj, get: obj => obj.stop }, metadata: _metadata }, null, _instanceExtraInitializers);
144
138
  __esDecorate(this, null, _destroy_decorators, { kind: "method", name: "destroy", static: false, private: false, access: { has: obj => "destroy" in obj, get: obj => obj.destroy }, metadata: _metadata }, null, _instanceExtraInitializers);
145
139
  __esDecorate(this, null, _clear_decorators, { kind: "method", name: "clear", static: false, private: false, access: { has: obj => "clear" in obj, get: obj => obj.clear }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -310,16 +304,16 @@ let RedisQueue = (() => {
310
304
  * @param {IMQOptions} [options]
311
305
  * @param {IMQMode} [mode]
312
306
  */
313
- constructor(name, options, mode = _1.IMQMode.BOTH) {
307
+ constructor(name, options, mode = IMQMode.BOTH) {
314
308
  super();
315
309
  this.name = name;
316
310
  this.mode = mode;
317
- this.options = (0, helpers_1.buildOptions)(exports.DEFAULT_IMQ_OPTIONS, options);
318
- this.pack = this.options.useGzip ? helpers_1.pack : JSON.stringify;
319
- this.unpack = this.options.useGzip ? helpers_1.unpack : JSON.parse;
311
+ this.options = buildOptions(DEFAULT_IMQ_OPTIONS, options);
312
+ this.pack = this.options.useGzip ? pack : JSON.stringify;
313
+ this.unpack = this.options.useGzip ? unpack : JSON.parse;
320
314
  this.redisKey = `${this.options.host}:${this.options.port}`;
321
315
  for (const script of Object.keys(this.scripts)) {
322
- this.scripts[script].checksum = (0, helpers_1.sha1)(this.scripts[script].code);
316
+ this.scripts[script].checksum = sha1(this.scripts[script].code);
323
317
  }
324
318
  this.verbose(`Initializing queue on ${this.options.host}:${this.options.port} with prefix ${this.options.prefix} and safeDelivery = ${this.options.safeDelivery}, and safeDeliveryTtl = ${this.options.safeDeliveryTtl}, and watcherCheckDelay = ${this.options.watcherCheckDelay}, and useGzip = ${this.options.useGzip}`);
325
319
  }
@@ -502,7 +496,7 @@ let RedisQueue = (() => {
502
496
  let exitCode = 0;
503
497
  const timer = setTimeout(() => {
504
498
  process.exit(exitCode || 1);
505
- }, exports.IMQ_SHUTDOWN_TIMEOUT);
499
+ }, IMQ_SHUTDOWN_TIMEOUT);
506
500
  await Promise.all([...RedisQueue.instances]
507
501
  .filter(queue => queue.watchOwner)
508
502
  .map(queue => queue.unlock().catch(err => {
@@ -580,7 +574,7 @@ let RedisQueue = (() => {
580
574
  if (!this.writer) {
581
575
  throw new TypeError('IMQ: unable to initialize queue!');
582
576
  }
583
- const id = (0, node_crypto_1.randomUUID)();
577
+ const id = randomUUID();
584
578
  const data = { id, message, from: this.name };
585
579
  const key = `${this.options.prefix}:${toQueue}`;
586
580
  const packet = this.pack(data);
@@ -710,7 +704,7 @@ let RedisQueue = (() => {
710
704
  * @returns {boolean}
711
705
  */
712
706
  isPublisher() {
713
- return this.mode === _1.IMQMode.BOTH || this.mode === _1.IMQMode.PUBLISHER;
707
+ return this.mode === IMQMode.BOTH || this.mode === IMQMode.PUBLISHER;
714
708
  }
715
709
  /**
716
710
  * Returns true if worker mode is enabled on this queue, false otherwise.
@@ -718,7 +712,7 @@ let RedisQueue = (() => {
718
712
  * @returns {boolean}
719
713
  */
720
714
  isWorker() {
721
- return this.mode === _1.IMQMode.BOTH || this.mode === _1.IMQMode.WORKER;
715
+ return this.mode === IMQMode.BOTH || this.mode === IMQMode.WORKER;
722
716
  }
723
717
  /**
724
718
  * Returns false only when this queue is known to be unable to accept
@@ -888,7 +882,7 @@ let RedisQueue = (() => {
888
882
  // forced disconnect after a short grace period to avoid leaking
889
883
  // the socket (which would keep the process alive)
890
884
  client.quit().then(forceDisconnect, forceDisconnect);
891
- const timer = setTimeout(forceDisconnect, exports.IMQ_CONNECTION_QUIT_TIMEOUT);
885
+ const timer = setTimeout(forceDisconnect, IMQ_CONNECTION_QUIT_TIMEOUT);
892
886
  // the grace timer itself must not keep the process alive; while
893
887
  // the leaked socket keeps the loop running the timer still fires
894
888
  timer.unref();
@@ -910,7 +904,7 @@ let RedisQueue = (() => {
910
904
  if (existing) {
911
905
  return existing;
912
906
  }
913
- const redis = new redis_1.default({
907
+ const redis = new Redis({
914
908
  port: options.port || 6379,
915
909
  host: options.host || 'localhost',
916
910
  username: options.username,
@@ -1035,7 +1029,7 @@ let RedisQueue = (() => {
1035
1029
  * @returns {string}
1036
1030
  */
1037
1031
  getChannelName(contextName, prefix, name) {
1038
- const uniqueSuffix = `pid:${process.pid}:host:${(0, node_os_1.hostname)()}`;
1032
+ const uniqueSuffix = `pid:${process.pid}:host:${hostname()}`;
1039
1033
  return `${prefix}:${contextName}:${name}:${uniqueSuffix}`;
1040
1034
  }
1041
1035
  /**
@@ -1103,7 +1097,7 @@ let RedisQueue = (() => {
1103
1097
  if (!this.writer) {
1104
1098
  return 0;
1105
1099
  }
1106
- const rx = new RegExp(`\\bname=${(0, helpers_1.escapeRegExp)(this.options.prefix || '')}:\\S+?:watcher:`);
1100
+ const rx = new RegExp(`\\bname=${escapeRegExp(this.options.prefix || '')}:\\S+?:watcher:`);
1107
1101
  const list = (await this.writer.client('LIST'));
1108
1102
  if (!list || !list.split) {
1109
1103
  return 0;
@@ -1275,9 +1269,9 @@ let RedisQueue = (() => {
1275
1269
  if (!this.options.cleanup) {
1276
1270
  return;
1277
1271
  }
1278
- const filter = new RegExp((0, helpers_1.escapeRegExp)(this.options.prefix || '') +
1272
+ const filter = new RegExp(escapeRegExp(this.options.prefix || '') +
1279
1273
  ':' +
1280
- (0, helpers_1.escapeRegExp)(this.options.cleanupFilter || '*').replace(/\\\*/g, '.*'), 'i');
1274
+ escapeRegExp(this.options.cleanupFilter || '*').replace(/\\\*/g, '.*'), 'i');
1281
1275
  this.verbose(`Cleaning up keys matching ${filter}`);
1282
1276
  const clients = (await this.writer.client('LIST')).toString() || '';
1283
1277
  const connectedKeys = (clients.match(RX_CLIENT_NAME) || [])
@@ -1369,7 +1363,7 @@ let RedisQueue = (() => {
1369
1363
  break;
1370
1364
  }
1371
1365
  const expire = Date.now() + Number(this.options.safeDeliveryTtl);
1372
- const workerKey = `${key}:worker:${(0, node_crypto_1.randomUUID)()}:${expire}`;
1366
+ const workerKey = `${key}:worker:${randomUUID()}:${expire}`;
1373
1367
  let msg;
1374
1368
  try {
1375
1369
  msg = await this.reader.blmove(this.key, workerKey, 'RIGHT', 'LEFT', timeout);
@@ -1522,7 +1516,7 @@ let RedisQueue = (() => {
1522
1516
  // another instance may hold the lock while its watcher died:
1523
1517
  // wait a small random interval (to avoid a thundering herd) and
1524
1518
  // try to resolve the possible deadlock
1525
- await delay((0, helpers_1.randomInt)(1, 50));
1519
+ await delay(randomInt(1, 50));
1526
1520
  await this.resolveWatchLock();
1527
1521
  }
1528
1522
  catch (err) {
@@ -1532,5 +1526,5 @@ let RedisQueue = (() => {
1532
1526
  }
1533
1527
  };
1534
1528
  })();
1535
- exports.RedisQueue = RedisQueue;
1529
+ export { RedisQueue };
1536
1530
  //# sourceMappingURL=RedisQueue.js.map
@@ -1,5 +1,5 @@
1
- import { ClusterManager } from './ClusterManager';
2
- import { ILogger } from './IMessageQueue';
1
+ import { ClusterManager } from './ClusterManager.js';
2
+ import { type ILogger } from './IMessageQueue.js';
3
3
  export interface UDPClusterManagerOptions {
4
4
  /**
5
5
  * Message queue broadcast port
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UDPClusterManager = exports.DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS = void 0;
4
1
  /*!
5
2
  * UDP message listener for cluster managing
6
3
  *
@@ -24,13 +21,14 @@ exports.UDPClusterManager = exports.DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS = void 0
24
21
  * purchase a proprietary commercial license. Please contact us at
25
22
  * <support@imqueue.com> to get commercial licensing options.
26
23
  */
27
- const node_path_1 = require("node:path");
28
- const node_worker_threads_1 = require("node:worker_threads");
29
- const ClusterManager_1 = require("./ClusterManager");
24
+ import { join } from 'node:path';
25
+ import { Worker } from 'node:worker_threads';
26
+ import { ClusterManager } from './ClusterManager.js';
27
+ import {} from './IMessageQueue.js';
30
28
  const IMQ_UDP_CLUSTER_MANAGER_ALIVE_CHECK = !!+(process.env.IMQ_UDP_CLUSTER_MANAGER_ALIVE_CHECK || 1);
31
29
  /** Delay (ms) before an unexpectedly dead worker is re-spawned */
32
30
  const WORKER_RESPAWN_DELAY = 1000;
33
- exports.DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS = {
31
+ export const DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS = {
34
32
  port: 63000,
35
33
  address: '255.255.255.255',
36
34
  aliveTimeoutCorrection: 5000,
@@ -38,7 +36,7 @@ exports.DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS = {
38
36
  handleSignals: true,
39
37
  logger: console,
40
38
  };
41
- class UDPClusterManager extends ClusterManager_1.ClusterManager {
39
+ export class UDPClusterManager extends ClusterManager {
42
40
  static workers = {};
43
41
  /** Number of manager instances sharing each worker (by worker key) */
44
42
  static workerRefs = {};
@@ -61,7 +59,7 @@ class UDPClusterManager extends ClusterManager_1.ClusterManager {
61
59
  constructor(options) {
62
60
  super();
63
61
  this.options = {
64
- ...exports.DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS,
62
+ ...DEFAULT_UDP_CLUSTER_MANAGER_OPTIONS,
65
63
  ...options,
66
64
  };
67
65
  this.startWorkerListener();
@@ -154,7 +152,7 @@ class UDPClusterManager extends ClusterManager_1.ClusterManager {
154
152
  aliveTimeoutCorrection: this.options.aliveTimeoutCorrection,
155
153
  useAliveCheck: this.options.useAliveCheck,
156
154
  };
157
- const worker = new node_worker_threads_1.Worker((0, node_path_1.join)(__dirname, './UDPWorker.js'), {
155
+ const worker = new Worker(join(import.meta.dirname, './UDPWorker.js'), {
158
156
  workerData,
159
157
  });
160
158
  const workerKey = this.workerKey;
@@ -292,5 +290,4 @@ class UDPClusterManager extends ClusterManager_1.ClusterManager {
292
290
  });
293
291
  }
294
292
  }
295
- exports.UDPClusterManager = UDPClusterManager;
296
293
  //# sourceMappingURL=UDPClusterManager.js.map
@@ -23,7 +23,7 @@
23
23
  * <support@imqueue.com> to get commercial licensing options.
24
24
  */
25
25
  import { MessagePort } from 'node:worker_threads';
26
- import { UDPWorkerOptions } from './UDPClusterManager';
26
+ import { type UDPWorkerOptions } from './UDPClusterManager.js';
27
27
  export declare class UDPWorker {
28
28
  private readonly options;
29
29
  private readonly messagePort;
package/src/UDPWorker.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UDPWorker = void 0;
4
1
  /*!
5
2
  * UDP message listener for cluster managing: Worker for processing
6
3
  * messages
@@ -25,16 +22,17 @@ exports.UDPWorker = void 0;
25
22
  * purchase a proprietary commercial license. Please contact us at
26
23
  * <support@imqueue.com> to get commercial licensing options.
27
24
  */
28
- const node_worker_threads_1 = require("node:worker_threads");
29
- const node_dgram_1 = require("node:dgram");
30
- const node_os_1 = require("node:os");
31
- const node_crypto_1 = require("node:crypto");
25
+ import { isMainThread, parentPort, workerData, MessagePort, } from 'node:worker_threads';
26
+ import { createSocket } from 'node:dgram';
27
+ import { networkInterfaces } from 'node:os';
28
+ import { randomUUID } from 'node:crypto';
29
+ import {} from './UDPClusterManager.js';
32
30
  var MessageType;
33
31
  (function (MessageType) {
34
32
  MessageType["Up"] = "up";
35
33
  MessageType["Down"] = "down";
36
34
  })(MessageType || (MessageType = {}));
37
- class UDPWorker {
35
+ export class UDPWorker {
38
36
  options;
39
37
  messagePort;
40
38
  socket;
@@ -43,7 +41,7 @@ class UDPWorker {
43
41
  this.options = options;
44
42
  this.messagePort = messagePort;
45
43
  this.setupMessageHandlers();
46
- this.socket = (0, node_dgram_1.createSocket)({
44
+ this.socket = createSocket({
47
45
  type: 'udp4',
48
46
  reuseAddr: true,
49
47
  reusePort: true,
@@ -109,7 +107,7 @@ class UDPWorker {
109
107
  };
110
108
  }
111
109
  serverAliveWait(message) {
112
- const stamp = (0, node_crypto_1.randomUUID)();
110
+ const stamp = randomUUID();
113
111
  const correction = this.options.aliveTimeoutCorrection ?? 0;
114
112
  const effectiveTimeout = message.timeout + correction + 1;
115
113
  const key = UDPWorker.getServerKey(message);
@@ -131,7 +129,7 @@ class UDPWorker {
131
129
  }
132
130
  }
133
131
  selectNetworkInterface() {
134
- const interfaces = (0, node_os_1.networkInterfaces)();
132
+ const interfaces = networkInterfaces();
135
133
  const broadcastAddress = this.options.address || this.options.limitedAddress;
136
134
  const defaultAddress = '0.0.0.0';
137
135
  if (!broadcastAddress ||
@@ -207,8 +205,7 @@ class UDPWorker {
207
205
  }
208
206
  }
209
207
  }
210
- exports.UDPWorker = UDPWorker;
211
- if (!node_worker_threads_1.isMainThread && node_worker_threads_1.parentPort) {
212
- new UDPWorker(node_worker_threads_1.workerData, node_worker_threads_1.parentPort);
208
+ if (!isMainThread && parentPort) {
209
+ new UDPWorker(workerData, parentPort);
213
210
  }
214
211
  //# sourceMappingURL=UDPWorker.js.map
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildOptions = buildOptions;
4
1
  /*!
5
2
  * Helper: buildOptions
6
3
  *
@@ -33,7 +30,7 @@ exports.buildOptions = buildOptions;
33
30
  * @param {Partial<T>} givenOptions
34
31
  * @returns {T}
35
32
  */
36
- function buildOptions(defaultOptions, givenOptions) {
33
+ export function buildOptions(defaultOptions, givenOptions) {
37
34
  return Object.assign({}, defaultOptions, givenOptions);
38
35
  }
39
36
  //# sourceMappingURL=buildOptions.js.map
@@ -1,15 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.copyEventEmitter = copyEventEmitter;
4
- const node_util_1 = require("node:util");
5
- function copyEventEmitter(source, target) {
1
+ /*!
2
+ * Copies identical EventEmitter to the target
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ import { EventEmitter } from 'node:events';
25
+ import { inspect } from 'node:util';
26
+ export function copyEventEmitter(source, target) {
6
27
  if (typeof source._maxListeners !== 'undefined') {
7
28
  target.setMaxListeners(source.getMaxListeners());
8
29
  }
9
30
  for (const event of source.eventNames()) {
10
31
  const listeners = source.rawListeners(event);
11
32
  for (const originalListener of listeners) {
12
- if ((0, node_util_1.inspect)(originalListener).includes('onceWrapper')) {
33
+ if (inspect(originalListener).includes('onceWrapper')) {
13
34
  const realListener = originalListener?.listener || originalListener;
14
35
  target.once(event, realListener);
15
36
  }
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.envInt = envInt;
4
1
  /*!
5
2
  * Helper: envInt
6
3
  *
@@ -32,7 +29,7 @@ exports.envInt = envInt;
32
29
  * @param {number} defaultValue
33
30
  * @returns {number}
34
31
  */
35
- function envInt(name, defaultValue) {
32
+ export function envInt(name, defaultValue) {
36
33
  const value = Number(process.env[name] || defaultValue);
37
34
  return isNaN(value) ? defaultValue : value;
38
35
  }
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.escapeRegExp = escapeRegExp;
4
1
  /*!
5
2
  * Helper: escapeRegExp
6
3
  *
@@ -30,7 +27,7 @@ exports.escapeRegExp = escapeRegExp;
30
27
  * @param {string} str
31
28
  * @returns {string}
32
29
  */
33
- function escapeRegExp(str) {
30
+ export function escapeRegExp(str) {
34
31
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
35
32
  }
36
33
  //# sourceMappingURL=escapeRegExp.js.map
@@ -21,11 +21,11 @@
21
21
  * purchase a proprietary commercial license. Please contact us at
22
22
  * <support@imqueue.com> to get commercial licensing options.
23
23
  */
24
- export * from './buildOptions';
25
- export * from './sha1';
26
- export * from './randomInt';
27
- export * from './pack';
28
- export * from './unpack';
29
- export * from './escapeRegExp';
30
- export * from './copyEventEmitter';
31
- export * from './envInt';
24
+ export * from './buildOptions.js';
25
+ export * from './sha1.js';
26
+ export * from './randomInt.js';
27
+ export * from './pack.js';
28
+ export * from './unpack.js';
29
+ export * from './escapeRegExp.js';
30
+ export * from './copyEventEmitter.js';
31
+ export * from './envInt.js';
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  /*!
18
2
  * IMQ helper functions
19
3
  *
@@ -37,12 +21,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
21
  * purchase a proprietary commercial license. Please contact us at
38
22
  * <support@imqueue.com> to get commercial licensing options.
39
23
  */
40
- __exportStar(require("./buildOptions"), exports);
41
- __exportStar(require("./sha1"), exports);
42
- __exportStar(require("./randomInt"), exports);
43
- __exportStar(require("./pack"), exports);
44
- __exportStar(require("./unpack"), exports);
45
- __exportStar(require("./escapeRegExp"), exports);
46
- __exportStar(require("./copyEventEmitter"), exports);
47
- __exportStar(require("./envInt"), exports);
24
+ export * from './buildOptions.js';
25
+ export * from './sha1.js';
26
+ export * from './randomInt.js';
27
+ export * from './pack.js';
28
+ export * from './unpack.js';
29
+ export * from './escapeRegExp.js';
30
+ export * from './copyEventEmitter.js';
31
+ export * from './envInt.js';
48
32
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pack = pack;
4
1
  /*!
5
2
  * Helper: pack
6
3
  *
@@ -24,14 +21,14 @@ exports.pack = pack;
24
21
  * purchase a proprietary commercial license. Please contact us at
25
22
  * <support@imqueue.com> to get commercial licensing options.
26
23
  */
27
- const node_zlib_1 = require("node:zlib");
24
+ import { gzipSync } from 'node:zlib';
28
25
  /**
29
26
  * Compresses the given data and returns a binary string
30
27
  *
31
28
  * @param {unknown} data - data to compress
32
29
  * @returns {string} - compressed data as a binary string
33
30
  */
34
- function pack(data) {
35
- return (0, node_zlib_1.gzipSync)(JSON.stringify(data)).toString('binary');
31
+ export function pack(data) {
32
+ return gzipSync(JSON.stringify(data)).toString('binary');
36
33
  }
37
34
  //# sourceMappingURL=pack.js.map
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randomInt = randomInt;
4
1
  /*!
5
2
  * Helper: intrand
6
3
  *
@@ -31,7 +28,7 @@ exports.randomInt = randomInt;
31
28
  * @param {number} max
32
29
  * @returns {number}
33
30
  */
34
- function randomInt(min, max) {
31
+ export function randomInt(min, max) {
35
32
  return Math.floor(Math.random() * (max - min + 1)) + min;
36
33
  }
37
34
  //# sourceMappingURL=randomInt.js.map
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sha1 = sha1;
4
1
  /*!
5
2
  * Helper: sha1
6
3
  *
@@ -24,15 +21,15 @@ exports.sha1 = sha1;
24
21
  * purchase a proprietary commercial license. Please contact us at
25
22
  * <support@imqueue.com> to get commercial licensing options.
26
23
  */
27
- const node_crypto_1 = require("node:crypto");
24
+ import { createHash, Hash } from 'node:crypto';
28
25
  /**
29
26
  * Returns SHA1 hash sum of the given string
30
27
  *
31
28
  * @param {string} str
32
29
  * @returns {string}
33
30
  */
34
- function sha1(str) {
35
- const sha = (0, node_crypto_1.createHash)('sha1');
31
+ export function sha1(str) {
32
+ const sha = createHash('sha1');
36
33
  sha.update(str);
37
34
  return sha.digest('hex');
38
35
  }
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unpack = unpack;
4
1
  /*!
5
2
  * Helper: unpack
6
3
  *
@@ -24,14 +21,14 @@ exports.unpack = unpack;
24
21
  * purchase a proprietary commercial license. Please contact us at
25
22
  * <support@imqueue.com> to get commercial licensing options.
26
23
  */
27
- const node_zlib_1 = require("node:zlib");
24
+ import { gunzipSync } from 'node:zlib';
28
25
  /**
29
26
  * Decompresses a binary string and returns the decompressed data
30
27
  *
31
28
  * @param {string} data - compressed data string
32
29
  * @returns {unknown} - decompressed data
33
30
  */
34
- function unpack(data) {
35
- return JSON.parse((0, node_zlib_1.gunzipSync)(Buffer.from(data, 'binary')).toString());
31
+ export function unpack(data) {
32
+ return JSON.parse(gunzipSync(Buffer.from(data, 'binary')).toString());
36
33
  }
37
34
  //# sourceMappingURL=unpack.js.map
package/src/index.d.ts CHANGED
@@ -19,10 +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
- export * from './profile';
23
- export * from './redis';
24
- export * from './IMQMode';
25
- export * from './IMessageQueue';
26
- export * from './RedisQueue';
27
- export * from './ClusteredRedisQueue';
28
- export * from './UDPClusterManager';
22
+ export * from './profile.js';
23
+ export * from './redis.js';
24
+ export * from './IMQMode.js';
25
+ export * from './IMessageQueue.js';
26
+ export * from './RedisQueue.js';
27
+ export * from './ClusteredRedisQueue.js';
28
+ export * from './UDPClusterManager.js';
package/src/index.js CHANGED
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  /*!
18
2
  * I'm Queue Software Project
19
3
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -35,11 +19,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
19
  * purchase a proprietary commercial license. Please contact us at
36
20
  * <support@imqueue.com> to get commercial licensing options.
37
21
  */
38
- __exportStar(require("./profile"), exports);
39
- __exportStar(require("./redis"), exports);
40
- __exportStar(require("./IMQMode"), exports);
41
- __exportStar(require("./IMessageQueue"), exports);
42
- __exportStar(require("./RedisQueue"), exports);
43
- __exportStar(require("./ClusteredRedisQueue"), exports);
44
- __exportStar(require("./UDPClusterManager"), exports);
22
+ export * from './profile.js';
23
+ export * from './redis.js';
24
+ export * from './IMQMode.js';
25
+ export * from './IMessageQueue.js';
26
+ export * from './RedisQueue.js';
27
+ export * from './ClusteredRedisQueue.js';
28
+ export * from './UDPClusterManager.js';
45
29
  //# sourceMappingURL=index.js.map
package/src/profile.d.ts CHANGED
@@ -21,7 +21,7 @@
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 { ILogger } from '.';
24
+ import { type ILogger } from './index.js';
25
25
  export declare enum LogLevel {
26
26
  LOG = "log",
27
27
  INFO = "info",
package/src/profile.js CHANGED
@@ -1,23 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IMQ_LOG_TIME_FORMAT = exports.IMQ_LOG_ARGS = exports.IMQ_LOG_TIME = exports.IMQ_LOG_LEVEL = exports.LogLevel = void 0;
4
- exports.verifyLogLevel = verifyLogLevel;
5
- exports.logDebugInfo = logDebugInfo;
6
- exports.profile = profile;
7
- var LogLevel;
1
+ /*!
2
+ * Decorator: @profile
3
+ *
4
+ * I'm Queue Software Project
5
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ *
20
+ * If you want to use this code in a closed source (commercial) project, you can
21
+ * purchase a proprietary commercial license. Please contact us at
22
+ * <support@imqueue.com> to get commercial licensing options.
23
+ */
24
+ import {} from './index.js';
25
+ export var LogLevel;
8
26
  (function (LogLevel) {
9
27
  LogLevel["LOG"] = "log";
10
28
  LogLevel["INFO"] = "info";
11
29
  LogLevel["WARN"] = "warn";
12
30
  LogLevel["ERROR"] = "error";
13
- })(LogLevel || (exports.LogLevel = LogLevel = {}));
31
+ })(LogLevel || (LogLevel = {}));
14
32
  /**
15
33
  * Validates a log level value or returns the default
16
34
  *
17
35
  * @param {unknown} level - the level to validate
18
36
  * @returns {LogLevel} - validated log level or INFO if invalid
19
37
  */
20
- function verifyLogLevel(level) {
38
+ export function verifyLogLevel(level) {
21
39
  switch (level) {
22
40
  case LogLevel.LOG:
23
41
  case LogLevel.INFO:
@@ -28,9 +46,9 @@ function verifyLogLevel(level) {
28
46
  return LogLevel.INFO;
29
47
  }
30
48
  }
31
- exports.IMQ_LOG_LEVEL = verifyLogLevel(process.env.IMQ_LOG_LEVEL);
49
+ export const IMQ_LOG_LEVEL = verifyLogLevel(process.env.IMQ_LOG_LEVEL);
32
50
  const DEFAULT_OPTIONS = {
33
- logLevel: exports.IMQ_LOG_LEVEL,
51
+ logLevel: IMQ_LOG_LEVEL,
34
52
  };
35
53
  /**
36
54
  * Environment variable IMQ_LOG_TIME=[1, 0]. Enable or disable profiled
@@ -38,14 +56,14 @@ const DEFAULT_OPTIONS = {
38
56
  *
39
57
  * @type {boolean}
40
58
  */
41
- exports.IMQ_LOG_TIME = !!+(process.env.IMQ_LOG_TIME || 0);
59
+ export const IMQ_LOG_TIME = !!+(process.env.IMQ_LOG_TIME || 0);
42
60
  /**
43
61
  * Environment variable IMQ_LOG_ARGS=[1, 0]. Enable or disable logging of
44
62
  * profiled call arguments.
45
63
  *
46
64
  * @type {boolean}
47
65
  */
48
- exports.IMQ_LOG_ARGS = !!+(process.env.IMQ_LOG_ARGS || 0);
66
+ export const IMQ_LOG_ARGS = !!+(process.env.IMQ_LOG_ARGS || 0);
49
67
  /**
50
68
  * Environment variable IMQ_LOG_TIME_FORMAT. Specifies the format for profiled
51
69
  * time logging. Values: 'microseconds', 'milliseconds', 'seconds'.
@@ -53,20 +71,20 @@ exports.IMQ_LOG_ARGS = !!+(process.env.IMQ_LOG_ARGS || 0);
53
71
  *
54
72
  * @type {AllowedTimeFormat | string}
55
73
  */
56
- exports.IMQ_LOG_TIME_FORMAT = process.env.IMQ_LOG_TIME_FORMAT || 'microseconds';
74
+ export const IMQ_LOG_TIME_FORMAT = process.env.IMQ_LOG_TIME_FORMAT || 'microseconds';
57
75
  /**
58
76
  * Logs debug information about a function call
59
77
  *
60
78
  * @param {DebugInfoOptions} options - debug information options
61
79
  */
62
- function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start, logger, logLevel, }) {
80
+ export function logDebugInfo({ debugTime, debugArgs, className, args, methodName, start, logger, logLevel, }) {
63
81
  const log = logger && typeof logger[logLevel] === 'function'
64
82
  ? logger[logLevel].bind(logger)
65
83
  : undefined;
66
84
  if (debugTime) {
67
85
  const time = Number(process.hrtime.bigint() - BigInt(start)) / 1000;
68
86
  let timeStr;
69
- switch (exports.IMQ_LOG_TIME_FORMAT) {
87
+ switch (IMQ_LOG_TIME_FORMAT) {
70
88
  case 'milliseconds':
71
89
  timeStr = (time / 1000).toFixed(3) + ' ms';
72
90
  break;
@@ -178,11 +196,11 @@ function isThenable(value) {
178
196
  * descriptor: TypedPropertyDescriptor<(...args: any[]) => any>,
179
197
  * ) => void}
180
198
  */
181
- function profile(options) {
199
+ export function profile(options) {
182
200
  options = Object.assign({}, DEFAULT_OPTIONS, options);
183
201
  const { enableDebugTime, enableDebugArgs, logLevel } = options;
184
- let debugTime = exports.IMQ_LOG_TIME;
185
- let debugArgs = exports.IMQ_LOG_ARGS;
202
+ let debugTime = IMQ_LOG_TIME;
203
+ let debugArgs = IMQ_LOG_ARGS;
186
204
  if (typeof enableDebugTime === 'boolean') {
187
205
  debugTime = enableDebugTime;
188
206
  }
@@ -202,7 +220,7 @@ function profile(options) {
202
220
  className,
203
221
  debugArgs,
204
222
  debugTime,
205
- logLevel: logLevel ? verifyLogLevel(logLevel) : exports.IMQ_LOG_LEVEL,
223
+ logLevel: logLevel ? verifyLogLevel(logLevel) : IMQ_LOG_LEVEL,
206
224
  logger,
207
225
  methodName,
208
226
  start,
package/src/redis.d.ts CHANGED
@@ -21,7 +21,7 @@
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 Redis from 'ioredis';
24
+ import { Redis } from 'ioredis';
25
25
  /**
26
26
  * Extends the default Redis type to allow dynamic properties access on it
27
27
  *
package/src/redis.js CHANGED
@@ -1,9 +1,3 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Redis = void 0;
7
1
  /*!
8
2
  * Extends native redis module to be promise-like
9
3
  *
@@ -27,7 +21,7 @@ exports.Redis = void 0;
27
21
  * purchase a proprietary commercial license. Please contact us at
28
22
  * <support@imqueue.com> to get commercial licensing options.
29
23
  */
30
- const ioredis_1 = __importDefault(require("ioredis"));
31
- exports.Redis = ioredis_1.default;
32
- exports.default = ioredis_1.default;
24
+ import { Redis } from 'ioredis';
25
+ export { Redis };
26
+ export default Redis;
33
27
  //# sourceMappingURL=redis.js.map