qznt 1.0.33 → 1.0.35
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/dist/index.cjs +248 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +370 -545
- package/dist/index.d.ts +370 -545
- package/dist/index.js +190 -183
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9,13 +9,13 @@ var __export = (target, all) => {
|
|
|
9
9
|
for (var name in all)
|
|
10
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var __copyProps = (
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
14
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
@@ -35,33 +35,96 @@ __export(index_exports, {
|
|
|
35
35
|
Loop: () => Loop,
|
|
36
36
|
Pipe: () => Pipe,
|
|
37
37
|
Storage: () => Storage,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
chance: () => chance,
|
|
39
|
+
choice: () => choice,
|
|
40
|
+
chunk: () => chunk,
|
|
41
|
+
chunkAdj: () => chunkAdj,
|
|
42
|
+
clamp: () => clamp,
|
|
43
|
+
cluster: () => cluster,
|
|
44
|
+
compact: () => compact,
|
|
45
|
+
compactNumber: () => compactNumber,
|
|
46
|
+
currency: () => currency,
|
|
47
|
+
debounce: () => debounce,
|
|
41
48
|
default: () => index_default,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
defined: () => defined,
|
|
50
|
+
duration: () => duration,
|
|
51
|
+
empty: () => empty,
|
|
52
|
+
escapeRegex: () => escapeRegex,
|
|
53
|
+
eta: () => eta,
|
|
54
|
+
float: () => float,
|
|
55
|
+
forceArray: () => forceArray,
|
|
56
|
+
get: () => get,
|
|
57
|
+
getFlag: () => getFlag,
|
|
58
|
+
has: () => has,
|
|
59
|
+
hasFlag: () => hasFlag,
|
|
60
|
+
inRange: () => inRange,
|
|
61
|
+
index: () => index,
|
|
62
|
+
int: () => int,
|
|
63
|
+
invLerp: () => invLerp,
|
|
64
|
+
lerp: () => lerp,
|
|
65
|
+
memoize: () => memoize,
|
|
66
|
+
memory: () => memory,
|
|
67
|
+
merge: () => merge,
|
|
68
|
+
ms: () => ms,
|
|
69
|
+
number: () => number,
|
|
70
|
+
object: () => object,
|
|
71
|
+
omit: () => omit,
|
|
72
|
+
ordinal: () => ordinal,
|
|
73
|
+
parse: () => parse,
|
|
74
|
+
percent: () => percent,
|
|
75
|
+
pick: () => pick,
|
|
76
|
+
prng: () => prng,
|
|
77
|
+
readDir: () => readDir,
|
|
78
|
+
record: () => record,
|
|
79
|
+
remap: () => remap,
|
|
80
|
+
retry: () => retry,
|
|
81
|
+
sampler: () => sampler,
|
|
82
|
+
search: () => search,
|
|
83
|
+
secs: () => secs,
|
|
84
|
+
seqMap: () => seqMap,
|
|
85
|
+
set: () => set,
|
|
86
|
+
shuffle: () => shuffle,
|
|
87
|
+
sortBy: () => sortBy,
|
|
88
|
+
sorted: () => sorted,
|
|
89
|
+
str: () => str,
|
|
90
|
+
string: () => string,
|
|
91
|
+
sum: () => sum,
|
|
92
|
+
throttle: () => throttle,
|
|
93
|
+
toTitleCase: () => toTitleCase,
|
|
94
|
+
today: () => today,
|
|
95
|
+
unique: () => unique,
|
|
96
|
+
wait: () => wait,
|
|
97
|
+
weighted: () => weighted
|
|
52
98
|
});
|
|
53
99
|
module.exports = __toCommonJS(index_exports);
|
|
54
100
|
|
|
55
101
|
// src/arr.ts
|
|
56
102
|
var arr_exports = {};
|
|
57
103
|
__export(arr_exports, {
|
|
58
|
-
|
|
104
|
+
chunk: () => chunk,
|
|
105
|
+
chunkAdj: () => chunkAdj,
|
|
106
|
+
cluster: () => cluster,
|
|
107
|
+
compact: () => compact,
|
|
108
|
+
forceArray: () => forceArray,
|
|
109
|
+
search: () => search,
|
|
110
|
+
seqMap: () => seqMap,
|
|
111
|
+
shuffle: () => shuffle,
|
|
112
|
+
sortBy: () => sortBy,
|
|
113
|
+
unique: () => unique
|
|
59
114
|
});
|
|
60
115
|
|
|
61
116
|
// src/rnd.ts
|
|
62
117
|
var rnd_exports = {};
|
|
63
118
|
__export(rnd_exports, {
|
|
64
|
-
|
|
119
|
+
chance: () => chance,
|
|
120
|
+
choice: () => choice,
|
|
121
|
+
float: () => float,
|
|
122
|
+
index: () => index,
|
|
123
|
+
int: () => int,
|
|
124
|
+
prng: () => prng,
|
|
125
|
+
sampler: () => sampler,
|
|
126
|
+
str: () => str,
|
|
127
|
+
weighted: () => weighted
|
|
65
128
|
});
|
|
66
129
|
var LOWER = "abcdefghijklmnopqrstuvwxyz";
|
|
67
130
|
var UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
@@ -75,13 +138,13 @@ function chance(percent2 = 0.5, seed) {
|
|
|
75
138
|
function choice(array, options = {}) {
|
|
76
139
|
const { seed, not, maxRerolls = 10 } = options;
|
|
77
140
|
const random = seed !== void 0 ? prng(seed) : Math.random;
|
|
78
|
-
const
|
|
79
|
-
let result =
|
|
141
|
+
const rnd = () => array[Math.floor(random() * array.length)];
|
|
142
|
+
let result = rnd();
|
|
80
143
|
if (seed === void 0 && array.length > 1 && not !== void 0) {
|
|
81
144
|
let rerolls = 0;
|
|
82
145
|
const shouldReroll = () => typeof not === "function" ? not(result) : result === not;
|
|
83
146
|
while (shouldReroll() && rerolls < maxRerolls) {
|
|
84
|
-
result =
|
|
147
|
+
result = rnd();
|
|
85
148
|
rerolls++;
|
|
86
149
|
}
|
|
87
150
|
}
|
|
@@ -163,13 +226,13 @@ function float(min, max, seed) {
|
|
|
163
226
|
function index(array, options = {}) {
|
|
164
227
|
const { seed, not, maxRerolls = 10 } = options;
|
|
165
228
|
const random = seed !== void 0 ? prng(seed) : Math.random;
|
|
166
|
-
const
|
|
167
|
-
let result =
|
|
229
|
+
const rnd = () => Math.floor(random() * array.length);
|
|
230
|
+
let result = rnd();
|
|
168
231
|
if (seed === void 0 && array.length > 1 && not !== void 0) {
|
|
169
232
|
let rerolls = 0;
|
|
170
233
|
const shouldReroll = () => typeof not === "function" ? not(result) : result === not;
|
|
171
234
|
while (shouldReroll() && rerolls < maxRerolls) {
|
|
172
|
-
result =
|
|
235
|
+
result = rnd();
|
|
173
236
|
rerolls++;
|
|
174
237
|
}
|
|
175
238
|
}
|
|
@@ -196,17 +259,6 @@ function str(len, mode, options = {}) {
|
|
|
196
259
|
}
|
|
197
260
|
return result.join("");
|
|
198
261
|
}
|
|
199
|
-
var rnd = {
|
|
200
|
-
chance,
|
|
201
|
-
choice,
|
|
202
|
-
weighted,
|
|
203
|
-
sampler,
|
|
204
|
-
prng,
|
|
205
|
-
float,
|
|
206
|
-
index,
|
|
207
|
-
int,
|
|
208
|
-
str
|
|
209
|
-
};
|
|
210
262
|
|
|
211
263
|
// src/arr.ts
|
|
212
264
|
function chunk(array, size) {
|
|
@@ -295,7 +347,7 @@ function seqMap(array, callback) {
|
|
|
295
347
|
return result;
|
|
296
348
|
}
|
|
297
349
|
function shuffle(array, seed) {
|
|
298
|
-
const random = seed !== void 0 ?
|
|
350
|
+
const random = seed !== void 0 ? prng(seed) : Math.random;
|
|
299
351
|
const result = [...array];
|
|
300
352
|
for (let i = result.length - 1; i > 0; i--) {
|
|
301
353
|
const j = Math.floor(random() * (i + 1));
|
|
@@ -329,27 +381,16 @@ function sortBy(array, selectorOrSelectors, order = "asc") {
|
|
|
329
381
|
function unique(array, key) {
|
|
330
382
|
return Array.from(new Map(array.map((item) => [key(item), item])).values());
|
|
331
383
|
}
|
|
332
|
-
var arr = {
|
|
333
|
-
chunk,
|
|
334
|
-
chunkAdj,
|
|
335
|
-
cluster,
|
|
336
|
-
compact,
|
|
337
|
-
forceArray,
|
|
338
|
-
search,
|
|
339
|
-
seqMap,
|
|
340
|
-
shuffle,
|
|
341
|
-
sortBy,
|
|
342
|
-
unique
|
|
343
|
-
};
|
|
344
384
|
|
|
345
385
|
// src/async.ts
|
|
346
386
|
var async_exports = {};
|
|
347
387
|
__export(async_exports, {
|
|
348
|
-
|
|
388
|
+
retry: () => retry,
|
|
389
|
+
wait: () => wait
|
|
349
390
|
});
|
|
350
|
-
async function retry(
|
|
391
|
+
async function retry(fn, retries = 3, delay = 500) {
|
|
351
392
|
try {
|
|
352
|
-
return await
|
|
393
|
+
return await fn();
|
|
353
394
|
} catch (error) {
|
|
354
395
|
if (retries <= 0) throw error;
|
|
355
396
|
const jitter = Math.random() * 200;
|
|
@@ -363,17 +404,13 @@ function wait(ms2) {
|
|
|
363
404
|
}, ms2)
|
|
364
405
|
);
|
|
365
406
|
}
|
|
366
|
-
var async = {
|
|
367
|
-
retry,
|
|
368
|
-
wait
|
|
369
|
-
};
|
|
370
407
|
|
|
371
408
|
// src/fn.ts
|
|
372
409
|
var fn_exports = {};
|
|
373
410
|
__export(fn_exports, {
|
|
374
|
-
|
|
411
|
+
memoize: () => memoize
|
|
375
412
|
});
|
|
376
|
-
function memoize(
|
|
413
|
+
function memoize(fn, options = {}) {
|
|
377
414
|
const cache = /* @__PURE__ */ new Map();
|
|
378
415
|
const { resolver, maxAge } = options;
|
|
379
416
|
const memoized = function(...args) {
|
|
@@ -386,21 +423,20 @@ function memoize(fn2, options = {}) {
|
|
|
386
423
|
}
|
|
387
424
|
cache.delete(key);
|
|
388
425
|
}
|
|
389
|
-
const result =
|
|
426
|
+
const result = fn.apply(this, args);
|
|
390
427
|
cache.set(key, { value: result, timestamp: now });
|
|
391
428
|
return result;
|
|
392
429
|
};
|
|
393
430
|
memoized.clear = () => cache.clear();
|
|
394
431
|
return memoized;
|
|
395
432
|
}
|
|
396
|
-
var fn = {
|
|
397
|
-
memoize
|
|
398
|
-
};
|
|
399
433
|
|
|
400
434
|
// src/date.ts
|
|
401
435
|
var date_exports = {};
|
|
402
436
|
__export(date_exports, {
|
|
403
|
-
|
|
437
|
+
duration: () => duration,
|
|
438
|
+
eta: () => eta,
|
|
439
|
+
parse: () => parse
|
|
404
440
|
});
|
|
405
441
|
var MS_MAP = {
|
|
406
442
|
ms: 1,
|
|
@@ -440,9 +476,9 @@ function duration(target, style = "hms", options = {}) {
|
|
|
440
476
|
const last = result.pop();
|
|
441
477
|
return `${result.join(", ")} and ${last}`;
|
|
442
478
|
}
|
|
443
|
-
function eta(
|
|
479
|
+
function eta(date, locale) {
|
|
444
480
|
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
445
|
-
const elapsed = (typeof
|
|
481
|
+
const elapsed = (typeof date === "number" ? date : date.getTime()) - Date.now();
|
|
446
482
|
const units = [
|
|
447
483
|
{ unit: "year", ms: 31536e6 },
|
|
448
484
|
{ unit: "month", ms: 2628e6 },
|
|
@@ -458,9 +494,9 @@ function eta(date2, locale) {
|
|
|
458
494
|
}
|
|
459
495
|
return "";
|
|
460
496
|
}
|
|
461
|
-
function parse(
|
|
462
|
-
if (typeof
|
|
463
|
-
const matches =
|
|
497
|
+
function parse(str2, options = {}) {
|
|
498
|
+
if (typeof str2 === "number") return str2;
|
|
499
|
+
const matches = str2.matchAll(/(-?\d+)([a-z]+)/gi);
|
|
464
500
|
let totalMs = 0;
|
|
465
501
|
let found = false;
|
|
466
502
|
for (const [_, value, unit] of matches) {
|
|
@@ -471,20 +507,19 @@ function parse(str3, options = {}) {
|
|
|
471
507
|
found = true;
|
|
472
508
|
}
|
|
473
509
|
}
|
|
474
|
-
if (!found) throw new Error(`parse: Invalid time format: "${
|
|
510
|
+
if (!found) throw new Error(`parse: Invalid time format: "${str2}"`);
|
|
475
511
|
const result = options.unit === "s" ? totalMs / 1e3 : totalMs;
|
|
476
512
|
return options.fromNow ? Date.now() + result : result;
|
|
477
513
|
}
|
|
478
|
-
var date = {
|
|
479
|
-
duration,
|
|
480
|
-
eta,
|
|
481
|
-
parse
|
|
482
|
-
};
|
|
483
514
|
|
|
484
515
|
// src/format.ts
|
|
485
516
|
var format_exports = {};
|
|
486
517
|
__export(format_exports, {
|
|
487
|
-
|
|
518
|
+
compactNumber: () => compactNumber,
|
|
519
|
+
currency: () => currency,
|
|
520
|
+
memory: () => memory,
|
|
521
|
+
number: () => number,
|
|
522
|
+
ordinal: () => ordinal
|
|
488
523
|
});
|
|
489
524
|
function currency(num, options = {}) {
|
|
490
525
|
return new Intl.NumberFormat(options.locale, {
|
|
@@ -525,18 +560,11 @@ function compactNumber(num, locale) {
|
|
|
525
560
|
maximumFractionDigits: 1
|
|
526
561
|
}).format(num);
|
|
527
562
|
}
|
|
528
|
-
var format = {
|
|
529
|
-
currency,
|
|
530
|
-
number,
|
|
531
|
-
memory,
|
|
532
|
-
ordinal,
|
|
533
|
-
compactNumber
|
|
534
|
-
};
|
|
535
563
|
|
|
536
564
|
// src/fs.ts
|
|
537
565
|
var fs_exports = {};
|
|
538
566
|
__export(fs_exports, {
|
|
539
|
-
|
|
567
|
+
readDir: () => readDir
|
|
540
568
|
});
|
|
541
569
|
var import_node_fs = __toESM(require("fs"));
|
|
542
570
|
var import_node_path = require("path");
|
|
@@ -544,8 +572,8 @@ function readDir(path2, options = {}) {
|
|
|
544
572
|
const { recursive = true } = options;
|
|
545
573
|
if (!import_node_fs.default.existsSync(path2)) return [];
|
|
546
574
|
if (!recursive) {
|
|
547
|
-
return import_node_fs.default.readdirSync(path2).filter((
|
|
548
|
-
return import_node_fs.default.statSync((0, import_node_path.join)(path2,
|
|
575
|
+
return import_node_fs.default.readdirSync(path2).filter((fn) => {
|
|
576
|
+
return import_node_fs.default.statSync((0, import_node_path.join)(path2, fn)).isFile();
|
|
549
577
|
});
|
|
550
578
|
}
|
|
551
579
|
const walk = (dir, base = "") => {
|
|
@@ -564,14 +592,17 @@ function readDir(path2, options = {}) {
|
|
|
564
592
|
};
|
|
565
593
|
return walk(path2);
|
|
566
594
|
}
|
|
567
|
-
var fs = {
|
|
568
|
-
readDir
|
|
569
|
-
};
|
|
570
595
|
|
|
571
596
|
// src/is.ts
|
|
572
597
|
var is_exports = {};
|
|
573
598
|
__export(is_exports, {
|
|
574
|
-
|
|
599
|
+
defined: () => defined,
|
|
600
|
+
empty: () => empty,
|
|
601
|
+
inRange: () => inRange,
|
|
602
|
+
object: () => object,
|
|
603
|
+
sorted: () => sorted,
|
|
604
|
+
string: () => string,
|
|
605
|
+
today: () => today
|
|
575
606
|
});
|
|
576
607
|
function defined(val) {
|
|
577
608
|
return val !== void 0 && val !== null;
|
|
@@ -591,9 +622,9 @@ function inRange(num, a, b) {
|
|
|
591
622
|
function object(val) {
|
|
592
623
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
593
624
|
}
|
|
594
|
-
function sorted(
|
|
595
|
-
for (let i = 0; i <
|
|
596
|
-
const comp = comparator ? comparator(
|
|
625
|
+
function sorted(arr, comparator) {
|
|
626
|
+
for (let i = 0; i < arr.length - 1; i++) {
|
|
627
|
+
const comp = comparator ? comparator(arr[i], arr[i + 1]) : arr[i] > arr[i + 1] ? 1 : -1;
|
|
597
628
|
if (comp > 0) return false;
|
|
598
629
|
}
|
|
599
630
|
return true;
|
|
@@ -601,25 +632,23 @@ function sorted(arr2, comparator) {
|
|
|
601
632
|
function string(val) {
|
|
602
633
|
return typeof val === "string";
|
|
603
634
|
}
|
|
604
|
-
function today(
|
|
605
|
-
const d =
|
|
635
|
+
function today(date) {
|
|
636
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
606
637
|
const today2 = /* @__PURE__ */ new Date();
|
|
607
638
|
return d.getDate() === today2.getDate() && d.getMonth() === today2.getMonth() && d.getFullYear() === today2.getFullYear();
|
|
608
639
|
}
|
|
609
|
-
var is = {
|
|
610
|
-
defined,
|
|
611
|
-
empty,
|
|
612
|
-
inRange,
|
|
613
|
-
object,
|
|
614
|
-
sorted,
|
|
615
|
-
string,
|
|
616
|
-
today
|
|
617
|
-
};
|
|
618
640
|
|
|
619
641
|
// src/math.ts
|
|
620
642
|
var math_exports = {};
|
|
621
643
|
__export(math_exports, {
|
|
622
|
-
|
|
644
|
+
clamp: () => clamp,
|
|
645
|
+
invLerp: () => invLerp,
|
|
646
|
+
lerp: () => lerp,
|
|
647
|
+
ms: () => ms,
|
|
648
|
+
percent: () => percent,
|
|
649
|
+
remap: () => remap,
|
|
650
|
+
secs: () => secs,
|
|
651
|
+
sum: () => sum
|
|
623
652
|
});
|
|
624
653
|
function clamp(num, a, b) {
|
|
625
654
|
let min = b !== void 0 ? a : 0;
|
|
@@ -657,26 +686,21 @@ function sum(array, selector) {
|
|
|
657
686
|
return (isNaN(b) ? 0 : b) < 0 ? a - -b : a + (b || 0);
|
|
658
687
|
}, 0);
|
|
659
688
|
}
|
|
660
|
-
var math = {
|
|
661
|
-
clamp,
|
|
662
|
-
invLerp,
|
|
663
|
-
lerp,
|
|
664
|
-
ms,
|
|
665
|
-
percent,
|
|
666
|
-
remap,
|
|
667
|
-
secs,
|
|
668
|
-
sum
|
|
669
|
-
};
|
|
670
689
|
|
|
671
690
|
// src/obj.ts
|
|
672
691
|
var obj_exports = {};
|
|
673
692
|
__export(obj_exports, {
|
|
674
|
-
|
|
693
|
+
get: () => get,
|
|
694
|
+
has: () => has,
|
|
695
|
+
merge: () => merge,
|
|
696
|
+
omit: () => omit,
|
|
697
|
+
pick: () => pick,
|
|
698
|
+
set: () => set
|
|
675
699
|
});
|
|
676
|
-
function get(
|
|
677
|
-
if (!
|
|
700
|
+
function get(obj, path2, defaultValue) {
|
|
701
|
+
if (!obj) throw new Error("get: Target object is null or undefined");
|
|
678
702
|
const parts = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
679
|
-
let current =
|
|
703
|
+
let current = obj;
|
|
680
704
|
const trace = [];
|
|
681
705
|
for (const part of parts) {
|
|
682
706
|
trace.push(part);
|
|
@@ -692,10 +716,10 @@ function get(obj2, path2, defaultValue) {
|
|
|
692
716
|
}
|
|
693
717
|
return current;
|
|
694
718
|
}
|
|
695
|
-
function has(
|
|
696
|
-
if (!
|
|
719
|
+
function has(obj, path2) {
|
|
720
|
+
if (!obj || !path2) return false;
|
|
697
721
|
const parts = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
698
|
-
let current =
|
|
722
|
+
let current = obj;
|
|
699
723
|
for (let i = 0; i < parts.length; i++) {
|
|
700
724
|
const part = parts[i];
|
|
701
725
|
if (current === null || typeof current !== "object") {
|
|
@@ -708,9 +732,9 @@ function has(obj2, path2) {
|
|
|
708
732
|
}
|
|
709
733
|
return true;
|
|
710
734
|
}
|
|
711
|
-
function set(
|
|
735
|
+
function set(obj, path2, value) {
|
|
712
736
|
const parts = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
713
|
-
let current =
|
|
737
|
+
let current = obj;
|
|
714
738
|
for (let i = 0; i < parts.length; i++) {
|
|
715
739
|
const part = parts[i];
|
|
716
740
|
const isLast = i === parts.length - 1;
|
|
@@ -742,58 +766,53 @@ function merge(target, ...sources) {
|
|
|
742
766
|
}
|
|
743
767
|
return target;
|
|
744
768
|
}
|
|
745
|
-
function pick(
|
|
769
|
+
function pick(obj, keys) {
|
|
746
770
|
const result = {};
|
|
747
771
|
for (const key of keys) {
|
|
748
|
-
if (key in
|
|
749
|
-
result[key] =
|
|
772
|
+
if (key in obj) {
|
|
773
|
+
result[key] = obj[key];
|
|
750
774
|
}
|
|
751
775
|
}
|
|
752
776
|
return result;
|
|
753
777
|
}
|
|
754
|
-
function omit(
|
|
755
|
-
const result = { ...
|
|
778
|
+
function omit(obj, keys) {
|
|
779
|
+
const result = { ...obj };
|
|
756
780
|
for (const key of keys) {
|
|
757
781
|
delete result[key];
|
|
758
782
|
}
|
|
759
783
|
return result;
|
|
760
784
|
}
|
|
761
|
-
var obj = {
|
|
762
|
-
get,
|
|
763
|
-
has,
|
|
764
|
-
set,
|
|
765
|
-
merge,
|
|
766
|
-
pick,
|
|
767
|
-
omit
|
|
768
|
-
};
|
|
769
785
|
|
|
770
786
|
// src/str.ts
|
|
771
787
|
var str_exports = {};
|
|
772
788
|
__export(str_exports, {
|
|
773
|
-
|
|
789
|
+
escapeRegex: () => escapeRegex,
|
|
790
|
+
getFlag: () => getFlag,
|
|
791
|
+
hasFlag: () => hasFlag,
|
|
792
|
+
toTitleCase: () => toTitleCase
|
|
774
793
|
});
|
|
775
|
-
function escapeRegex(
|
|
776
|
-
return
|
|
794
|
+
function escapeRegex(str2) {
|
|
795
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
777
796
|
}
|
|
778
|
-
function getFlag(
|
|
797
|
+
function getFlag(str2, flag, length) {
|
|
779
798
|
const regex = flag instanceof RegExp ? flag : new RegExp(`${escapeRegex(flag)}\\b`, "g");
|
|
780
|
-
const match = regex.exec(
|
|
799
|
+
const match = regex.exec(str2);
|
|
781
800
|
if (!match) return null;
|
|
782
801
|
const startIndex = match.index + match[0].length;
|
|
783
|
-
let result =
|
|
802
|
+
let result = str2.slice(startIndex).trimStart();
|
|
784
803
|
if (length !== void 0) {
|
|
785
804
|
return result.split(/\s+/).slice(0, length).join(" ");
|
|
786
805
|
}
|
|
787
806
|
return result || null;
|
|
788
807
|
}
|
|
789
|
-
function hasFlag(
|
|
790
|
-
if (flag instanceof RegExp) return flag.test(
|
|
808
|
+
function hasFlag(str2, flag) {
|
|
809
|
+
if (flag instanceof RegExp) return flag.test(str2);
|
|
791
810
|
const pattern = new RegExp(`${escapeRegex(flag)}\\b`);
|
|
792
|
-
return pattern.test(
|
|
811
|
+
return pattern.test(str2);
|
|
793
812
|
}
|
|
794
|
-
function toTitleCase(
|
|
813
|
+
function toTitleCase(str2, smart = true) {
|
|
795
814
|
const minorWords = /^(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v\.?|via)$/i;
|
|
796
|
-
return
|
|
815
|
+
return str2.replace(/\w\S*/g, (txt, index2) => {
|
|
797
816
|
if (smart && index2 !== 0 && minorWords.test(txt)) {
|
|
798
817
|
return txt.toLowerCase();
|
|
799
818
|
}
|
|
@@ -803,19 +822,14 @@ function toTitleCase(str3, smart = true) {
|
|
|
803
822
|
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
804
823
|
});
|
|
805
824
|
}
|
|
806
|
-
var str2 = {
|
|
807
|
-
escapeRegex,
|
|
808
|
-
getFlag,
|
|
809
|
-
hasFlag,
|
|
810
|
-
toTitleCase
|
|
811
|
-
};
|
|
812
825
|
|
|
813
826
|
// src/timing.ts
|
|
814
827
|
var timing_exports = {};
|
|
815
828
|
__export(timing_exports, {
|
|
816
|
-
|
|
829
|
+
debounce: () => debounce,
|
|
830
|
+
throttle: () => throttle
|
|
817
831
|
});
|
|
818
|
-
function debounce(
|
|
832
|
+
function debounce(fn, wait2, options = {}) {
|
|
819
833
|
let timeoutId;
|
|
820
834
|
const leading = options.immediate ?? false;
|
|
821
835
|
const debounced = function(...args) {
|
|
@@ -823,9 +837,9 @@ function debounce(fn2, wait2, options = {}) {
|
|
|
823
837
|
if (timeoutId) clearTimeout(timeoutId);
|
|
824
838
|
timeoutId = setTimeout(() => {
|
|
825
839
|
timeoutId = void 0;
|
|
826
|
-
if (!leading)
|
|
840
|
+
if (!leading) fn.apply(this, args);
|
|
827
841
|
}, wait2);
|
|
828
|
-
if (callNow)
|
|
842
|
+
if (callNow) fn.apply(this, args);
|
|
829
843
|
};
|
|
830
844
|
debounced.cancel = () => {
|
|
831
845
|
if (timeoutId) {
|
|
@@ -835,25 +849,21 @@ function debounce(fn2, wait2, options = {}) {
|
|
|
835
849
|
};
|
|
836
850
|
return debounced;
|
|
837
851
|
}
|
|
838
|
-
function throttle(
|
|
852
|
+
function throttle(fn, limit) {
|
|
839
853
|
let inThrottle = false;
|
|
840
854
|
return function(...args) {
|
|
841
855
|
if (!inThrottle) {
|
|
842
|
-
|
|
856
|
+
fn.apply(this, args);
|
|
843
857
|
inThrottle = true;
|
|
844
858
|
setTimeout(() => inThrottle = false, limit);
|
|
845
859
|
}
|
|
846
860
|
};
|
|
847
861
|
}
|
|
848
|
-
var timing = {
|
|
849
|
-
debounce,
|
|
850
|
-
throttle
|
|
851
|
-
};
|
|
852
862
|
|
|
853
863
|
// src/to.ts
|
|
854
864
|
var to_exports = {};
|
|
855
865
|
__export(to_exports, {
|
|
856
|
-
|
|
866
|
+
record: () => record
|
|
857
867
|
});
|
|
858
868
|
function record(array, callback) {
|
|
859
869
|
const result = {};
|
|
@@ -871,13 +881,10 @@ function record(array, callback) {
|
|
|
871
881
|
}
|
|
872
882
|
return result;
|
|
873
883
|
}
|
|
874
|
-
var to = {
|
|
875
|
-
record
|
|
876
|
-
};
|
|
877
884
|
|
|
878
885
|
// src/Pipe.ts
|
|
879
886
|
function Pipe(value, ...fns) {
|
|
880
|
-
return fns.reduce((acc,
|
|
887
|
+
return fns.reduce((acc, fn) => fn(acc), value);
|
|
881
888
|
}
|
|
882
889
|
|
|
883
890
|
// src/Storage.ts
|
|
@@ -1055,9 +1062,9 @@ var Loop = class extends TypedEmitterBase {
|
|
|
1055
1062
|
* @param delay The delay between runs in milliseconds.
|
|
1056
1063
|
* @param immediate Whether to start the loop immediately. [default: true]
|
|
1057
1064
|
*/
|
|
1058
|
-
constructor(
|
|
1065
|
+
constructor(fn, delay, immediate = true) {
|
|
1059
1066
|
super();
|
|
1060
|
-
this.fn =
|
|
1067
|
+
this.fn = fn;
|
|
1061
1068
|
this.delay = delay;
|
|
1062
1069
|
if (immediate) this.start();
|
|
1063
1070
|
}
|
|
@@ -1114,19 +1121,19 @@ var Loop = class extends TypedEmitterBase {
|
|
|
1114
1121
|
|
|
1115
1122
|
// src/index.ts
|
|
1116
1123
|
var qznt = {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1124
|
+
arr: arr_exports,
|
|
1125
|
+
async: async_exports,
|
|
1126
|
+
fn: fn_exports,
|
|
1127
|
+
date: date_exports,
|
|
1128
|
+
format: format_exports,
|
|
1129
|
+
fs: fs_exports,
|
|
1130
|
+
is: is_exports,
|
|
1131
|
+
math: math_exports,
|
|
1132
|
+
obj: obj_exports,
|
|
1133
|
+
timing: timing_exports,
|
|
1134
|
+
rnd: rnd_exports,
|
|
1135
|
+
str: str_exports,
|
|
1136
|
+
to: to_exports,
|
|
1130
1137
|
Pipe,
|
|
1131
1138
|
Storage,
|
|
1132
1139
|
Cache,
|
|
@@ -1141,18 +1148,64 @@ var index_default = qznt;
|
|
|
1141
1148
|
Loop,
|
|
1142
1149
|
Pipe,
|
|
1143
1150
|
Storage,
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1151
|
+
chance,
|
|
1152
|
+
choice,
|
|
1153
|
+
chunk,
|
|
1154
|
+
chunkAdj,
|
|
1155
|
+
clamp,
|
|
1156
|
+
cluster,
|
|
1157
|
+
compact,
|
|
1158
|
+
compactNumber,
|
|
1159
|
+
currency,
|
|
1160
|
+
debounce,
|
|
1161
|
+
defined,
|
|
1162
|
+
duration,
|
|
1163
|
+
empty,
|
|
1164
|
+
escapeRegex,
|
|
1165
|
+
eta,
|
|
1166
|
+
float,
|
|
1167
|
+
forceArray,
|
|
1168
|
+
get,
|
|
1169
|
+
getFlag,
|
|
1170
|
+
has,
|
|
1171
|
+
hasFlag,
|
|
1172
|
+
inRange,
|
|
1173
|
+
index,
|
|
1174
|
+
int,
|
|
1175
|
+
invLerp,
|
|
1176
|
+
lerp,
|
|
1177
|
+
memoize,
|
|
1178
|
+
memory,
|
|
1179
|
+
merge,
|
|
1180
|
+
ms,
|
|
1181
|
+
number,
|
|
1182
|
+
object,
|
|
1183
|
+
omit,
|
|
1184
|
+
ordinal,
|
|
1185
|
+
parse,
|
|
1186
|
+
percent,
|
|
1187
|
+
pick,
|
|
1188
|
+
prng,
|
|
1189
|
+
readDir,
|
|
1190
|
+
record,
|
|
1191
|
+
remap,
|
|
1192
|
+
retry,
|
|
1193
|
+
sampler,
|
|
1194
|
+
search,
|
|
1195
|
+
secs,
|
|
1196
|
+
seqMap,
|
|
1197
|
+
set,
|
|
1198
|
+
shuffle,
|
|
1199
|
+
sortBy,
|
|
1200
|
+
sorted,
|
|
1154
1201
|
str,
|
|
1155
|
-
|
|
1156
|
-
|
|
1202
|
+
string,
|
|
1203
|
+
sum,
|
|
1204
|
+
throttle,
|
|
1205
|
+
toTitleCase,
|
|
1206
|
+
today,
|
|
1207
|
+
unique,
|
|
1208
|
+
wait,
|
|
1209
|
+
weighted
|
|
1157
1210
|
});
|
|
1158
1211
|
//# sourceMappingURL=index.cjs.map
|