@sapphire/ratelimits 2.4.5-next.fca7a80.0 → 2.4.5-next.ff9cb61.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/README.md +2 -2
- package/dist/index.d.ts +92 -3
- package/dist/index.global.js +3 -947
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -6
- package/dist/lib/RateLimit.d.ts +0 -48
- package/dist/lib/RateLimitManager.d.ts +0 -45
package/dist/index.global.js
CHANGED
|
@@ -71,786 +71,14 @@ var SapphireRatelimits = (() => {
|
|
|
71
71
|
};
|
|
72
72
|
__name(RateLimit, "RateLimit");
|
|
73
73
|
|
|
74
|
-
// ../
|
|
74
|
+
// ../timer-manager/dist/index.mjs
|
|
75
75
|
var __defProp2 = Object.defineProperty;
|
|
76
|
+
var __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
|
|
76
77
|
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
77
|
-
function arrayStrictEquals(arr1, arr2) {
|
|
78
|
-
if (arr1 === arr2)
|
|
79
|
-
return true;
|
|
80
|
-
if (arr1.length !== arr2.length)
|
|
81
|
-
return false;
|
|
82
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
83
|
-
if (arr1[i] !== arr2[i] || typeof arr1[i] !== typeof arr2[i])
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
__name(arrayStrictEquals, "arrayStrictEquals");
|
|
89
|
-
__name2(arrayStrictEquals, "arrayStrictEquals");
|
|
90
|
-
function cast(value) {
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
__name(cast, "cast");
|
|
94
|
-
__name2(cast, "cast");
|
|
95
|
-
function chunk(array, chunkSize) {
|
|
96
|
-
if (!Array.isArray(array))
|
|
97
|
-
throw new TypeError("entries must be an array.");
|
|
98
|
-
if (!Number.isInteger(chunkSize))
|
|
99
|
-
throw new TypeError("chunkSize must be an integer.");
|
|
100
|
-
if (chunkSize < 1)
|
|
101
|
-
throw new RangeError("chunkSize must be 1 or greater.");
|
|
102
|
-
const clone = array.slice();
|
|
103
|
-
const chunks = [];
|
|
104
|
-
while (clone.length)
|
|
105
|
-
chunks.push(clone.splice(0, chunkSize));
|
|
106
|
-
return chunks;
|
|
107
|
-
}
|
|
108
|
-
__name(chunk, "chunk");
|
|
109
|
-
__name2(chunk, "chunk");
|
|
110
|
-
function classExtends(value, base) {
|
|
111
|
-
let ctor = value;
|
|
112
|
-
while (ctor !== null) {
|
|
113
|
-
if (ctor === base)
|
|
114
|
-
return true;
|
|
115
|
-
ctor = Object.getPrototypeOf(ctor);
|
|
116
|
-
}
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
__name(classExtends, "classExtends");
|
|
120
|
-
__name2(classExtends, "classExtends");
|
|
121
|
-
var zws = String.fromCharCode(8203);
|
|
122
|
-
function codeBlock(language, expression) {
|
|
123
|
-
if (typeof expression === "string") {
|
|
124
|
-
if (expression.length === 0)
|
|
125
|
-
return `\`\`\`${zws}\`\`\``;
|
|
126
|
-
return `\`\`\`${language}
|
|
127
|
-
${expression.replace(/```/, `\`${zws}\`\``).replace(/`$/g, `\`${zws}`)}\`\`\``;
|
|
128
|
-
}
|
|
129
|
-
return `\`\`\`${language}
|
|
130
|
-
${expression || zws}\`\`\``;
|
|
131
|
-
}
|
|
132
|
-
__name(codeBlock, "codeBlock");
|
|
133
|
-
__name2(codeBlock, "codeBlock");
|
|
134
|
-
function splitText(str, length, char = " ") {
|
|
135
|
-
const x = str.substring(0, length).lastIndexOf(char);
|
|
136
|
-
const pos = x === -1 ? length : x;
|
|
137
|
-
return str.substring(0, pos);
|
|
138
|
-
}
|
|
139
|
-
__name(splitText, "splitText");
|
|
140
|
-
__name2(splitText, "splitText");
|
|
141
|
-
function cutText(str, length) {
|
|
142
|
-
if (str.length < length)
|
|
143
|
-
return str;
|
|
144
|
-
const cut = splitText(str, length - 3);
|
|
145
|
-
if (cut.length < length - 3)
|
|
146
|
-
return `${cut}...`;
|
|
147
|
-
return `${cut.slice(0, length - 3)}...`;
|
|
148
|
-
}
|
|
149
|
-
__name(cutText, "cutText");
|
|
150
|
-
__name2(cutText, "cutText");
|
|
151
|
-
function debounce(func, options = {}) {
|
|
152
|
-
var _a;
|
|
153
|
-
let lastArgs;
|
|
154
|
-
let result;
|
|
155
|
-
let timerId;
|
|
156
|
-
let lastCallTime;
|
|
157
|
-
let lastInvokeTime = 0;
|
|
158
|
-
const wait = (_a = options.wait) != null ? _a : 0;
|
|
159
|
-
const maxWait = typeof options.maxWait === "number" ? Math.max(options.maxWait, wait) : null;
|
|
160
|
-
function invokeFunc(time) {
|
|
161
|
-
const args = lastArgs;
|
|
162
|
-
lastArgs = void 0;
|
|
163
|
-
lastInvokeTime = time;
|
|
164
|
-
result = func(...args);
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
__name(invokeFunc, "invokeFunc");
|
|
168
|
-
__name2(invokeFunc, "invokeFunc");
|
|
169
|
-
function leadingEdge(time) {
|
|
170
|
-
lastInvokeTime = time;
|
|
171
|
-
timerId = setTimeout(timerExpired, wait);
|
|
172
|
-
return result;
|
|
173
|
-
}
|
|
174
|
-
__name(leadingEdge, "leadingEdge");
|
|
175
|
-
__name2(leadingEdge, "leadingEdge");
|
|
176
|
-
function remainingWait(time) {
|
|
177
|
-
const timeSinceLastCall = time - lastCallTime;
|
|
178
|
-
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
179
|
-
const result2 = wait - timeSinceLastCall;
|
|
180
|
-
return maxWait === null ? result2 : Math.min(result2, maxWait - timeSinceLastInvoke);
|
|
181
|
-
}
|
|
182
|
-
__name(remainingWait, "remainingWait");
|
|
183
|
-
__name2(remainingWait, "remainingWait");
|
|
184
|
-
function shouldInvoke(time) {
|
|
185
|
-
const timeSinceLastCall = time - lastCallTime;
|
|
186
|
-
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
187
|
-
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxWait !== null && timeSinceLastInvoke >= maxWait;
|
|
188
|
-
}
|
|
189
|
-
__name(shouldInvoke, "shouldInvoke");
|
|
190
|
-
__name2(shouldInvoke, "shouldInvoke");
|
|
191
|
-
function timerExpired() {
|
|
192
|
-
const time = Date.now();
|
|
193
|
-
if (shouldInvoke(time)) {
|
|
194
|
-
trailingEdge(time);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
198
|
-
}
|
|
199
|
-
__name(timerExpired, "timerExpired");
|
|
200
|
-
__name2(timerExpired, "timerExpired");
|
|
201
|
-
function trailingEdge(time) {
|
|
202
|
-
timerId = void 0;
|
|
203
|
-
return invokeFunc(time);
|
|
204
|
-
}
|
|
205
|
-
__name(trailingEdge, "trailingEdge");
|
|
206
|
-
__name2(trailingEdge, "trailingEdge");
|
|
207
|
-
function cancel() {
|
|
208
|
-
if (timerId !== void 0) {
|
|
209
|
-
clearTimeout(timerId);
|
|
210
|
-
}
|
|
211
|
-
lastInvokeTime = 0;
|
|
212
|
-
lastArgs = void 0;
|
|
213
|
-
lastCallTime = void 0;
|
|
214
|
-
timerId = void 0;
|
|
215
|
-
}
|
|
216
|
-
__name(cancel, "cancel");
|
|
217
|
-
__name2(cancel, "cancel");
|
|
218
|
-
function flush() {
|
|
219
|
-
return timerId === void 0 ? result : trailingEdge(Date.now());
|
|
220
|
-
}
|
|
221
|
-
__name(flush, "flush");
|
|
222
|
-
__name2(flush, "flush");
|
|
223
|
-
function debounced(...args) {
|
|
224
|
-
const time = Date.now();
|
|
225
|
-
const isInvoking = shouldInvoke(time);
|
|
226
|
-
lastArgs = args;
|
|
227
|
-
lastCallTime = time;
|
|
228
|
-
if (isInvoking) {
|
|
229
|
-
if (timerId === void 0) {
|
|
230
|
-
return leadingEdge(lastCallTime);
|
|
231
|
-
}
|
|
232
|
-
if (maxWait !== null) {
|
|
233
|
-
timerId = setTimeout(timerExpired, wait);
|
|
234
|
-
return invokeFunc(lastCallTime);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (timerId === void 0) {
|
|
238
|
-
timerId = setTimeout(timerExpired, wait);
|
|
239
|
-
}
|
|
240
|
-
return result;
|
|
241
|
-
}
|
|
242
|
-
__name(debounced, "debounced");
|
|
243
|
-
__name2(debounced, "debounced");
|
|
244
|
-
debounced.cancel = cancel;
|
|
245
|
-
debounced.flush = flush;
|
|
246
|
-
return debounced;
|
|
247
|
-
}
|
|
248
|
-
__name(debounce, "debounce");
|
|
249
|
-
__name2(debounce, "debounce");
|
|
250
|
-
var primitiveTypes = ["string", "bigint", "number", "boolean"];
|
|
251
|
-
function isPrimitive(input) {
|
|
252
|
-
return primitiveTypes.includes(typeof input);
|
|
253
|
-
}
|
|
254
|
-
__name(isPrimitive, "isPrimitive");
|
|
255
|
-
__name2(isPrimitive, "isPrimitive");
|
|
256
|
-
function deepClone(source) {
|
|
257
|
-
if (source === null || isPrimitive(source)) {
|
|
258
|
-
return source;
|
|
259
|
-
}
|
|
260
|
-
if (source instanceof Date) {
|
|
261
|
-
const output = new source.constructor(source);
|
|
262
|
-
return output;
|
|
263
|
-
}
|
|
264
|
-
if (Array.isArray(source)) {
|
|
265
|
-
const output = new source.constructor(source.length);
|
|
266
|
-
for (let i = 0; i < source.length; i++) {
|
|
267
|
-
output[i] = deepClone(source[i]);
|
|
268
|
-
}
|
|
269
|
-
return output;
|
|
270
|
-
}
|
|
271
|
-
if (source instanceof Map) {
|
|
272
|
-
const output = new source.constructor();
|
|
273
|
-
for (const [key, value] of source.entries()) {
|
|
274
|
-
output.set(key, deepClone(value));
|
|
275
|
-
}
|
|
276
|
-
return output;
|
|
277
|
-
}
|
|
278
|
-
if (source instanceof Set) {
|
|
279
|
-
const output = new source.constructor();
|
|
280
|
-
for (const value of source.values()) {
|
|
281
|
-
output.add(deepClone(value));
|
|
282
|
-
}
|
|
283
|
-
return output;
|
|
284
|
-
}
|
|
285
|
-
if (typeof source === "object") {
|
|
286
|
-
const output = new source.constructor();
|
|
287
|
-
for (const [key, value] of Object.entries(source)) {
|
|
288
|
-
Object.defineProperty(output, key, {
|
|
289
|
-
configurable: true,
|
|
290
|
-
enumerable: true,
|
|
291
|
-
value: deepClone(value),
|
|
292
|
-
writable: true
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
return output;
|
|
296
|
-
}
|
|
297
|
-
return source;
|
|
298
|
-
}
|
|
299
|
-
__name(deepClone, "deepClone");
|
|
300
|
-
__name2(deepClone, "deepClone");
|
|
301
|
-
function isNullOrUndefined(value) {
|
|
302
|
-
return value === void 0 || value === null;
|
|
303
|
-
}
|
|
304
|
-
__name(isNullOrUndefined, "isNullOrUndefined");
|
|
305
|
-
__name2(isNullOrUndefined, "isNullOrUndefined");
|
|
306
|
-
function filterNullAndUndefined(value) {
|
|
307
|
-
return !isNullOrUndefined(value);
|
|
308
|
-
}
|
|
309
|
-
__name(filterNullAndUndefined, "filterNullAndUndefined");
|
|
310
|
-
__name2(filterNullAndUndefined, "filterNullAndUndefined");
|
|
311
|
-
function isNullOrUndefinedOrEmpty(value) {
|
|
312
|
-
return isNullOrUndefined(value) || value.length === 0;
|
|
313
|
-
}
|
|
314
|
-
__name(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
|
|
315
|
-
__name2(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
|
|
316
|
-
function filterNullAndUndefinedAndEmpty(value) {
|
|
317
|
-
return !isNullOrUndefinedOrEmpty(value);
|
|
318
|
-
}
|
|
319
|
-
__name(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
|
|
320
|
-
__name2(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
|
|
321
|
-
function isNullOrUndefinedOrZero(value) {
|
|
322
|
-
return value === 0 || isNullOrUndefined(value);
|
|
323
|
-
}
|
|
324
|
-
__name(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
|
|
325
|
-
__name2(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
|
|
326
|
-
function filterNullAndUndefinedAndZero(value) {
|
|
327
|
-
return !isNullOrUndefinedOrZero(value);
|
|
328
|
-
}
|
|
329
|
-
__name(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
|
|
330
|
-
__name2(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
|
|
331
|
-
function isObject(input, constructorType) {
|
|
332
|
-
return typeof input === "object" && input ? input.constructor === (constructorType != null ? constructorType : Object) : false;
|
|
333
|
-
}
|
|
334
|
-
__name(isObject, "isObject");
|
|
335
|
-
__name2(isObject, "isObject");
|
|
336
|
-
function getDeepObjectKeys(obj, { arrayKeysIndexStyle = "dotted" } = { arrayKeysIndexStyle: "dotted" }) {
|
|
337
|
-
const keys = [];
|
|
338
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
339
|
-
if (Array.isArray(value)) {
|
|
340
|
-
for (const [index, innerValue] of value.entries()) {
|
|
341
|
-
const arraySubKeys = getDeepObjectKeys(innerValue);
|
|
342
|
-
keys.push(...arraySubKeys.map((arraySubKey) => {
|
|
343
|
-
switch (arrayKeysIndexStyle) {
|
|
344
|
-
case "braces-with-dot":
|
|
345
|
-
return `${key}[${index}].${arraySubKey}`;
|
|
346
|
-
case "braces":
|
|
347
|
-
return `${key}[${index}]${arraySubKey}`;
|
|
348
|
-
case "dotted":
|
|
349
|
-
default:
|
|
350
|
-
return `${key}.${index}.${arraySubKey}`;
|
|
351
|
-
}
|
|
352
|
-
}));
|
|
353
|
-
}
|
|
354
|
-
} else if (isObject(value)) {
|
|
355
|
-
const objectSubKeys = getDeepObjectKeys(value);
|
|
356
|
-
keys.push(...objectSubKeys.map((subKey) => `${key}.${subKey}`));
|
|
357
|
-
} else {
|
|
358
|
-
keys.push(key);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return keys;
|
|
362
|
-
}
|
|
363
|
-
__name(getDeepObjectKeys, "getDeepObjectKeys");
|
|
364
|
-
__name2(getDeepObjectKeys, "getDeepObjectKeys");
|
|
365
|
-
function hasAtLeastOneKeyInMap(map, keys) {
|
|
366
|
-
return keys.some((key) => map.has(key));
|
|
367
|
-
}
|
|
368
|
-
__name(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
|
|
369
|
-
__name2(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
|
|
370
|
-
var zws2 = String.fromCharCode(8203);
|
|
371
|
-
function inlineCodeBlock(input) {
|
|
372
|
-
return `\`${input.replace(/ /g, "\xA0").replace(/`/g, `\`${zws2}`)}\``;
|
|
373
|
-
}
|
|
374
|
-
__name(inlineCodeBlock, "inlineCodeBlock");
|
|
375
|
-
__name2(inlineCodeBlock, "inlineCodeBlock");
|
|
376
|
-
function isClass(input) {
|
|
377
|
-
return typeof input === "function" && typeof input.prototype === "object";
|
|
378
|
-
}
|
|
379
|
-
__name(isClass, "isClass");
|
|
380
|
-
__name2(isClass, "isClass");
|
|
381
|
-
function isFunction(input) {
|
|
382
|
-
return typeof input === "function";
|
|
383
|
-
}
|
|
384
|
-
__name(isFunction, "isFunction");
|
|
385
|
-
__name2(isFunction, "isFunction");
|
|
386
|
-
function isNumber(input) {
|
|
387
|
-
return typeof input === "number" && !isNaN(input) && Number.isFinite(input);
|
|
388
|
-
}
|
|
389
|
-
__name(isNumber, "isNumber");
|
|
390
|
-
__name2(isNumber, "isNumber");
|
|
391
|
-
function hasThen(input) {
|
|
392
|
-
return Reflect.has(input, "then") && isFunction(input.then);
|
|
393
|
-
}
|
|
394
|
-
__name(hasThen, "hasThen");
|
|
395
|
-
__name2(hasThen, "hasThen");
|
|
396
|
-
function hasCatch(input) {
|
|
397
|
-
return Reflect.has(input, "catch") && isFunction(input.catch);
|
|
398
|
-
}
|
|
399
|
-
__name(hasCatch, "hasCatch");
|
|
400
|
-
__name2(hasCatch, "hasCatch");
|
|
401
|
-
function isThenable(input) {
|
|
402
|
-
if (typeof input !== "object" || input === null)
|
|
403
|
-
return false;
|
|
404
|
-
return input instanceof Promise || input !== Promise.prototype && hasThen(input) && hasCatch(input);
|
|
405
|
-
}
|
|
406
|
-
__name(isThenable, "isThenable");
|
|
407
|
-
__name2(isThenable, "isThenable");
|
|
408
|
-
function lazy(cb) {
|
|
409
|
-
let defaultValue;
|
|
410
|
-
return () => defaultValue != null ? defaultValue : defaultValue = cb();
|
|
411
|
-
}
|
|
412
|
-
__name(lazy, "lazy");
|
|
413
|
-
__name2(lazy, "lazy");
|
|
414
|
-
function makeObject(path, value, obj = {}) {
|
|
415
|
-
if (path.includes(".")) {
|
|
416
|
-
const route = path.split(".");
|
|
417
|
-
const lastKey = route.pop();
|
|
418
|
-
let reference = obj;
|
|
419
|
-
for (const key of route) {
|
|
420
|
-
if (!reference[key])
|
|
421
|
-
reference[key] = {};
|
|
422
|
-
reference = reference[key];
|
|
423
|
-
}
|
|
424
|
-
reference[lastKey] = value;
|
|
425
|
-
} else {
|
|
426
|
-
obj[path] = value;
|
|
427
|
-
}
|
|
428
|
-
return obj;
|
|
429
|
-
}
|
|
430
|
-
__name(makeObject, "makeObject");
|
|
431
|
-
__name2(makeObject, "makeObject");
|
|
432
|
-
function mergeDefault(base, overwrites) {
|
|
433
|
-
if (!overwrites)
|
|
434
|
-
return deepClone(base);
|
|
435
|
-
for (const [baseKey, baseValue] of Object.entries(base)) {
|
|
436
|
-
const overwritesValueAtBaseKey = Reflect.get(overwrites, baseKey);
|
|
437
|
-
if (typeof overwritesValueAtBaseKey === "undefined") {
|
|
438
|
-
Reflect.set(overwrites, baseKey, deepClone(baseValue));
|
|
439
|
-
} else if (isObject(overwritesValueAtBaseKey)) {
|
|
440
|
-
Reflect.set(overwrites, baseKey, mergeDefault(baseValue != null ? baseValue : {}, overwritesValueAtBaseKey));
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
return overwrites;
|
|
444
|
-
}
|
|
445
|
-
__name(mergeDefault, "mergeDefault");
|
|
446
|
-
__name2(mergeDefault, "mergeDefault");
|
|
447
|
-
function mergeObjects(objTarget, objSource) {
|
|
448
|
-
for (const [key, value] of Object.entries(objSource)) {
|
|
449
|
-
const targetValue = Reflect.get(objTarget, key);
|
|
450
|
-
if (isObject(value)) {
|
|
451
|
-
Reflect.set(objTarget, key, isObject(targetValue) ? mergeObjects(targetValue, value) : value);
|
|
452
|
-
} else if (!isObject(targetValue)) {
|
|
453
|
-
Reflect.set(objTarget, key, value);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
return objTarget;
|
|
457
|
-
}
|
|
458
|
-
__name(mergeObjects, "mergeObjects");
|
|
459
|
-
__name2(mergeObjects, "mergeObjects");
|
|
460
|
-
function noop() {
|
|
461
|
-
}
|
|
462
|
-
__name(noop, "noop");
|
|
463
|
-
__name2(noop, "noop");
|
|
464
|
-
function objectToTuples(obj, prefix = "") {
|
|
465
|
-
const entries = [];
|
|
466
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
467
|
-
if (isObject(value)) {
|
|
468
|
-
entries.push(...objectToTuples(value, `${prefix}${key}.`));
|
|
469
|
-
} else {
|
|
470
|
-
entries.push([`${prefix}${key}`, value]);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return entries;
|
|
474
|
-
}
|
|
475
|
-
__name(objectToTuples, "objectToTuples");
|
|
476
|
-
__name2(objectToTuples, "objectToTuples");
|
|
477
|
-
function parseURL(url) {
|
|
478
|
-
try {
|
|
479
|
-
return new URL(url);
|
|
480
|
-
} catch {
|
|
481
|
-
return null;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
__name(parseURL, "parseURL");
|
|
485
|
-
__name2(parseURL, "parseURL");
|
|
486
|
-
function partition(array, predicate) {
|
|
487
|
-
if (!Array.isArray(array))
|
|
488
|
-
throw new TypeError("entries must be an array.");
|
|
489
|
-
if (!isFunction(predicate))
|
|
490
|
-
throw new TypeError("predicate must be an function that returns a boolean value.");
|
|
491
|
-
const partitionOne = [];
|
|
492
|
-
const partitionTwo = [];
|
|
493
|
-
for (let i = 0; i < array.length; i++) {
|
|
494
|
-
if (predicate(array[i], i)) {
|
|
495
|
-
partitionOne.push(array[i]);
|
|
496
|
-
} else {
|
|
497
|
-
partitionTwo.push(array[i]);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
return [partitionOne, partitionTwo];
|
|
501
|
-
}
|
|
502
|
-
__name(partition, "partition");
|
|
503
|
-
__name2(partition, "partition");
|
|
504
|
-
function range(min, max, step) {
|
|
505
|
-
return new Array(Math.floor((max - min) / step) + 1).fill(0).map((_val, i) => min + i * step);
|
|
506
|
-
}
|
|
507
|
-
__name(range, "range");
|
|
508
|
-
__name2(range, "range");
|
|
509
|
-
var REGEXPESC = /[-/\\^$*+?.()|[\]{}]/g;
|
|
510
|
-
function regExpEsc(str) {
|
|
511
|
-
return str.replace(REGEXPESC, "\\$&");
|
|
512
|
-
}
|
|
513
|
-
__name(regExpEsc, "regExpEsc");
|
|
514
|
-
__name2(regExpEsc, "regExpEsc");
|
|
515
|
-
function roundNumber(num, scale = 0) {
|
|
516
|
-
if (!num.toString().includes("e")) {
|
|
517
|
-
return Number(`${Math.round(Number(`${num}e+${scale}`))}e-${scale}`);
|
|
518
|
-
}
|
|
519
|
-
const arr = `${num}`.split("e");
|
|
520
|
-
let sig = "";
|
|
521
|
-
if (Number(arr[1]) + scale > 0) {
|
|
522
|
-
sig = "+";
|
|
523
|
-
}
|
|
524
|
-
return Number(`${Math.round(Number(`${Number(arr[0])}e${sig}${Number(arr[1]) + scale}`))}e-${scale}`);
|
|
525
|
-
}
|
|
526
|
-
__name(roundNumber, "roundNumber");
|
|
527
|
-
__name2(roundNumber, "roundNumber");
|
|
528
|
-
var TO_TITLE_CASE = /[A-Za-zÀ-ÖØ-öø-ÿ]\S*/g;
|
|
529
|
-
var baseVariants = {
|
|
530
|
-
textchannel: "TextChannel",
|
|
531
|
-
voicechannel: "VoiceChannel",
|
|
532
|
-
categorychannel: "CategoryChannel",
|
|
533
|
-
guildmember: "GuildMember"
|
|
534
|
-
};
|
|
535
|
-
function toTitleCase(str, options = {}) {
|
|
536
|
-
const { additionalVariants = {}, caseSensitive } = options;
|
|
537
|
-
const titleCaseVariants = {
|
|
538
|
-
...baseVariants,
|
|
539
|
-
...caseSensitive ? additionalVariants : Object.entries(additionalVariants).reduce((variants, [key, variant]) => ({ ...variants, [key.toLowerCase()]: variant }), {})
|
|
540
|
-
};
|
|
541
|
-
return str.replace(TO_TITLE_CASE, (txt) => {
|
|
542
|
-
var _a;
|
|
543
|
-
return (_a = titleCaseVariants[caseSensitive ? txt : txt.toLowerCase()]) != null ? _a : txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
__name(toTitleCase, "toTitleCase");
|
|
547
|
-
__name2(toTitleCase, "toTitleCase");
|
|
548
|
-
function tryParse(value) {
|
|
549
|
-
try {
|
|
550
|
-
return JSON.parse(value);
|
|
551
|
-
} catch (err) {
|
|
552
|
-
return value;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
__name(tryParse, "tryParse");
|
|
556
|
-
__name2(tryParse, "tryParse");
|
|
557
|
-
|
|
558
|
-
// ../time-utilities/dist/index.mjs
|
|
559
|
-
var __defProp3 = Object.defineProperty;
|
|
560
|
-
var __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
|
|
561
|
-
var __name3 = /* @__PURE__ */ __name((target, value) => __defProp3(target, "name", { value, configurable: true }), "__name");
|
|
562
78
|
var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => {
|
|
563
79
|
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
564
80
|
return value;
|
|
565
81
|
}, "__publicField");
|
|
566
|
-
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
567
|
-
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
568
|
-
var tokens = /* @__PURE__ */ new Map([
|
|
569
|
-
["Y", 4],
|
|
570
|
-
["Q", 1],
|
|
571
|
-
["M", 4],
|
|
572
|
-
["D", 4],
|
|
573
|
-
["d", 4],
|
|
574
|
-
["X", 1],
|
|
575
|
-
["x", 1],
|
|
576
|
-
["H", 2],
|
|
577
|
-
["h", 2],
|
|
578
|
-
["a", 1],
|
|
579
|
-
["A", 1],
|
|
580
|
-
["m", 2],
|
|
581
|
-
["s", 2],
|
|
582
|
-
["S", 3],
|
|
583
|
-
["Z", 2],
|
|
584
|
-
["l", 4],
|
|
585
|
-
["L", 4],
|
|
586
|
-
["T", 1],
|
|
587
|
-
["t", 1]
|
|
588
|
-
]);
|
|
589
|
-
var partRegex = /^(?:(\*)|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/;
|
|
590
|
-
var wildcardRegex = /\bh\b|\B\?\B/g;
|
|
591
|
-
var allowedNum = [
|
|
592
|
-
[0, 59],
|
|
593
|
-
[0, 23],
|
|
594
|
-
[1, 31],
|
|
595
|
-
[1, 12],
|
|
596
|
-
[0, 6]
|
|
597
|
-
];
|
|
598
|
-
var predefined = {
|
|
599
|
-
"@annually": "0 0 1 1 *",
|
|
600
|
-
"@yearly": "0 0 1 1 *",
|
|
601
|
-
"@monthly": "0 0 1 * *",
|
|
602
|
-
"@weekly": "0 0 * * 0",
|
|
603
|
-
"@daily": "0 0 * * *",
|
|
604
|
-
"@hourly": "0 * * * *"
|
|
605
|
-
};
|
|
606
|
-
var cronTokens = {
|
|
607
|
-
jan: 1,
|
|
608
|
-
feb: 2,
|
|
609
|
-
mar: 3,
|
|
610
|
-
apr: 4,
|
|
611
|
-
may: 5,
|
|
612
|
-
jun: 6,
|
|
613
|
-
jul: 7,
|
|
614
|
-
aug: 8,
|
|
615
|
-
sep: 9,
|
|
616
|
-
oct: 10,
|
|
617
|
-
nov: 11,
|
|
618
|
-
dec: 12,
|
|
619
|
-
sun: 0,
|
|
620
|
-
mon: 1,
|
|
621
|
-
tue: 2,
|
|
622
|
-
wed: 3,
|
|
623
|
-
thu: 4,
|
|
624
|
-
fri: 5,
|
|
625
|
-
sat: 6
|
|
626
|
-
};
|
|
627
|
-
var tokensRegex = new RegExp(Object.keys(cronTokens).join("|"), "g");
|
|
628
|
-
var DEFAULT_UNITS = {
|
|
629
|
-
["year"]: {
|
|
630
|
-
1: "year",
|
|
631
|
-
DEFAULT: "years"
|
|
632
|
-
},
|
|
633
|
-
["month"]: {
|
|
634
|
-
1: "month",
|
|
635
|
-
DEFAULT: "months"
|
|
636
|
-
},
|
|
637
|
-
["week"]: {
|
|
638
|
-
1: "week",
|
|
639
|
-
DEFAULT: "weeks"
|
|
640
|
-
},
|
|
641
|
-
["day"]: {
|
|
642
|
-
1: "day",
|
|
643
|
-
DEFAULT: "days"
|
|
644
|
-
},
|
|
645
|
-
["hour"]: {
|
|
646
|
-
1: "hour",
|
|
647
|
-
DEFAULT: "hours"
|
|
648
|
-
},
|
|
649
|
-
["minute"]: {
|
|
650
|
-
1: "minute",
|
|
651
|
-
DEFAULT: "minutes"
|
|
652
|
-
},
|
|
653
|
-
["second"]: {
|
|
654
|
-
1: "second",
|
|
655
|
-
DEFAULT: "seconds"
|
|
656
|
-
}
|
|
657
|
-
};
|
|
658
|
-
var DEFAULT_SEPARATORS = {
|
|
659
|
-
left: " ",
|
|
660
|
-
right: " "
|
|
661
|
-
};
|
|
662
|
-
var Cron = /* @__PURE__ */ __name(class {
|
|
663
|
-
constructor(cron) {
|
|
664
|
-
__publicField2(this, "cron");
|
|
665
|
-
__publicField2(this, "normalized");
|
|
666
|
-
__publicField2(this, "minutes");
|
|
667
|
-
__publicField2(this, "hours");
|
|
668
|
-
__publicField2(this, "days");
|
|
669
|
-
__publicField2(this, "months");
|
|
670
|
-
__publicField2(this, "dows");
|
|
671
|
-
this.cron = cron.toLowerCase();
|
|
672
|
-
this.normalized = Cron.normalize(this.cron);
|
|
673
|
-
[this.minutes, this.hours, this.days, this.months, this.dows] = Cron.parseString(this.normalized);
|
|
674
|
-
}
|
|
675
|
-
next(outset = new Date(), origin = true) {
|
|
676
|
-
if (!this.days.includes(outset.getUTCDate()) || !this.months.includes(outset.getUTCMonth() + 1) || !this.dows.includes(outset.getUTCDay())) {
|
|
677
|
-
return this.next(new Date(outset.getTime() + 864e5), false);
|
|
678
|
-
}
|
|
679
|
-
if (!origin)
|
|
680
|
-
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), this.hours[0], this.minutes[0]));
|
|
681
|
-
const now = new Date(outset.getTime() + 6e4);
|
|
682
|
-
for (const hour of this.hours) {
|
|
683
|
-
if (hour < now.getUTCHours())
|
|
684
|
-
continue;
|
|
685
|
-
for (const minute of this.minutes) {
|
|
686
|
-
if (hour === now.getUTCHours() && minute < now.getUTCMinutes())
|
|
687
|
-
continue;
|
|
688
|
-
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), hour, minute));
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
return this.next(new Date(outset.getTime() + 864e5), false);
|
|
692
|
-
}
|
|
693
|
-
static normalize(cron) {
|
|
694
|
-
if (Reflect.has(predefined, cron))
|
|
695
|
-
return Reflect.get(predefined, cron);
|
|
696
|
-
const now = new Date();
|
|
697
|
-
cron = cron.split(" ").map((val, i) => val.replace(wildcardRegex, (match) => {
|
|
698
|
-
if (match === "h")
|
|
699
|
-
return (Math.floor(Math.random() * allowedNum[i][1]) + allowedNum[i][0]).toString();
|
|
700
|
-
if (match === "?") {
|
|
701
|
-
switch (i) {
|
|
702
|
-
case 0:
|
|
703
|
-
return now.getUTCMinutes().toString();
|
|
704
|
-
case 1:
|
|
705
|
-
return now.getUTCHours().toString();
|
|
706
|
-
case 2:
|
|
707
|
-
return now.getUTCDate().toString();
|
|
708
|
-
case 3:
|
|
709
|
-
return now.getUTCMonth().toString();
|
|
710
|
-
case 4:
|
|
711
|
-
return now.getUTCDay().toString();
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
return match;
|
|
715
|
-
})).join(" ");
|
|
716
|
-
return cron.replace(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));
|
|
717
|
-
}
|
|
718
|
-
static parseString(cron) {
|
|
719
|
-
const parts = cron.split(" ");
|
|
720
|
-
if (parts.length !== 5)
|
|
721
|
-
throw new Error("Invalid Cron Provided");
|
|
722
|
-
return parts.map((part, i) => Cron.parsePart(part, i));
|
|
723
|
-
}
|
|
724
|
-
static parsePart(cronPart, id) {
|
|
725
|
-
if (cronPart.includes(",")) {
|
|
726
|
-
const res = [];
|
|
727
|
-
for (const part of cronPart.split(","))
|
|
728
|
-
res.push(...Cron.parsePart(part, id));
|
|
729
|
-
return [...new Set(res)].sort((a, b) => a - b);
|
|
730
|
-
}
|
|
731
|
-
const [, wild, minStr, maxStr, step] = partRegex.exec(cronPart);
|
|
732
|
-
let [min, max] = [parseInt(minStr, 10), parseInt(maxStr, 10)];
|
|
733
|
-
if (wild)
|
|
734
|
-
[min, max] = allowedNum[id];
|
|
735
|
-
else if (!max && !step)
|
|
736
|
-
return [min];
|
|
737
|
-
[min, max] = [min, max || allowedNum[id][1]].sort((a, b) => a - b);
|
|
738
|
-
return range(min, max, parseInt(step, 10) || 1);
|
|
739
|
-
}
|
|
740
|
-
}, "Cron");
|
|
741
|
-
__name3(Cron, "Cron");
|
|
742
|
-
var tokens2 = /* @__PURE__ */ new Map([
|
|
743
|
-
["nanosecond", 1 / 1e6],
|
|
744
|
-
["nanoseconds", 1 / 1e6],
|
|
745
|
-
["ns", 1 / 1e6],
|
|
746
|
-
["millisecond", 1],
|
|
747
|
-
["milliseconds", 1],
|
|
748
|
-
["ms", 1],
|
|
749
|
-
["second", 1e3],
|
|
750
|
-
["seconds", 1e3],
|
|
751
|
-
["sec", 1e3],
|
|
752
|
-
["secs", 1e3],
|
|
753
|
-
["s", 1e3],
|
|
754
|
-
["minute", 1e3 * 60],
|
|
755
|
-
["minutes", 1e3 * 60],
|
|
756
|
-
["min", 1e3 * 60],
|
|
757
|
-
["mins", 1e3 * 60],
|
|
758
|
-
["m", 1e3 * 60],
|
|
759
|
-
["hour", 1e3 * 60 * 60],
|
|
760
|
-
["hours", 1e3 * 60 * 60],
|
|
761
|
-
["hr", 1e3 * 60 * 60],
|
|
762
|
-
["hrs", 1e3 * 60 * 60],
|
|
763
|
-
["h", 1e3 * 60 * 60],
|
|
764
|
-
["day", 1e3 * 60 * 60 * 24],
|
|
765
|
-
["days", 1e3 * 60 * 60 * 24],
|
|
766
|
-
["d", 1e3 * 60 * 60 * 24],
|
|
767
|
-
["week", 1e3 * 60 * 60 * 24 * 7],
|
|
768
|
-
["weeks", 1e3 * 60 * 60 * 24 * 7],
|
|
769
|
-
["wk", 1e3 * 60 * 60 * 24 * 7],
|
|
770
|
-
["wks", 1e3 * 60 * 60 * 24 * 7],
|
|
771
|
-
["w", 1e3 * 60 * 60 * 24 * 7],
|
|
772
|
-
["month", 1e3 * 60 * 60 * 24 * (365.25 / 12)],
|
|
773
|
-
["months", 1e3 * 60 * 60 * 24 * (365.25 / 12)],
|
|
774
|
-
["b", 1e3 * 60 * 60 * 24 * (365.25 / 12)],
|
|
775
|
-
["mo", 1e3 * 60 * 60 * 24 * (365.25 / 12)],
|
|
776
|
-
["year", 1e3 * 60 * 60 * 24 * 365.25],
|
|
777
|
-
["years", 1e3 * 60 * 60 * 24 * 365.25],
|
|
778
|
-
["yr", 1e3 * 60 * 60 * 24 * 365.25],
|
|
779
|
-
["yrs", 1e3 * 60 * 60 * 24 * 365.25],
|
|
780
|
-
["y", 1e3 * 60 * 60 * 24 * 365.25]
|
|
781
|
-
]);
|
|
782
|
-
var _Duration = /* @__PURE__ */ __name(class {
|
|
783
|
-
constructor(pattern) {
|
|
784
|
-
__publicField2(this, "offset");
|
|
785
|
-
this.offset = _Duration.parse(pattern.toLowerCase());
|
|
786
|
-
}
|
|
787
|
-
get fromNow() {
|
|
788
|
-
return this.dateFrom(new Date());
|
|
789
|
-
}
|
|
790
|
-
dateFrom(date) {
|
|
791
|
-
return new Date(date.getTime() + this.offset);
|
|
792
|
-
}
|
|
793
|
-
static parse(pattern) {
|
|
794
|
-
let result = 0;
|
|
795
|
-
let valid = false;
|
|
796
|
-
pattern.replace(_Duration.kCommaRegex, "").replace(_Duration.kAanRegex, "1").replace(_Duration.kPatternRegex, (_, i, units) => {
|
|
797
|
-
const token = tokens2.get(units);
|
|
798
|
-
if (token !== void 0) {
|
|
799
|
-
result += Number(i) * token;
|
|
800
|
-
valid = true;
|
|
801
|
-
}
|
|
802
|
-
return "";
|
|
803
|
-
});
|
|
804
|
-
return valid ? result : NaN;
|
|
805
|
-
}
|
|
806
|
-
}, "_Duration");
|
|
807
|
-
var Duration = _Duration;
|
|
808
|
-
__name3(Duration, "Duration");
|
|
809
|
-
__publicField2(Duration, "kPatternRegex", /(-?\d*\.?\d+(?:e[-+]?\d+)?)\s*([a-zμ]*)/gi);
|
|
810
|
-
__publicField2(Duration, "kCommaRegex", /,/g);
|
|
811
|
-
__publicField2(Duration, "kAanRegex", /\ban?\b/gi);
|
|
812
|
-
var kTimeDurations = [
|
|
813
|
-
["year", 31536e6],
|
|
814
|
-
["month", 2628e6],
|
|
815
|
-
["week", 1e3 * 60 * 60 * 24 * 7],
|
|
816
|
-
["day", 1e3 * 60 * 60 * 24],
|
|
817
|
-
["hour", 1e3 * 60 * 60],
|
|
818
|
-
["minute", 1e3 * 60],
|
|
819
|
-
["second", 1e3]
|
|
820
|
-
];
|
|
821
|
-
var DurationFormatter = /* @__PURE__ */ __name(class {
|
|
822
|
-
constructor(units = DEFAULT_UNITS) {
|
|
823
|
-
this.units = units;
|
|
824
|
-
}
|
|
825
|
-
format(duration, precision = 7, {
|
|
826
|
-
left: leftSeparator = DEFAULT_SEPARATORS.left,
|
|
827
|
-
right: rightSeparator = DEFAULT_SEPARATORS.right
|
|
828
|
-
} = DEFAULT_SEPARATORS) {
|
|
829
|
-
const output = [];
|
|
830
|
-
const negative = duration < 0;
|
|
831
|
-
if (negative)
|
|
832
|
-
duration *= -1;
|
|
833
|
-
for (const [type, timeDuration] of kTimeDurations) {
|
|
834
|
-
const substraction = duration / timeDuration;
|
|
835
|
-
if (substraction < 1)
|
|
836
|
-
continue;
|
|
837
|
-
const floored = Math.floor(substraction);
|
|
838
|
-
duration -= floored * timeDuration;
|
|
839
|
-
output.push(addUnit(floored, this.units[type], leftSeparator));
|
|
840
|
-
if (output.length >= precision)
|
|
841
|
-
break;
|
|
842
|
-
}
|
|
843
|
-
return `${negative ? "-" : ""}${output.join(rightSeparator) || addUnit(0, this.units.second, leftSeparator)}`;
|
|
844
|
-
}
|
|
845
|
-
}, "DurationFormatter");
|
|
846
|
-
__name3(DurationFormatter, "DurationFormatter");
|
|
847
|
-
function addUnit(time, unit, separator) {
|
|
848
|
-
if (Reflect.has(unit, time))
|
|
849
|
-
return `${time}${separator}${Reflect.get(unit, time)}`;
|
|
850
|
-
return `${time}${separator}${unit.DEFAULT}`;
|
|
851
|
-
}
|
|
852
|
-
__name(addUnit, "addUnit");
|
|
853
|
-
__name3(addUnit, "addUnit");
|
|
854
82
|
var TimerManager = /* @__PURE__ */ __name(class extends null {
|
|
855
83
|
static setTimeout(fn, delay, ...args) {
|
|
856
84
|
const timeout = setTimeout(() => {
|
|
@@ -882,166 +110,9 @@ ${expression || zws}\`\`\``;
|
|
|
882
110
|
this.storedIntervals.clear();
|
|
883
111
|
}
|
|
884
112
|
}, "TimerManager");
|
|
885
|
-
|
|
113
|
+
__name2(TimerManager, "TimerManager");
|
|
886
114
|
__publicField2(TimerManager, "storedTimeouts", /* @__PURE__ */ new Set());
|
|
887
115
|
__publicField2(TimerManager, "storedIntervals", /* @__PURE__ */ new Set());
|
|
888
|
-
var tokenResolvers = /* @__PURE__ */ new Map([
|
|
889
|
-
["Y", (time) => String(time.getFullYear()).slice(2)],
|
|
890
|
-
["YY", (time) => String(time.getFullYear()).slice(2)],
|
|
891
|
-
["YYY", (time) => String(time.getFullYear())],
|
|
892
|
-
["YYYY", (time) => String(time.getFullYear())],
|
|
893
|
-
["Q", (time) => String((time.getMonth() + 1) / 3)],
|
|
894
|
-
["M", (time) => String(time.getMonth() + 1)],
|
|
895
|
-
["MM", (time) => String(time.getMonth() + 1).padStart(2, "0")],
|
|
896
|
-
["MMM", (time) => months[time.getMonth()]],
|
|
897
|
-
["MMMM", (time) => months[time.getMonth()]],
|
|
898
|
-
["D", (time) => String(time.getDate())],
|
|
899
|
-
["DD", (time) => String(time.getDate()).padStart(2, "0")],
|
|
900
|
-
["DDD", (time) => String(Math.floor((time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5))],
|
|
901
|
-
["DDDD", (time) => String(Math.floor((time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5))],
|
|
902
|
-
[
|
|
903
|
-
"d",
|
|
904
|
-
(time) => {
|
|
905
|
-
const day = String(time.getDate());
|
|
906
|
-
if (day !== "11" && day.endsWith("1"))
|
|
907
|
-
return `${day}st`;
|
|
908
|
-
if (day !== "12" && day.endsWith("2"))
|
|
909
|
-
return `${day}nd`;
|
|
910
|
-
if (day !== "13" && day.endsWith("3"))
|
|
911
|
-
return `${day}rd`;
|
|
912
|
-
return `${day}th`;
|
|
913
|
-
}
|
|
914
|
-
],
|
|
915
|
-
["dd", (time) => days[time.getDay()].slice(0, 2)],
|
|
916
|
-
["ddd", (time) => days[time.getDay()].slice(0, 3)],
|
|
917
|
-
["dddd", (time) => days[time.getDay()]],
|
|
918
|
-
["X", (time) => String(time.valueOf() / 1e3)],
|
|
919
|
-
["x", (time) => String(time.valueOf())],
|
|
920
|
-
["H", (time) => String(time.getHours())],
|
|
921
|
-
["HH", (time) => String(time.getHours()).padStart(2, "0")],
|
|
922
|
-
["h", (time) => String(time.getHours() % 12 || 12)],
|
|
923
|
-
["hh", (time) => String(time.getHours() % 12 || 12).padStart(2, "0")],
|
|
924
|
-
["a", (time) => time.getHours() < 12 ? "am" : "pm"],
|
|
925
|
-
["A", (time) => time.getHours() < 12 ? "AM" : "PM"],
|
|
926
|
-
["m", (time) => String(time.getMinutes())],
|
|
927
|
-
["mm", (time) => String(time.getMinutes()).padStart(2, "0")],
|
|
928
|
-
["s", (time) => String(time.getSeconds())],
|
|
929
|
-
["ss", (time) => String(time.getSeconds()).padStart(2, "0")],
|
|
930
|
-
["S", (time) => String(time.getMilliseconds())],
|
|
931
|
-
["SS", (time) => String(time.getMilliseconds()).padStart(2, "0")],
|
|
932
|
-
["SSS", (time) => String(time.getMilliseconds()).padStart(3, "0")],
|
|
933
|
-
["T", (time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`],
|
|
934
|
-
[
|
|
935
|
-
"t",
|
|
936
|
-
(time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")}:${String(time.getSeconds()).padStart(2, "0")} ${time.getHours() < 12 ? "am" : "pm"}`
|
|
937
|
-
],
|
|
938
|
-
["L", (time) => `${String(time.getMonth() + 1).padStart(2, "0")}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
|
|
939
|
-
["l", (time) => `${String(time.getMonth() + 1)}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
|
|
940
|
-
["LL", (time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
|
|
941
|
-
["ll", (time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
|
|
942
|
-
[
|
|
943
|
-
"LLL",
|
|
944
|
-
(time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
945
|
-
],
|
|
946
|
-
[
|
|
947
|
-
"lll",
|
|
948
|
-
(time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
949
|
-
],
|
|
950
|
-
[
|
|
951
|
-
"LLLL",
|
|
952
|
-
(time) => `${days[time.getDay()]}, ${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
953
|
-
],
|
|
954
|
-
[
|
|
955
|
-
"llll",
|
|
956
|
-
(time) => `${days[time.getDay()].slice(0, 3)} ${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
957
|
-
],
|
|
958
|
-
[
|
|
959
|
-
"Z",
|
|
960
|
-
(time) => {
|
|
961
|
-
const offset = time.getTimezoneOffset();
|
|
962
|
-
const unsigned = offset >= 0;
|
|
963
|
-
const absolute = Math.abs(offset);
|
|
964
|
-
return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
|
|
965
|
-
}
|
|
966
|
-
],
|
|
967
|
-
[
|
|
968
|
-
"ZZ",
|
|
969
|
-
(time) => {
|
|
970
|
-
const offset = time.getTimezoneOffset();
|
|
971
|
-
const unsigned = offset >= 0;
|
|
972
|
-
const absolute = Math.abs(offset);
|
|
973
|
-
return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
|
|
974
|
-
}
|
|
975
|
-
]
|
|
976
|
-
]);
|
|
977
|
-
var Timestamp = /* @__PURE__ */ __name(class {
|
|
978
|
-
constructor(pattern) {
|
|
979
|
-
__publicField2(this, "pattern");
|
|
980
|
-
__publicField2(this, "template");
|
|
981
|
-
this.pattern = pattern;
|
|
982
|
-
this.template = Timestamp.parse(pattern);
|
|
983
|
-
}
|
|
984
|
-
display(time = new Date()) {
|
|
985
|
-
return Timestamp.display(this.template, time);
|
|
986
|
-
}
|
|
987
|
-
displayUTC(time) {
|
|
988
|
-
return Timestamp.display(this.template, Timestamp.utc(time));
|
|
989
|
-
}
|
|
990
|
-
edit(pattern) {
|
|
991
|
-
this.pattern = pattern;
|
|
992
|
-
this.template = Timestamp.parse(pattern);
|
|
993
|
-
return this;
|
|
994
|
-
}
|
|
995
|
-
toString() {
|
|
996
|
-
return this.display();
|
|
997
|
-
}
|
|
998
|
-
static displayArbitrary(pattern, time = new Date()) {
|
|
999
|
-
return Timestamp.display(Timestamp.parse(pattern), time);
|
|
1000
|
-
}
|
|
1001
|
-
static displayUTCArbitrary(pattern, time = new Date()) {
|
|
1002
|
-
return Timestamp.display(Timestamp.parse(pattern), Timestamp.utc(time));
|
|
1003
|
-
}
|
|
1004
|
-
static utc(time = new Date()) {
|
|
1005
|
-
time = Timestamp.resolveDate(time);
|
|
1006
|
-
return new Date(time.valueOf() + time.getTimezoneOffset() * 6e4);
|
|
1007
|
-
}
|
|
1008
|
-
static display(template, time) {
|
|
1009
|
-
let output = "";
|
|
1010
|
-
const parsedTime = Timestamp.resolveDate(time);
|
|
1011
|
-
for (const { content, type } of template)
|
|
1012
|
-
output += content || tokenResolvers.get(type)(parsedTime);
|
|
1013
|
-
return output;
|
|
1014
|
-
}
|
|
1015
|
-
static parse(pattern) {
|
|
1016
|
-
const template = [];
|
|
1017
|
-
for (let i = 0; i < pattern.length; i++) {
|
|
1018
|
-
let current = "";
|
|
1019
|
-
const currentChar = pattern[i];
|
|
1020
|
-
const tokenMax = tokens.get(currentChar);
|
|
1021
|
-
if (typeof tokenMax === "number") {
|
|
1022
|
-
current += currentChar;
|
|
1023
|
-
while (pattern[i + 1] === currentChar && current.length < tokenMax)
|
|
1024
|
-
current += pattern[++i];
|
|
1025
|
-
template.push({ type: current, content: null });
|
|
1026
|
-
} else if (currentChar === "[") {
|
|
1027
|
-
while (i + 1 < pattern.length && pattern[i + 1] !== "]")
|
|
1028
|
-
current += pattern[++i];
|
|
1029
|
-
i++;
|
|
1030
|
-
template.push({ type: "literal", content: current || "[" });
|
|
1031
|
-
} else {
|
|
1032
|
-
current += currentChar;
|
|
1033
|
-
while (i + 1 < pattern.length && !tokens.has(pattern[i + 1]) && pattern[i + 1] !== "[")
|
|
1034
|
-
current += pattern[++i];
|
|
1035
|
-
template.push({ type: "literal", content: current });
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
return template;
|
|
1039
|
-
}
|
|
1040
|
-
static resolveDate(time) {
|
|
1041
|
-
return time instanceof Date ? time : new Date(time);
|
|
1042
|
-
}
|
|
1043
|
-
}, "Timestamp");
|
|
1044
|
-
__name3(Timestamp, "Timestamp");
|
|
1045
116
|
|
|
1046
117
|
// src/lib/RateLimitManager.ts
|
|
1047
118
|
var _RateLimitManager = class extends Map {
|
|
@@ -1081,19 +152,4 @@ ${expression || zws}\`\`\``;
|
|
|
1081
152
|
__publicField(RateLimitManager, "sweepIntervalDuration", 3e4);
|
|
1082
153
|
return __toCommonJS(src_exports);
|
|
1083
154
|
})();
|
|
1084
|
-
/**
|
|
1085
|
-
* Split a string by its latest space character in a range from the character 0 to the selected one.
|
|
1086
|
-
* @param str The text to split.
|
|
1087
|
-
* @param length The length of the desired string.
|
|
1088
|
-
* @param char The character to split with
|
|
1089
|
-
* @copyright 2019 Antonio Román
|
|
1090
|
-
* @license Apache-2.0
|
|
1091
|
-
*/
|
|
1092
|
-
/**
|
|
1093
|
-
* Split a text by its latest space character in a range from the character 0 to the selected one.
|
|
1094
|
-
* @param str The text to split.
|
|
1095
|
-
* @param length The length of the desired string.
|
|
1096
|
-
* @copyright 2019 Antonio Román
|
|
1097
|
-
* @license Apache-2.0
|
|
1098
|
-
*/
|
|
1099
155
|
//# sourceMappingURL=index.global.js.map
|