@imqueue/core 2.0.25 → 3.0.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 (49) hide show
  1. package/.oxfmtrc.json +9 -0
  2. package/.oxlintrc.json +20 -0
  3. package/README.md +73 -63
  4. package/debug_getter.d.ts +1 -9
  5. package/index.d.ts +0 -1
  6. package/index.js +8 -9
  7. package/package.json +20 -67
  8. package/scripts/strip-comment-coverage.mjs +397 -0
  9. package/src/ClusterManager.d.ts +12 -3
  10. package/src/ClusterManager.js +21 -10
  11. package/src/ClusteredRedisQueue.d.ts +46 -14
  12. package/src/ClusteredRedisQueue.js +196 -169
  13. package/src/IMessageQueue.d.ts +89 -96
  14. package/src/IMessageQueue.js +2 -2
  15. package/src/RedisQueue.d.ts +193 -97
  16. package/src/RedisQueue.js +1328 -1070
  17. package/src/UDPClusterManager.d.ts +110 -26
  18. package/src/UDPClusterManager.js +227 -70
  19. package/src/UDPWorker.d.ts +53 -1
  20. package/src/UDPWorker.js +87 -46
  21. package/src/{promisify.d.ts → helpers/buildOptions.d.ts} +8 -15
  22. package/src/helpers/buildOptions.js +39 -0
  23. package/src/{copyEventEmitter.d.ts → helpers/copyEventEmitter.d.ts} +1 -1
  24. package/src/{copyEventEmitter.js → helpers/copyEventEmitter.js} +3 -4
  25. package/src/helpers/envInt.d.ts +32 -0
  26. package/src/helpers/envInt.js +39 -0
  27. package/src/helpers/escapeRegExp.d.ts +30 -0
  28. package/src/helpers/escapeRegExp.js +36 -0
  29. package/src/helpers/index.d.ts +31 -0
  30. package/src/helpers/index.js +48 -0
  31. package/src/helpers/pack.d.ts +7 -0
  32. package/src/helpers/pack.js +37 -0
  33. package/src/helpers/randomInt.d.ts +31 -0
  34. package/src/helpers/randomInt.js +37 -0
  35. package/src/helpers/sha1.d.ts +7 -0
  36. package/src/helpers/sha1.js +39 -0
  37. package/src/helpers/unpack.d.ts +7 -0
  38. package/src/helpers/unpack.js +37 -0
  39. package/src/index.d.ts +1 -14
  40. package/src/index.js +1 -19
  41. package/src/profile.d.ts +28 -38
  42. package/src/profile.js +100 -95
  43. package/src/redis.d.ts +1 -1
  44. package/src/redis.js +4 -2
  45. package/typedoc.json +19 -0
  46. package/eslint.config.mjs +0 -98
  47. package/src/promisify.js +0 -106
  48. package/src/uuid.d.ts +0 -6
  49. package/src/uuid.js +0 -65
package/src/UDPWorker.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UDPWorker = void 0;
3
4
  /*!
4
5
  * UDP message listener for cluster managing: Worker for processing
5
6
  * messages
@@ -24,29 +25,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
25
  * purchase a proprietary commercial license. Please contact us at
25
26
  * <support@imqueue.com> to get commercial licensing options.
26
27
  */
27
- const worker_threads_1 = require("worker_threads");
28
- const dgram_1 = require("dgram");
29
- const os_1 = require("os");
30
- const uuid_1 = require("./uuid");
31
- process.setMaxListeners(10000);
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");
32
32
  var MessageType;
33
33
  (function (MessageType) {
34
34
  MessageType["Up"] = "up";
35
35
  MessageType["Down"] = "down";
36
36
  })(MessageType || (MessageType = {}));
37
- class UDPClusterWorker {
37
+ class UDPWorker {
38
+ options;
39
+ messagePort;
40
+ socket;
41
+ servers = new Map();
38
42
  constructor(options, messagePort) {
39
43
  this.options = options;
40
44
  this.messagePort = messagePort;
41
- this.servers = new Map();
42
45
  this.setupMessageHandlers();
43
- this.setupProcessHandlers();
44
- this.socket = (0, dgram_1.createSocket)({
46
+ this.socket = (0, node_dgram_1.createSocket)({
45
47
  type: 'udp4',
46
48
  reuseAddr: true,
47
49
  reusePort: true,
48
- }).bind(this.options.port, this.selectNetworkInterface());
49
- this.socket.on('message', message => this.processMessage(this.parseMessage(message)));
50
+ });
51
+ // surface socket failures (bind errors, network errors) to the
52
+ // main thread instead of crashing the whole process with an
53
+ // unhandled 'error' event
54
+ this.socket.on('error', err => {
55
+ this.messagePort.postMessage({
56
+ type: 'error',
57
+ error: err.message,
58
+ });
59
+ });
60
+ this.socket.on('message', input => {
61
+ // a malformed datagram on the broadcast port must never crash
62
+ // the worker (and, through it, the host process)
63
+ try {
64
+ const message = this.parseMessage(input);
65
+ if (message) {
66
+ this.processMessage(message);
67
+ }
68
+ }
69
+ catch {
70
+ // ignore broken datagrams
71
+ }
72
+ });
73
+ this.socket.bind(this.options.port, this.selectNetworkInterface());
50
74
  }
51
75
  static getServerKey(message) {
52
76
  return message.id;
@@ -58,23 +82,20 @@ class UDPClusterWorker {
58
82
  }
59
83
  });
60
84
  }
61
- setupProcessHandlers() {
62
- process.on('SIGTERM', this.cleanup);
63
- process.on('SIGINT', this.cleanup);
64
- process.on('SIGABRT', this.cleanup);
65
- }
66
85
  addServer(message) {
67
86
  this.messagePort.postMessage({
68
87
  type: 'cluster:add',
69
- server: UDPClusterWorker.mapMessage(message),
88
+ server: UDPWorker.mapMessage(message),
70
89
  });
71
- this.serverAliveWait(message);
90
+ if (this.options.useAliveCheck) {
91
+ this.serverAliveWait(message);
92
+ }
72
93
  }
73
94
  removeServer(message) {
74
- this.servers.delete(UDPClusterWorker.getServerKey(message));
95
+ this.servers.delete(UDPWorker.getServerKey(message));
75
96
  this.messagePort.postMessage({
76
97
  type: 'cluster:remove',
77
- server: UDPClusterWorker.mapMessage(message),
98
+ server: UDPWorker.mapMessage(message),
78
99
  });
79
100
  }
80
101
  static mapMessage(message) {
@@ -88,24 +109,18 @@ class UDPClusterWorker {
88
109
  };
89
110
  }
90
111
  serverAliveWait(message) {
91
- var _a;
92
- const stamp = (0, uuid_1.uuid)();
93
- const correction = (_a = this.options.aliveTimeoutCorrection) !== null && _a !== void 0 ? _a : 0;
112
+ const stamp = (0, node_crypto_1.randomUUID)();
113
+ const correction = this.options.aliveTimeoutCorrection ?? 0;
94
114
  const effectiveTimeout = message.timeout + correction + 1;
95
- const key = UDPClusterWorker.getServerKey(message);
115
+ const key = UDPWorker.getServerKey(message);
96
116
  this.servers.set(key, stamp);
97
- const t = setTimeout(() => setImmediate(() => {
117
+ const timer = setTimeout(() => setImmediate(() => {
98
118
  if (this.servers.get(key) === stamp) {
99
119
  this.removeServer(message);
100
120
  }
101
121
  }), effectiveTimeout);
102
- // Avoid keeping the event loop alive due to pending timers
103
- try {
104
- if (t && typeof t.unref === 'function') {
105
- t.unref();
106
- }
107
- }
108
- catch ( /* ignore */_b) { /* ignore */ }
122
+ // a pending liveness timer must not keep the worker alive on its own
123
+ timer.unref();
109
124
  }
110
125
  processMessage(message) {
111
126
  if (message.type === MessageType.Down) {
@@ -116,12 +131,11 @@ class UDPClusterWorker {
116
131
  }
117
132
  }
118
133
  selectNetworkInterface() {
119
- const interfaces = (0, os_1.networkInterfaces)();
120
- const broadcastAddress = this.options.address
121
- || this.options.limitedAddress;
134
+ const interfaces = (0, node_os_1.networkInterfaces)();
135
+ const broadcastAddress = this.options.address || this.options.limitedAddress;
122
136
  const defaultAddress = '0.0.0.0';
123
- if (!broadcastAddress
124
- || broadcastAddress === this.options.limitedAddress) {
137
+ if (!broadcastAddress ||
138
+ broadcastAddress === this.options.limitedAddress) {
125
139
  return defaultAddress;
126
140
  }
127
141
  for (const key in interfaces) {
@@ -129,8 +143,8 @@ class UDPClusterWorker {
129
143
  continue;
130
144
  }
131
145
  for (const net of interfaces[key]) {
132
- const shouldBeSelected = net.family === 'IPv4'
133
- && net.address.startsWith(broadcastAddress.replace(/\.255/g, ''));
146
+ const shouldBeSelected = net.family === 'IPv4' &&
147
+ net.address.startsWith(broadcastAddress.replace(/\.255/g, ''));
134
148
  if (shouldBeSelected) {
135
149
  return net.address;
136
150
  }
@@ -138,16 +152,40 @@ class UDPClusterWorker {
138
152
  }
139
153
  return defaultAddress;
140
154
  }
155
+ /**
156
+ * Parses a raw broadcast datagram into a message. Returns null for
157
+ * malformed input (missing fields, non-numeric port, or timeout), so
158
+ * garbage on the broadcast port is dropped instead of producing
159
+ * NaN-driven timers or crashes.
160
+ *
161
+ * @param {Buffer} input
162
+ * @returns {Message | null}
163
+ */
141
164
  parseMessage(input) {
142
- const [name, id, type, address = '', timeout = '0',] = input.toString().split('\t');
143
- const [host, port] = address.split(':');
165
+ const [name, id, type, address = '', timeout = '0'] = input
166
+ .toString()
167
+ .split('\t');
168
+ const [host, port = ''] = address.split(':');
169
+ const portNumber = parseInt(port, 10);
170
+ const timeoutMs = parseFloat(timeout) * 1000;
171
+ if (!name ||
172
+ !id ||
173
+ !type ||
174
+ !host ||
175
+ !Number.isFinite(portNumber) ||
176
+ portNumber <= 0 ||
177
+ portNumber > 65535 ||
178
+ !Number.isFinite(timeoutMs) ||
179
+ timeoutMs < 0) {
180
+ return null;
181
+ }
144
182
  return {
145
183
  id,
146
184
  name,
147
185
  type: type.toLowerCase(),
148
186
  host,
149
- port: parseInt(port),
150
- timeout: parseFloat(timeout) * 1000,
187
+ port: portNumber,
188
+ timeout: timeoutMs,
151
189
  };
152
190
  }
153
191
  stop() {
@@ -163,11 +201,14 @@ class UDPClusterWorker {
163
201
  cleanup() {
164
202
  this.servers.clear();
165
203
  if (this.socket) {
166
- this.socket.removeAllListeners();
204
+ // keep the 'error' listener attached: a socket error during
205
+ // close must not crash the worker as an unhandled 'error' event
206
+ this.socket.removeAllListeners('message');
167
207
  }
168
208
  }
169
209
  }
170
- if (!worker_threads_1.isMainThread && worker_threads_1.parentPort) {
171
- new UDPClusterWorker(worker_threads_1.workerData, worker_threads_1.parentPort);
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);
172
213
  }
173
214
  //# sourceMappingURL=UDPWorker.js.map
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Makes callback handling function promise-like
2
+ * Helper: buildOptions
3
3
  *
4
4
  * I'm Queue Software Project
5
5
  * Copyright (C) 2025 imqueue.com <support@imqueue.com>
@@ -22,19 +22,12 @@
22
22
  * <support@imqueue.com> to get commercial licensing options.
23
23
  */
24
24
  /**
25
- * Returns entire list of the given object properties including
26
- * entire prototype chain
25
+ * Safely builds full options definition using default options and
26
+ * partial given options
27
27
  *
28
- * @param {any} obj
29
- * @returns {string[]}
28
+ * @template T
29
+ * @param {T} defaultOptions
30
+ * @param {Partial<T>} givenOptions
31
+ * @returns {T}
30
32
  */
31
- export declare function propertiesOf(obj: any): string[];
32
- /**
33
- * Makes given object methods promise-like
34
- *
35
- * @param {any} obj - source object to modify
36
- * @param {string[]} restrict - stick promise-like behavior to a given
37
- * restricted list of methods
38
- * @return {void}
39
- */
40
- export declare function promisify(obj: any, restrict?: string[]): void;
33
+ export declare function buildOptions<T>(defaultOptions: T, givenOptions?: Partial<T>): T;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildOptions = buildOptions;
4
+ /*!
5
+ * Helper: buildOptions
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
+ /**
28
+ * Safely builds full options definition using default options and
29
+ * partial given options
30
+ *
31
+ * @template T
32
+ * @param {T} defaultOptions
33
+ * @param {Partial<T>} givenOptions
34
+ * @returns {T}
35
+ */
36
+ function buildOptions(defaultOptions, givenOptions) {
37
+ return Object.assign({}, defaultOptions, givenOptions);
38
+ }
39
+ //# sourceMappingURL=buildOptions.js.map
@@ -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 { EventEmitter } from 'events';
24
+ import { EventEmitter } from 'node:events';
25
25
  export declare function copyEventEmitter(source: EventEmitter & {
26
26
  _maxListeners?: number;
27
27
  _events?: Record<string | symbol, any>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.copyEventEmitter = copyEventEmitter;
4
- const util = require("util");
4
+ const node_util_1 = require("node:util");
5
5
  function copyEventEmitter(source, target) {
6
6
  if (typeof source._maxListeners !== 'undefined') {
7
7
  target.setMaxListeners(source.getMaxListeners());
@@ -9,9 +9,8 @@ function copyEventEmitter(source, target) {
9
9
  for (const event of source.eventNames()) {
10
10
  const listeners = source.rawListeners(event);
11
11
  for (const originalListener of listeners) {
12
- if (util.inspect(originalListener).includes('onceWrapper')) {
13
- const realListener = (originalListener === null || originalListener === void 0 ? void 0 : originalListener.listener)
14
- || originalListener;
12
+ if ((0, node_util_1.inspect)(originalListener).includes('onceWrapper')) {
13
+ const realListener = originalListener?.listener || originalListener;
15
14
  target.once(event, realListener);
16
15
  }
17
16
  else {
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Helper: envInt
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
+ /**
25
+ * Reads integer value from environment variable, falling back to the
26
+ * given default on missing or non-numeric values
27
+ *
28
+ * @param {string} name
29
+ * @param {number} defaultValue
30
+ * @returns {number}
31
+ */
32
+ export declare function envInt(name: string, defaultValue: number): number;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.envInt = envInt;
4
+ /*!
5
+ * Helper: envInt
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
+ /**
28
+ * Reads integer value from environment variable, falling back to the
29
+ * given default on missing or non-numeric values
30
+ *
31
+ * @param {string} name
32
+ * @param {number} defaultValue
33
+ * @returns {number}
34
+ */
35
+ function envInt(name, defaultValue) {
36
+ const value = Number(process.env[name] || defaultValue);
37
+ return isNaN(value) ? defaultValue : value;
38
+ }
39
+ //# sourceMappingURL=envInt.js.map
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * Helper: escapeRegExp
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
+ /**
25
+ * Escapes regular expression special characters in a given string
26
+ *
27
+ * @param {string} str
28
+ * @returns {string}
29
+ */
30
+ export declare function escapeRegExp(str: string): string;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.escapeRegExp = escapeRegExp;
4
+ /*!
5
+ * Helper: escapeRegExp
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
+ /**
28
+ * Escapes regular expression special characters in a given string
29
+ *
30
+ * @param {string} str
31
+ * @returns {string}
32
+ */
33
+ function escapeRegExp(str) {
34
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
35
+ }
36
+ //# sourceMappingURL=escapeRegExp.js.map
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * IMQ helper functions
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
+ 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';
@@ -0,0 +1,48 @@
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
+ /*!
18
+ * IMQ helper functions
19
+ *
20
+ * I'm Queue Software Project
21
+ * Copyright (C) 2025 imqueue.com <support@imqueue.com>
22
+ *
23
+ * This program is free software: you can redistribute it and/or modify
24
+ * it under the terms of the GNU General Public License as published by
25
+ * the Free Software Foundation, either version 3 of the License, or
26
+ * (at your option) any later version.
27
+ *
28
+ * This program is distributed in the hope that it will be useful,
29
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
30
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31
+ * GNU General Public License for more details.
32
+ *
33
+ * You should have received a copy of the GNU General Public License
34
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
35
+ *
36
+ * If you want to use this code in a closed source (commercial) project, you can
37
+ * purchase a proprietary commercial license. Please contact us at
38
+ * <support@imqueue.com> to get commercial licensing options.
39
+ */
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);
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Compresses the given data and returns a binary string
3
+ *
4
+ * @param {unknown} data - data to compress
5
+ * @returns {string} - compressed data as a binary string
6
+ */
7
+ export declare function pack(data: unknown): string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pack = pack;
4
+ /*!
5
+ * Helper: pack
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
+ * Compresses the given data and returns a binary string
30
+ *
31
+ * @param {unknown} data - data to compress
32
+ * @returns {string} - compressed data as a binary string
33
+ */
34
+ function pack(data) {
35
+ return (0, node_zlib_1.gzipSync)(JSON.stringify(data)).toString('binary');
36
+ }
37
+ //# sourceMappingURL=pack.js.map
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * Helper: intrand
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
+ /**
25
+ * Returns random integer between given min and max
26
+ *
27
+ * @param {number} min
28
+ * @param {number} max
29
+ * @returns {number}
30
+ */
31
+ export declare function randomInt(min: number, max: number): number;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomInt = randomInt;
4
+ /*!
5
+ * Helper: intrand
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
+ /**
28
+ * Returns random integer between given min and max
29
+ *
30
+ * @param {number} min
31
+ * @param {number} max
32
+ * @returns {number}
33
+ */
34
+ function randomInt(min, max) {
35
+ return Math.floor(Math.random() * (max - min + 1)) + min;
36
+ }
37
+ //# sourceMappingURL=randomInt.js.map