@imqueue/core 2.0.26 → 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.
- package/.oxfmtrc.json +9 -0
- package/.oxlintrc.json +20 -0
- package/README.md +73 -63
- package/debug_getter.d.ts +1 -9
- package/index.d.ts +0 -1
- package/index.js +8 -9
- package/package.json +20 -67
- package/scripts/strip-comment-coverage.mjs +397 -0
- package/src/ClusterManager.d.ts +12 -3
- package/src/ClusterManager.js +21 -10
- package/src/ClusteredRedisQueue.d.ts +45 -14
- package/src/ClusteredRedisQueue.js +186 -168
- package/src/IMessageQueue.d.ts +89 -96
- package/src/IMessageQueue.js +2 -2
- package/src/RedisQueue.d.ts +193 -97
- package/src/RedisQueue.js +1328 -1068
- package/src/UDPClusterManager.d.ts +100 -26
- package/src/UDPClusterManager.js +225 -70
- package/src/UDPWorker.d.ts +53 -1
- package/src/UDPWorker.js +79 -40
- package/src/{promisify.d.ts → helpers/buildOptions.d.ts} +8 -15
- package/src/helpers/buildOptions.js +39 -0
- package/src/{copyEventEmitter.d.ts → helpers/copyEventEmitter.d.ts} +1 -1
- package/src/{copyEventEmitter.js → helpers/copyEventEmitter.js} +3 -4
- package/src/helpers/envInt.d.ts +32 -0
- package/src/helpers/envInt.js +39 -0
- package/src/helpers/escapeRegExp.d.ts +30 -0
- package/src/helpers/escapeRegExp.js +36 -0
- package/src/helpers/index.d.ts +31 -0
- package/src/helpers/index.js +48 -0
- package/src/helpers/pack.d.ts +7 -0
- package/src/helpers/pack.js +37 -0
- package/src/helpers/randomInt.d.ts +31 -0
- package/src/helpers/randomInt.js +37 -0
- package/src/helpers/sha1.d.ts +7 -0
- package/src/helpers/sha1.js +39 -0
- package/src/helpers/unpack.d.ts +7 -0
- package/src/helpers/unpack.js +37 -0
- package/src/index.d.ts +1 -14
- package/src/index.js +1 -19
- package/src/profile.d.ts +28 -38
- package/src/profile.js +100 -95
- package/src/redis.d.ts +1 -1
- package/src/redis.js +4 -2
- package/typedoc.json +19 -0
- package/eslint.config.mjs +0 -98
- package/src/promisify.js +0 -106
- package/src/uuid.d.ts +0 -6
- 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
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
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
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.
|
|
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
|
-
})
|
|
49
|
-
|
|
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,11 +82,6 @@ class UDPWorker {
|
|
|
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',
|
|
@@ -90,24 +109,18 @@ class UDPWorker {
|
|
|
90
109
|
};
|
|
91
110
|
}
|
|
92
111
|
serverAliveWait(message) {
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
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;
|
|
96
114
|
const effectiveTimeout = message.timeout + correction + 1;
|
|
97
115
|
const key = UDPWorker.getServerKey(message);
|
|
98
116
|
this.servers.set(key, stamp);
|
|
99
|
-
const
|
|
117
|
+
const timer = setTimeout(() => setImmediate(() => {
|
|
100
118
|
if (this.servers.get(key) === stamp) {
|
|
101
119
|
this.removeServer(message);
|
|
102
120
|
}
|
|
103
121
|
}), effectiveTimeout);
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
if (t && typeof t.unref === 'function') {
|
|
107
|
-
t.unref();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch ( /* ignore */_b) { /* ignore */ }
|
|
122
|
+
// a pending liveness timer must not keep the worker alive on its own
|
|
123
|
+
timer.unref();
|
|
111
124
|
}
|
|
112
125
|
processMessage(message) {
|
|
113
126
|
if (message.type === MessageType.Down) {
|
|
@@ -118,12 +131,11 @@ class UDPWorker {
|
|
|
118
131
|
}
|
|
119
132
|
}
|
|
120
133
|
selectNetworkInterface() {
|
|
121
|
-
const interfaces = (0,
|
|
122
|
-
const broadcastAddress = this.options.address
|
|
123
|
-
|| this.options.limitedAddress;
|
|
134
|
+
const interfaces = (0, node_os_1.networkInterfaces)();
|
|
135
|
+
const broadcastAddress = this.options.address || this.options.limitedAddress;
|
|
124
136
|
const defaultAddress = '0.0.0.0';
|
|
125
|
-
if (!broadcastAddress
|
|
126
|
-
|
|
137
|
+
if (!broadcastAddress ||
|
|
138
|
+
broadcastAddress === this.options.limitedAddress) {
|
|
127
139
|
return defaultAddress;
|
|
128
140
|
}
|
|
129
141
|
for (const key in interfaces) {
|
|
@@ -131,8 +143,8 @@ class UDPWorker {
|
|
|
131
143
|
continue;
|
|
132
144
|
}
|
|
133
145
|
for (const net of interfaces[key]) {
|
|
134
|
-
const shouldBeSelected = net.family === 'IPv4'
|
|
135
|
-
|
|
146
|
+
const shouldBeSelected = net.family === 'IPv4' &&
|
|
147
|
+
net.address.startsWith(broadcastAddress.replace(/\.255/g, ''));
|
|
136
148
|
if (shouldBeSelected) {
|
|
137
149
|
return net.address;
|
|
138
150
|
}
|
|
@@ -140,16 +152,40 @@ class UDPWorker {
|
|
|
140
152
|
}
|
|
141
153
|
return defaultAddress;
|
|
142
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
|
+
*/
|
|
143
164
|
parseMessage(input) {
|
|
144
|
-
const [name, id, type, address = '', timeout = '0'
|
|
145
|
-
|
|
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
|
+
}
|
|
146
182
|
return {
|
|
147
183
|
id,
|
|
148
184
|
name,
|
|
149
185
|
type: type.toLowerCase(),
|
|
150
186
|
host,
|
|
151
|
-
port:
|
|
152
|
-
timeout:
|
|
187
|
+
port: portNumber,
|
|
188
|
+
timeout: timeoutMs,
|
|
153
189
|
};
|
|
154
190
|
}
|
|
155
191
|
stop() {
|
|
@@ -165,11 +201,14 @@ class UDPWorker {
|
|
|
165
201
|
cleanup() {
|
|
166
202
|
this.servers.clear();
|
|
167
203
|
if (this.socket) {
|
|
168
|
-
|
|
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');
|
|
169
207
|
}
|
|
170
208
|
}
|
|
171
209
|
}
|
|
172
|
-
|
|
173
|
-
|
|
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);
|
|
174
213
|
}
|
|
175
214
|
//# sourceMappingURL=UDPWorker.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
*
|
|
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
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* Safely builds full options definition using default options and
|
|
26
|
+
* partial given options
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
29
|
-
* @
|
|
28
|
+
* @template T
|
|
29
|
+
* @param {T} defaultOptions
|
|
30
|
+
* @param {Partial<T>} givenOptions
|
|
31
|
+
* @returns {T}
|
|
30
32
|
*/
|
|
31
|
-
export declare function
|
|
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
|
|
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 (
|
|
13
|
-
const realListener =
|
|
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,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
|