@sapphire/cron 1.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/CHANGELOG.md +10 -0
- package/README.md +119 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.global.js +703 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +187 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +154 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var SapphireCron = (() => {
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __publicField = (obj, key, value) => {
|
|
23
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/index.ts
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
Cron: () => Cron,
|
|
31
|
+
Time: () => Time,
|
|
32
|
+
allowedNum: () => allowedNum,
|
|
33
|
+
cronTokens: () => cronTokens,
|
|
34
|
+
partRegex: () => partRegex,
|
|
35
|
+
predefined: () => predefined,
|
|
36
|
+
tokensRegex: () => tokensRegex,
|
|
37
|
+
wildcardRegex: () => wildcardRegex
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// src/lib/constants.ts
|
|
41
|
+
var Time = /* @__PURE__ */ ((Time2) => {
|
|
42
|
+
Time2[Time2["Millisecond"] = 1] = "Millisecond";
|
|
43
|
+
Time2[Time2["Second"] = 1e3] = "Second";
|
|
44
|
+
Time2[Time2["Minute"] = 6e4] = "Minute";
|
|
45
|
+
Time2[Time2["Hour"] = 36e5] = "Hour";
|
|
46
|
+
Time2[Time2["Day"] = 864e5] = "Day";
|
|
47
|
+
Time2[Time2["Month"] = 2628e6] = "Month";
|
|
48
|
+
Time2[Time2["Year"] = 31536e6] = "Year";
|
|
49
|
+
return Time2;
|
|
50
|
+
})(Time || {});
|
|
51
|
+
var partRegex = /^(?:(\*)|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/;
|
|
52
|
+
var wildcardRegex = /\bh\b|\B\?\B/g;
|
|
53
|
+
var allowedNum = [
|
|
54
|
+
[0, 59],
|
|
55
|
+
[0, 23],
|
|
56
|
+
[1, 31],
|
|
57
|
+
[1, 12],
|
|
58
|
+
[0, 6]
|
|
59
|
+
];
|
|
60
|
+
var predefined = {
|
|
61
|
+
"@annually": "0 0 1 1 *",
|
|
62
|
+
"@yearly": "0 0 1 1 *",
|
|
63
|
+
"@monthly": "0 0 1 * *",
|
|
64
|
+
"@weekly": "0 0 * * 0",
|
|
65
|
+
"@daily": "0 0 * * *",
|
|
66
|
+
"@hourly": "0 * * * *"
|
|
67
|
+
};
|
|
68
|
+
var cronTokens = {
|
|
69
|
+
jan: 1,
|
|
70
|
+
feb: 2,
|
|
71
|
+
mar: 3,
|
|
72
|
+
apr: 4,
|
|
73
|
+
may: 5,
|
|
74
|
+
jun: 6,
|
|
75
|
+
jul: 7,
|
|
76
|
+
aug: 8,
|
|
77
|
+
sep: 9,
|
|
78
|
+
oct: 10,
|
|
79
|
+
nov: 11,
|
|
80
|
+
dec: 12,
|
|
81
|
+
sun: 0,
|
|
82
|
+
mon: 1,
|
|
83
|
+
tue: 2,
|
|
84
|
+
wed: 3,
|
|
85
|
+
thu: 4,
|
|
86
|
+
fri: 5,
|
|
87
|
+
sat: 6
|
|
88
|
+
};
|
|
89
|
+
var tokensRegex = new RegExp(Object.keys(cronTokens).join("|"), "g");
|
|
90
|
+
|
|
91
|
+
// ../utilities/dist/index.mjs
|
|
92
|
+
var __defProp2 = Object.defineProperty;
|
|
93
|
+
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
94
|
+
function arrayStrictEquals(arr1, arr2) {
|
|
95
|
+
if (arr1 === arr2)
|
|
96
|
+
return true;
|
|
97
|
+
if (arr1.length !== arr2.length)
|
|
98
|
+
return false;
|
|
99
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
100
|
+
if (arr1[i] !== arr2[i] || typeof arr1[i] !== typeof arr2[i])
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
__name(arrayStrictEquals, "arrayStrictEquals");
|
|
106
|
+
__name2(arrayStrictEquals, "arrayStrictEquals");
|
|
107
|
+
function cast(value) {
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
__name(cast, "cast");
|
|
111
|
+
__name2(cast, "cast");
|
|
112
|
+
function chunk(array, chunkSize) {
|
|
113
|
+
if (!Array.isArray(array))
|
|
114
|
+
throw new TypeError("entries must be an array.");
|
|
115
|
+
if (!Number.isInteger(chunkSize))
|
|
116
|
+
throw new TypeError("chunkSize must be an integer.");
|
|
117
|
+
if (chunkSize < 1)
|
|
118
|
+
throw new RangeError("chunkSize must be 1 or greater.");
|
|
119
|
+
const clone = array.slice();
|
|
120
|
+
const chunks = [];
|
|
121
|
+
while (clone.length)
|
|
122
|
+
chunks.push(clone.splice(0, chunkSize));
|
|
123
|
+
return chunks;
|
|
124
|
+
}
|
|
125
|
+
__name(chunk, "chunk");
|
|
126
|
+
__name2(chunk, "chunk");
|
|
127
|
+
function classExtends(value, base) {
|
|
128
|
+
let ctor = value;
|
|
129
|
+
while (ctor !== null) {
|
|
130
|
+
if (ctor === base)
|
|
131
|
+
return true;
|
|
132
|
+
ctor = Object.getPrototypeOf(ctor);
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
__name(classExtends, "classExtends");
|
|
137
|
+
__name2(classExtends, "classExtends");
|
|
138
|
+
var zws = String.fromCharCode(8203);
|
|
139
|
+
function codeBlock(language, expression) {
|
|
140
|
+
if (typeof expression === "string") {
|
|
141
|
+
if (expression.length === 0)
|
|
142
|
+
return `\`\`\`${zws}\`\`\``;
|
|
143
|
+
return `\`\`\`${language}
|
|
144
|
+
${expression.replace(/```/, `\`${zws}\`\``).replace(/`$/g, `\`${zws}`)}\`\`\``;
|
|
145
|
+
}
|
|
146
|
+
return `\`\`\`${language}
|
|
147
|
+
${expression || zws}\`\`\``;
|
|
148
|
+
}
|
|
149
|
+
__name(codeBlock, "codeBlock");
|
|
150
|
+
__name2(codeBlock, "codeBlock");
|
|
151
|
+
function splitText(str, length, char = " ") {
|
|
152
|
+
const x = str.substring(0, length).lastIndexOf(char);
|
|
153
|
+
const pos = x === -1 ? length : x;
|
|
154
|
+
return str.substring(0, pos);
|
|
155
|
+
}
|
|
156
|
+
__name(splitText, "splitText");
|
|
157
|
+
__name2(splitText, "splitText");
|
|
158
|
+
function cutText(str, length) {
|
|
159
|
+
if (str.length < length)
|
|
160
|
+
return str;
|
|
161
|
+
const cut = splitText(str, length - 3);
|
|
162
|
+
if (cut.length < length - 3)
|
|
163
|
+
return `${cut}...`;
|
|
164
|
+
return `${cut.slice(0, length - 3)}...`;
|
|
165
|
+
}
|
|
166
|
+
__name(cutText, "cutText");
|
|
167
|
+
__name2(cutText, "cutText");
|
|
168
|
+
function debounce(func, options = {}) {
|
|
169
|
+
var _a;
|
|
170
|
+
let lastArgs;
|
|
171
|
+
let result;
|
|
172
|
+
let timerId;
|
|
173
|
+
let lastCallTime;
|
|
174
|
+
let lastInvokeTime = 0;
|
|
175
|
+
const wait = (_a = options.wait) != null ? _a : 0;
|
|
176
|
+
const maxWait = typeof options.maxWait === "number" ? Math.max(options.maxWait, wait) : null;
|
|
177
|
+
function invokeFunc(time) {
|
|
178
|
+
const args = lastArgs;
|
|
179
|
+
lastArgs = void 0;
|
|
180
|
+
lastInvokeTime = time;
|
|
181
|
+
result = func(...args);
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
__name(invokeFunc, "invokeFunc");
|
|
185
|
+
__name2(invokeFunc, "invokeFunc");
|
|
186
|
+
function leadingEdge(time) {
|
|
187
|
+
lastInvokeTime = time;
|
|
188
|
+
timerId = setTimeout(timerExpired, wait);
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
__name(leadingEdge, "leadingEdge");
|
|
192
|
+
__name2(leadingEdge, "leadingEdge");
|
|
193
|
+
function remainingWait(time) {
|
|
194
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
195
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
196
|
+
const result2 = wait - timeSinceLastCall;
|
|
197
|
+
return maxWait === null ? result2 : Math.min(result2, maxWait - timeSinceLastInvoke);
|
|
198
|
+
}
|
|
199
|
+
__name(remainingWait, "remainingWait");
|
|
200
|
+
__name2(remainingWait, "remainingWait");
|
|
201
|
+
function shouldInvoke(time) {
|
|
202
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
203
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
204
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxWait !== null && timeSinceLastInvoke >= maxWait;
|
|
205
|
+
}
|
|
206
|
+
__name(shouldInvoke, "shouldInvoke");
|
|
207
|
+
__name2(shouldInvoke, "shouldInvoke");
|
|
208
|
+
function timerExpired() {
|
|
209
|
+
const time = Date.now();
|
|
210
|
+
if (shouldInvoke(time)) {
|
|
211
|
+
trailingEdge(time);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
215
|
+
}
|
|
216
|
+
__name(timerExpired, "timerExpired");
|
|
217
|
+
__name2(timerExpired, "timerExpired");
|
|
218
|
+
function trailingEdge(time) {
|
|
219
|
+
timerId = void 0;
|
|
220
|
+
return invokeFunc(time);
|
|
221
|
+
}
|
|
222
|
+
__name(trailingEdge, "trailingEdge");
|
|
223
|
+
__name2(trailingEdge, "trailingEdge");
|
|
224
|
+
function cancel() {
|
|
225
|
+
if (timerId !== void 0) {
|
|
226
|
+
clearTimeout(timerId);
|
|
227
|
+
}
|
|
228
|
+
lastInvokeTime = 0;
|
|
229
|
+
lastArgs = void 0;
|
|
230
|
+
lastCallTime = void 0;
|
|
231
|
+
timerId = void 0;
|
|
232
|
+
}
|
|
233
|
+
__name(cancel, "cancel");
|
|
234
|
+
__name2(cancel, "cancel");
|
|
235
|
+
function flush() {
|
|
236
|
+
return timerId === void 0 ? result : trailingEdge(Date.now());
|
|
237
|
+
}
|
|
238
|
+
__name(flush, "flush");
|
|
239
|
+
__name2(flush, "flush");
|
|
240
|
+
function debounced(...args) {
|
|
241
|
+
const time = Date.now();
|
|
242
|
+
const isInvoking = shouldInvoke(time);
|
|
243
|
+
lastArgs = args;
|
|
244
|
+
lastCallTime = time;
|
|
245
|
+
if (isInvoking) {
|
|
246
|
+
if (timerId === void 0) {
|
|
247
|
+
return leadingEdge(lastCallTime);
|
|
248
|
+
}
|
|
249
|
+
if (maxWait !== null) {
|
|
250
|
+
timerId = setTimeout(timerExpired, wait);
|
|
251
|
+
return invokeFunc(lastCallTime);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (timerId === void 0) {
|
|
255
|
+
timerId = setTimeout(timerExpired, wait);
|
|
256
|
+
}
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
__name(debounced, "debounced");
|
|
260
|
+
__name2(debounced, "debounced");
|
|
261
|
+
debounced.cancel = cancel;
|
|
262
|
+
debounced.flush = flush;
|
|
263
|
+
return debounced;
|
|
264
|
+
}
|
|
265
|
+
__name(debounce, "debounce");
|
|
266
|
+
__name2(debounce, "debounce");
|
|
267
|
+
var primitiveTypes = ["string", "bigint", "number", "boolean"];
|
|
268
|
+
function isPrimitive(input) {
|
|
269
|
+
return primitiveTypes.includes(typeof input);
|
|
270
|
+
}
|
|
271
|
+
__name(isPrimitive, "isPrimitive");
|
|
272
|
+
__name2(isPrimitive, "isPrimitive");
|
|
273
|
+
function deepClone(source) {
|
|
274
|
+
if (source === null || isPrimitive(source)) {
|
|
275
|
+
return source;
|
|
276
|
+
}
|
|
277
|
+
if (source instanceof Date) {
|
|
278
|
+
const output = new source.constructor(source);
|
|
279
|
+
return output;
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(source)) {
|
|
282
|
+
const output = new source.constructor(source.length);
|
|
283
|
+
for (let i = 0; i < source.length; i++) {
|
|
284
|
+
output[i] = deepClone(source[i]);
|
|
285
|
+
}
|
|
286
|
+
return output;
|
|
287
|
+
}
|
|
288
|
+
if (source instanceof Map) {
|
|
289
|
+
const output = new source.constructor();
|
|
290
|
+
for (const [key, value] of source.entries()) {
|
|
291
|
+
output.set(key, deepClone(value));
|
|
292
|
+
}
|
|
293
|
+
return output;
|
|
294
|
+
}
|
|
295
|
+
if (source instanceof Set) {
|
|
296
|
+
const output = new source.constructor();
|
|
297
|
+
for (const value of source.values()) {
|
|
298
|
+
output.add(deepClone(value));
|
|
299
|
+
}
|
|
300
|
+
return output;
|
|
301
|
+
}
|
|
302
|
+
if (typeof source === "object") {
|
|
303
|
+
const output = new source.constructor();
|
|
304
|
+
for (const [key, value] of Object.entries(source)) {
|
|
305
|
+
Object.defineProperty(output, key, {
|
|
306
|
+
configurable: true,
|
|
307
|
+
enumerable: true,
|
|
308
|
+
value: deepClone(value),
|
|
309
|
+
writable: true
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return output;
|
|
313
|
+
}
|
|
314
|
+
return source;
|
|
315
|
+
}
|
|
316
|
+
__name(deepClone, "deepClone");
|
|
317
|
+
__name2(deepClone, "deepClone");
|
|
318
|
+
function isNullOrUndefined(value) {
|
|
319
|
+
return value === void 0 || value === null;
|
|
320
|
+
}
|
|
321
|
+
__name(isNullOrUndefined, "isNullOrUndefined");
|
|
322
|
+
__name2(isNullOrUndefined, "isNullOrUndefined");
|
|
323
|
+
function filterNullAndUndefined(value) {
|
|
324
|
+
return !isNullOrUndefined(value);
|
|
325
|
+
}
|
|
326
|
+
__name(filterNullAndUndefined, "filterNullAndUndefined");
|
|
327
|
+
__name2(filterNullAndUndefined, "filterNullAndUndefined");
|
|
328
|
+
function isNullOrUndefinedOrEmpty(value) {
|
|
329
|
+
return isNullOrUndefined(value) || value.length === 0;
|
|
330
|
+
}
|
|
331
|
+
__name(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
|
|
332
|
+
__name2(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
|
|
333
|
+
function filterNullAndUndefinedAndEmpty(value) {
|
|
334
|
+
return !isNullOrUndefinedOrEmpty(value);
|
|
335
|
+
}
|
|
336
|
+
__name(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
|
|
337
|
+
__name2(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
|
|
338
|
+
function isNullOrUndefinedOrZero(value) {
|
|
339
|
+
return value === 0 || isNullOrUndefined(value);
|
|
340
|
+
}
|
|
341
|
+
__name(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
|
|
342
|
+
__name2(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
|
|
343
|
+
function filterNullAndUndefinedAndZero(value) {
|
|
344
|
+
return !isNullOrUndefinedOrZero(value);
|
|
345
|
+
}
|
|
346
|
+
__name(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
|
|
347
|
+
__name2(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
|
|
348
|
+
function getDeepObjectKeys(obj, options) {
|
|
349
|
+
return [...getDeepObjectKeysGenerator(obj, options)];
|
|
350
|
+
}
|
|
351
|
+
__name(getDeepObjectKeys, "getDeepObjectKeys");
|
|
352
|
+
__name2(getDeepObjectKeys, "getDeepObjectKeys");
|
|
353
|
+
function* getDeepObjectKeysGenerator(obj, { arrayKeysIndexStyle = "dotted" } = { arrayKeysIndexStyle: "dotted" }) {
|
|
354
|
+
if (Array.isArray(obj)) {
|
|
355
|
+
for (const [index, value] of obj.entries()) {
|
|
356
|
+
yield* getDeepArrayKeysRecursive(value, index, { arrayKeysIndexStyle });
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
360
|
+
yield* getDeepObjectKeysRecursive(value, `${key}`, { arrayKeysIndexStyle });
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
__name(getDeepObjectKeysGenerator, "getDeepObjectKeysGenerator");
|
|
365
|
+
__name2(getDeepObjectKeysGenerator, "getDeepObjectKeysGenerator");
|
|
366
|
+
function* getDeepArrayKeysRecursive(value, index, { arrayKeysIndexStyle }) {
|
|
367
|
+
const resolvedIndex = arrayKeysIndexStyle === "dotted" ? `${index}` : arrayKeysIndexStyle === "braces" ? `[${index}]` : `[${index}].`;
|
|
368
|
+
yield* getDeepObjectKeysRecursive(value, resolvedIndex, { arrayKeysIndexStyle });
|
|
369
|
+
}
|
|
370
|
+
__name(getDeepArrayKeysRecursive, "getDeepArrayKeysRecursive");
|
|
371
|
+
__name2(getDeepArrayKeysRecursive, "getDeepArrayKeysRecursive");
|
|
372
|
+
function* getDeepObjectKeysRecursive(obj, prefix, { arrayKeysIndexStyle }) {
|
|
373
|
+
if (typeof obj !== "object" || obj === null) {
|
|
374
|
+
yield prefix;
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (Array.isArray(obj)) {
|
|
378
|
+
for (const [index, value] of obj.entries()) {
|
|
379
|
+
const resolvedPrefixedIndex = arrayKeysIndexStyle === "dotted" ? `${prefix}.${index}` : `${prefix}[${index}]`;
|
|
380
|
+
yield* getDeepObjectKeysRecursive(value, resolvedPrefixedIndex, { arrayKeysIndexStyle });
|
|
381
|
+
}
|
|
382
|
+
} else {
|
|
383
|
+
const objectEntries = Object.entries(obj);
|
|
384
|
+
if (isNullOrUndefinedOrEmpty(objectEntries) && prefix) {
|
|
385
|
+
yield prefix;
|
|
386
|
+
} else {
|
|
387
|
+
for (const [key, value] of objectEntries) {
|
|
388
|
+
yield* getDeepObjectKeysRecursive(value, arrayKeysIndexStyle === "braces" ? `${prefix}${key}` : `${prefix}.${key}`, {
|
|
389
|
+
arrayKeysIndexStyle
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
__name(getDeepObjectKeysRecursive, "getDeepObjectKeysRecursive");
|
|
396
|
+
__name2(getDeepObjectKeysRecursive, "getDeepObjectKeysRecursive");
|
|
397
|
+
function hasAtLeastOneKeyInMap(map, keys) {
|
|
398
|
+
return keys.some((key) => map.has(key));
|
|
399
|
+
}
|
|
400
|
+
__name(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
|
|
401
|
+
__name2(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
|
|
402
|
+
var zws2 = String.fromCharCode(8203);
|
|
403
|
+
function inlineCodeBlock(input) {
|
|
404
|
+
return `\`${input.replace(/ /g, "\xA0").replace(/`/g, `\`${zws2}`)}\``;
|
|
405
|
+
}
|
|
406
|
+
__name(inlineCodeBlock, "inlineCodeBlock");
|
|
407
|
+
__name2(inlineCodeBlock, "inlineCodeBlock");
|
|
408
|
+
function isClass(input) {
|
|
409
|
+
return typeof input === "function" && typeof input.prototype === "object";
|
|
410
|
+
}
|
|
411
|
+
__name(isClass, "isClass");
|
|
412
|
+
__name2(isClass, "isClass");
|
|
413
|
+
function isFunction(input) {
|
|
414
|
+
return typeof input === "function";
|
|
415
|
+
}
|
|
416
|
+
__name(isFunction, "isFunction");
|
|
417
|
+
__name2(isFunction, "isFunction");
|
|
418
|
+
function isNumber(input) {
|
|
419
|
+
if (typeof input === "string")
|
|
420
|
+
input = Number(input);
|
|
421
|
+
return typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input);
|
|
422
|
+
}
|
|
423
|
+
__name(isNumber, "isNumber");
|
|
424
|
+
__name2(isNumber, "isNumber");
|
|
425
|
+
function isObject(input, constructorType) {
|
|
426
|
+
return typeof input === "object" && input ? input.constructor === (constructorType != null ? constructorType : Object) : false;
|
|
427
|
+
}
|
|
428
|
+
__name(isObject, "isObject");
|
|
429
|
+
__name2(isObject, "isObject");
|
|
430
|
+
function hasThen(input) {
|
|
431
|
+
return Reflect.has(input, "then") && isFunction(input.then);
|
|
432
|
+
}
|
|
433
|
+
__name(hasThen, "hasThen");
|
|
434
|
+
__name2(hasThen, "hasThen");
|
|
435
|
+
function hasCatch(input) {
|
|
436
|
+
return Reflect.has(input, "catch") && isFunction(input.catch);
|
|
437
|
+
}
|
|
438
|
+
__name(hasCatch, "hasCatch");
|
|
439
|
+
__name2(hasCatch, "hasCatch");
|
|
440
|
+
function isThenable(input) {
|
|
441
|
+
if (typeof input !== "object" || input === null)
|
|
442
|
+
return false;
|
|
443
|
+
return input instanceof Promise || input !== Promise.prototype && hasThen(input) && hasCatch(input);
|
|
444
|
+
}
|
|
445
|
+
__name(isThenable, "isThenable");
|
|
446
|
+
__name2(isThenable, "isThenable");
|
|
447
|
+
function lazy(cb) {
|
|
448
|
+
let defaultValue;
|
|
449
|
+
return () => defaultValue != null ? defaultValue : defaultValue = cb();
|
|
450
|
+
}
|
|
451
|
+
__name(lazy, "lazy");
|
|
452
|
+
__name2(lazy, "lazy");
|
|
453
|
+
function makeObject(path, value, obj = {}) {
|
|
454
|
+
if (path.includes(".")) {
|
|
455
|
+
const route = path.split(".");
|
|
456
|
+
const lastKey = route.pop();
|
|
457
|
+
let reference = obj;
|
|
458
|
+
for (const key of route) {
|
|
459
|
+
if (!reference[key])
|
|
460
|
+
reference[key] = {};
|
|
461
|
+
reference = reference[key];
|
|
462
|
+
}
|
|
463
|
+
reference[lastKey] = value;
|
|
464
|
+
} else {
|
|
465
|
+
obj[path] = value;
|
|
466
|
+
}
|
|
467
|
+
return obj;
|
|
468
|
+
}
|
|
469
|
+
__name(makeObject, "makeObject");
|
|
470
|
+
__name2(makeObject, "makeObject");
|
|
471
|
+
function mergeDefault(base, overwrites) {
|
|
472
|
+
if (!overwrites)
|
|
473
|
+
return deepClone(base);
|
|
474
|
+
for (const [baseKey, baseValue] of Object.entries(base)) {
|
|
475
|
+
const overwritesValueAtBaseKey = Reflect.get(overwrites, baseKey);
|
|
476
|
+
if (typeof overwritesValueAtBaseKey === "undefined") {
|
|
477
|
+
Reflect.set(overwrites, baseKey, deepClone(baseValue));
|
|
478
|
+
} else if (isObject(overwritesValueAtBaseKey)) {
|
|
479
|
+
Reflect.set(overwrites, baseKey, mergeDefault(baseValue != null ? baseValue : {}, overwritesValueAtBaseKey));
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return overwrites;
|
|
483
|
+
}
|
|
484
|
+
__name(mergeDefault, "mergeDefault");
|
|
485
|
+
__name2(mergeDefault, "mergeDefault");
|
|
486
|
+
function mergeObjects(objTarget, objSource) {
|
|
487
|
+
for (const [key, value] of Object.entries(objSource)) {
|
|
488
|
+
const targetValue = Reflect.get(objTarget, key);
|
|
489
|
+
if (isObject(value)) {
|
|
490
|
+
Reflect.set(objTarget, key, isObject(targetValue) ? mergeObjects(targetValue, value) : value);
|
|
491
|
+
} else if (!isObject(targetValue)) {
|
|
492
|
+
Reflect.set(objTarget, key, value);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return objTarget;
|
|
496
|
+
}
|
|
497
|
+
__name(mergeObjects, "mergeObjects");
|
|
498
|
+
__name2(mergeObjects, "mergeObjects");
|
|
499
|
+
function noop() {
|
|
500
|
+
}
|
|
501
|
+
__name(noop, "noop");
|
|
502
|
+
__name2(noop, "noop");
|
|
503
|
+
function objectToTuples(obj, prefix = "") {
|
|
504
|
+
const entries = [];
|
|
505
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
506
|
+
if (isObject(value)) {
|
|
507
|
+
entries.push(...objectToTuples(value, `${prefix}${key}.`));
|
|
508
|
+
} else {
|
|
509
|
+
entries.push([`${prefix}${key}`, value]);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
return entries;
|
|
513
|
+
}
|
|
514
|
+
__name(objectToTuples, "objectToTuples");
|
|
515
|
+
__name2(objectToTuples, "objectToTuples");
|
|
516
|
+
function parseURL(url) {
|
|
517
|
+
try {
|
|
518
|
+
return new URL(url);
|
|
519
|
+
} catch {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
__name(parseURL, "parseURL");
|
|
524
|
+
__name2(parseURL, "parseURL");
|
|
525
|
+
function partition(array, predicate) {
|
|
526
|
+
if (!Array.isArray(array))
|
|
527
|
+
throw new TypeError("entries must be an array.");
|
|
528
|
+
if (!isFunction(predicate))
|
|
529
|
+
throw new TypeError("predicate must be an function that returns a boolean value.");
|
|
530
|
+
const partitionOne = [];
|
|
531
|
+
const partitionTwo = [];
|
|
532
|
+
for (let i = 0; i < array.length; i++) {
|
|
533
|
+
if (predicate(array[i], i)) {
|
|
534
|
+
partitionOne.push(array[i]);
|
|
535
|
+
} else {
|
|
536
|
+
partitionTwo.push(array[i]);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return [partitionOne, partitionTwo];
|
|
540
|
+
}
|
|
541
|
+
__name(partition, "partition");
|
|
542
|
+
__name2(partition, "partition");
|
|
543
|
+
function range(min, max, step) {
|
|
544
|
+
return new Array(Math.floor((max - min) / step) + 1).fill(0).map((_val, i) => min + i * step);
|
|
545
|
+
}
|
|
546
|
+
__name(range, "range");
|
|
547
|
+
__name2(range, "range");
|
|
548
|
+
var REGEXPESC = /[-/\\^$*+?.()|[\]{}]/g;
|
|
549
|
+
function regExpEsc(str) {
|
|
550
|
+
return str.replace(REGEXPESC, "\\$&");
|
|
551
|
+
}
|
|
552
|
+
__name(regExpEsc, "regExpEsc");
|
|
553
|
+
__name2(regExpEsc, "regExpEsc");
|
|
554
|
+
function roundNumber(num, scale = 0) {
|
|
555
|
+
if (!num.toString().includes("e")) {
|
|
556
|
+
return Number(`${Math.round(Number(`${num}e+${scale}`))}e-${scale}`);
|
|
557
|
+
}
|
|
558
|
+
const arr = `${num}`.split("e");
|
|
559
|
+
let sig = "";
|
|
560
|
+
if (Number(arr[1]) + scale > 0) {
|
|
561
|
+
sig = "+";
|
|
562
|
+
}
|
|
563
|
+
return Number(`${Math.round(Number(`${Number(arr[0])}e${sig}${Number(arr[1]) + scale}`))}e-${scale}`);
|
|
564
|
+
}
|
|
565
|
+
__name(roundNumber, "roundNumber");
|
|
566
|
+
__name2(roundNumber, "roundNumber");
|
|
567
|
+
var TO_TITLE_CASE = /[A-Za-zÀ-ÖØ-öø-ÿ]\S*/g;
|
|
568
|
+
var baseVariants = {
|
|
569
|
+
textchannel: "TextChannel",
|
|
570
|
+
voicechannel: "VoiceChannel",
|
|
571
|
+
categorychannel: "CategoryChannel",
|
|
572
|
+
guildmember: "GuildMember"
|
|
573
|
+
};
|
|
574
|
+
function toTitleCase(str, options = {}) {
|
|
575
|
+
const { additionalVariants = {}, caseSensitive } = options;
|
|
576
|
+
const titleCaseVariants = {
|
|
577
|
+
...baseVariants,
|
|
578
|
+
...caseSensitive ? additionalVariants : Object.entries(additionalVariants).reduce(
|
|
579
|
+
(variants, [key, variant]) => ({ ...variants, [key.toLowerCase()]: variant }),
|
|
580
|
+
{}
|
|
581
|
+
)
|
|
582
|
+
};
|
|
583
|
+
return str.replace(
|
|
584
|
+
TO_TITLE_CASE,
|
|
585
|
+
(txt) => {
|
|
586
|
+
var _a;
|
|
587
|
+
return (_a = titleCaseVariants[caseSensitive ? txt : txt.toLowerCase()]) != null ? _a : txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
588
|
+
}
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
__name(toTitleCase, "toTitleCase");
|
|
592
|
+
__name2(toTitleCase, "toTitleCase");
|
|
593
|
+
function tryParse(value) {
|
|
594
|
+
try {
|
|
595
|
+
return JSON.parse(value);
|
|
596
|
+
} catch (err) {
|
|
597
|
+
return value;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
__name(tryParse, "tryParse");
|
|
601
|
+
__name2(tryParse, "tryParse");
|
|
602
|
+
|
|
603
|
+
// src/lib/Cron.ts
|
|
604
|
+
var Cron = class {
|
|
605
|
+
constructor(cron) {
|
|
606
|
+
__publicField(this, "cron");
|
|
607
|
+
__publicField(this, "normalized");
|
|
608
|
+
__publicField(this, "minutes");
|
|
609
|
+
__publicField(this, "hours");
|
|
610
|
+
__publicField(this, "days");
|
|
611
|
+
__publicField(this, "months");
|
|
612
|
+
__publicField(this, "dows");
|
|
613
|
+
this.cron = cron.toLowerCase();
|
|
614
|
+
this.normalized = Cron.normalize(this.cron);
|
|
615
|
+
[this.minutes, this.hours, this.days, this.months, this.dows] = Cron.parseString(this.normalized);
|
|
616
|
+
}
|
|
617
|
+
next(outset = new Date(), origin = true) {
|
|
618
|
+
if (!this.days.includes(outset.getUTCDate()) || !this.months.includes(outset.getUTCMonth() + 1) || !this.dows.includes(outset.getUTCDay())) {
|
|
619
|
+
return this.next(new Date(outset.getTime() + 864e5 /* Day */), false);
|
|
620
|
+
}
|
|
621
|
+
if (!origin)
|
|
622
|
+
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), this.hours[0], this.minutes[0]));
|
|
623
|
+
const now = new Date(outset.getTime() + 6e4);
|
|
624
|
+
for (const hour of this.hours) {
|
|
625
|
+
if (hour < now.getUTCHours())
|
|
626
|
+
continue;
|
|
627
|
+
for (const minute of this.minutes) {
|
|
628
|
+
if (hour === now.getUTCHours() && minute < now.getUTCMinutes())
|
|
629
|
+
continue;
|
|
630
|
+
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), hour, minute));
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return this.next(new Date(outset.getTime() + 864e5 /* Day */), false);
|
|
634
|
+
}
|
|
635
|
+
static normalize(cron) {
|
|
636
|
+
if (Reflect.has(predefined, cron))
|
|
637
|
+
return Reflect.get(predefined, cron);
|
|
638
|
+
const now = new Date();
|
|
639
|
+
cron = cron.split(" ").map(
|
|
640
|
+
(val, i) => val.replace(wildcardRegex, (match) => {
|
|
641
|
+
if (match === "h")
|
|
642
|
+
return (Math.floor(Math.random() * allowedNum[i][1]) + allowedNum[i][0]).toString();
|
|
643
|
+
if (match === "?") {
|
|
644
|
+
switch (i) {
|
|
645
|
+
case 0:
|
|
646
|
+
return now.getUTCMinutes().toString();
|
|
647
|
+
case 1:
|
|
648
|
+
return now.getUTCHours().toString();
|
|
649
|
+
case 2:
|
|
650
|
+
return now.getUTCDate().toString();
|
|
651
|
+
case 3:
|
|
652
|
+
return now.getUTCMonth().toString();
|
|
653
|
+
case 4:
|
|
654
|
+
return now.getUTCDay().toString();
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return match;
|
|
658
|
+
})
|
|
659
|
+
).join(" ");
|
|
660
|
+
return cron.replace(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));
|
|
661
|
+
}
|
|
662
|
+
static parseString(cron) {
|
|
663
|
+
const parts = cron.split(" ");
|
|
664
|
+
if (parts.length !== 5)
|
|
665
|
+
throw new Error("Invalid Cron Provided");
|
|
666
|
+
return parts.map((part, i) => Cron.parsePart(part, i));
|
|
667
|
+
}
|
|
668
|
+
static parsePart(cronPart, id) {
|
|
669
|
+
if (cronPart.includes(",")) {
|
|
670
|
+
const res = [];
|
|
671
|
+
for (const part of cronPart.split(","))
|
|
672
|
+
res.push(...Cron.parsePart(part, id));
|
|
673
|
+
return [...new Set(res)].sort((a, b) => a - b);
|
|
674
|
+
}
|
|
675
|
+
const [, wild, minStr, maxStr, step] = partRegex.exec(cronPart);
|
|
676
|
+
let [min, max] = [parseInt(minStr, 10), parseInt(maxStr, 10)];
|
|
677
|
+
if (wild)
|
|
678
|
+
[min, max] = allowedNum[id];
|
|
679
|
+
else if (!max && !step)
|
|
680
|
+
return [min];
|
|
681
|
+
[min, max] = [min, max || allowedNum[id][1]].sort((a, b) => a - b);
|
|
682
|
+
return range(min, max, parseInt(step, 10) || 1);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
__name(Cron, "Cron");
|
|
686
|
+
return __toCommonJS(src_exports);
|
|
687
|
+
})();
|
|
688
|
+
/**
|
|
689
|
+
* Split a string by its latest space character in a range from the character 0 to the selected one.
|
|
690
|
+
* @param str The text to split.
|
|
691
|
+
* @param length The length of the desired string.
|
|
692
|
+
* @param char The character to split with
|
|
693
|
+
* @copyright 2019 Aura Román
|
|
694
|
+
* @license Apache-2.0
|
|
695
|
+
*/
|
|
696
|
+
/**
|
|
697
|
+
* Split a text by its latest space character in a range from the character 0 to the selected one.
|
|
698
|
+
* @param str The text to split.
|
|
699
|
+
* @param length The length of the desired string.
|
|
700
|
+
* @copyright 2019 Aura Román
|
|
701
|
+
* @license Apache-2.0
|
|
702
|
+
*/
|
|
703
|
+
//# sourceMappingURL=index.global.js.map
|