qznt 1.0.34 → 1.0.36
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 +295 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +399 -544
- package/dist/index.d.ts +399 -544
- package/dist/index.js +235 -184
- 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,98 @@ __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
|
+
getAge: () => getAge,
|
|
58
|
+
getFlag: () => getFlag,
|
|
59
|
+
has: () => has,
|
|
60
|
+
hasFlag: () => hasFlag,
|
|
61
|
+
inRange: () => inRange,
|
|
62
|
+
index: () => index,
|
|
63
|
+
int: () => int,
|
|
64
|
+
invLerp: () => invLerp,
|
|
65
|
+
lerp: () => lerp,
|
|
66
|
+
memoize: () => memoize,
|
|
67
|
+
memory: () => memory,
|
|
68
|
+
merge: () => merge,
|
|
69
|
+
ms: () => ms,
|
|
70
|
+
number: () => number,
|
|
71
|
+
object: () => object,
|
|
72
|
+
omit: () => omit,
|
|
73
|
+
ordinal: () => ordinal,
|
|
74
|
+
parse: () => parse,
|
|
75
|
+
percent: () => percent,
|
|
76
|
+
pick: () => pick,
|
|
77
|
+
prng: () => prng,
|
|
78
|
+
readDir: () => readDir,
|
|
79
|
+
record: () => record,
|
|
80
|
+
remap: () => remap,
|
|
81
|
+
retry: () => retry,
|
|
82
|
+
sampler: () => sampler,
|
|
83
|
+
search: () => search,
|
|
84
|
+
secs: () => secs,
|
|
85
|
+
seqMap: () => seqMap,
|
|
86
|
+
set: () => set,
|
|
87
|
+
shuffle: () => shuffle,
|
|
88
|
+
sortBy: () => sortBy,
|
|
89
|
+
sorted: () => sorted,
|
|
90
|
+
str: () => str,
|
|
91
|
+
string: () => string,
|
|
92
|
+
sum: () => sum,
|
|
93
|
+
throttle: () => throttle,
|
|
94
|
+
toTitleCase: () => toTitleCase,
|
|
95
|
+
today: () => today,
|
|
96
|
+
unique: () => unique,
|
|
97
|
+
wait: () => wait,
|
|
98
|
+
weighted: () => weighted,
|
|
99
|
+
wrap: () => wrap
|
|
52
100
|
});
|
|
53
101
|
module.exports = __toCommonJS(index_exports);
|
|
54
102
|
|
|
55
103
|
// src/arr.ts
|
|
56
104
|
var arr_exports = {};
|
|
57
105
|
__export(arr_exports, {
|
|
58
|
-
|
|
106
|
+
chunk: () => chunk,
|
|
107
|
+
chunkAdj: () => chunkAdj,
|
|
108
|
+
cluster: () => cluster,
|
|
109
|
+
compact: () => compact,
|
|
110
|
+
forceArray: () => forceArray,
|
|
111
|
+
search: () => search,
|
|
112
|
+
seqMap: () => seqMap,
|
|
113
|
+
shuffle: () => shuffle,
|
|
114
|
+
sortBy: () => sortBy,
|
|
115
|
+
unique: () => unique
|
|
59
116
|
});
|
|
60
117
|
|
|
61
118
|
// src/rnd.ts
|
|
62
119
|
var rnd_exports = {};
|
|
63
120
|
__export(rnd_exports, {
|
|
64
|
-
|
|
121
|
+
chance: () => chance,
|
|
122
|
+
choice: () => choice,
|
|
123
|
+
float: () => float,
|
|
124
|
+
index: () => index,
|
|
125
|
+
int: () => int,
|
|
126
|
+
prng: () => prng,
|
|
127
|
+
sampler: () => sampler,
|
|
128
|
+
str: () => str,
|
|
129
|
+
weighted: () => weighted
|
|
65
130
|
});
|
|
66
131
|
var LOWER = "abcdefghijklmnopqrstuvwxyz";
|
|
67
132
|
var UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
@@ -75,13 +140,13 @@ function chance(percent2 = 0.5, seed) {
|
|
|
75
140
|
function choice(array, options = {}) {
|
|
76
141
|
const { seed, not, maxRerolls = 10 } = options;
|
|
77
142
|
const random = seed !== void 0 ? prng(seed) : Math.random;
|
|
78
|
-
const
|
|
79
|
-
let result =
|
|
143
|
+
const rnd = () => array[Math.floor(random() * array.length)];
|
|
144
|
+
let result = rnd();
|
|
80
145
|
if (seed === void 0 && array.length > 1 && not !== void 0) {
|
|
81
146
|
let rerolls = 0;
|
|
82
147
|
const shouldReroll = () => typeof not === "function" ? not(result) : result === not;
|
|
83
148
|
while (shouldReroll() && rerolls < maxRerolls) {
|
|
84
|
-
result =
|
|
149
|
+
result = rnd();
|
|
85
150
|
rerolls++;
|
|
86
151
|
}
|
|
87
152
|
}
|
|
@@ -163,13 +228,13 @@ function float(min, max, seed) {
|
|
|
163
228
|
function index(array, options = {}) {
|
|
164
229
|
const { seed, not, maxRerolls = 10 } = options;
|
|
165
230
|
const random = seed !== void 0 ? prng(seed) : Math.random;
|
|
166
|
-
const
|
|
167
|
-
let result =
|
|
231
|
+
const rnd = () => Math.floor(random() * array.length);
|
|
232
|
+
let result = rnd();
|
|
168
233
|
if (seed === void 0 && array.length > 1 && not !== void 0) {
|
|
169
234
|
let rerolls = 0;
|
|
170
235
|
const shouldReroll = () => typeof not === "function" ? not(result) : result === not;
|
|
171
236
|
while (shouldReroll() && rerolls < maxRerolls) {
|
|
172
|
-
result =
|
|
237
|
+
result = rnd();
|
|
173
238
|
rerolls++;
|
|
174
239
|
}
|
|
175
240
|
}
|
|
@@ -196,17 +261,6 @@ function str(len, mode, options = {}) {
|
|
|
196
261
|
}
|
|
197
262
|
return result.join("");
|
|
198
263
|
}
|
|
199
|
-
var rnd = {
|
|
200
|
-
chance,
|
|
201
|
-
choice,
|
|
202
|
-
weighted,
|
|
203
|
-
sampler,
|
|
204
|
-
prng,
|
|
205
|
-
float,
|
|
206
|
-
index,
|
|
207
|
-
int,
|
|
208
|
-
str
|
|
209
|
-
};
|
|
210
264
|
|
|
211
265
|
// src/arr.ts
|
|
212
266
|
function chunk(array, size) {
|
|
@@ -295,7 +349,7 @@ function seqMap(array, callback) {
|
|
|
295
349
|
return result;
|
|
296
350
|
}
|
|
297
351
|
function shuffle(array, seed) {
|
|
298
|
-
const random = seed !== void 0 ?
|
|
352
|
+
const random = seed !== void 0 ? prng(seed) : Math.random;
|
|
299
353
|
const result = [...array];
|
|
300
354
|
for (let i = result.length - 1; i > 0; i--) {
|
|
301
355
|
const j = Math.floor(random() * (i + 1));
|
|
@@ -329,31 +383,48 @@ function sortBy(array, selectorOrSelectors, order = "asc") {
|
|
|
329
383
|
function unique(array, key) {
|
|
330
384
|
return Array.from(new Map(array.map((item) => [key(item), item])).values());
|
|
331
385
|
}
|
|
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
386
|
|
|
345
387
|
// src/async.ts
|
|
346
388
|
var async_exports = {};
|
|
347
389
|
__export(async_exports, {
|
|
348
|
-
|
|
390
|
+
retry: () => retry,
|
|
391
|
+
wait: () => wait
|
|
349
392
|
});
|
|
350
|
-
async function retry(
|
|
393
|
+
async function retry(fn, options = {}) {
|
|
394
|
+
const { retries = 3, delay = 500, timeout, signal } = options;
|
|
395
|
+
if (signal?.aborted) throw new Error("Operation aborted");
|
|
396
|
+
const executeWithTimeout = async () => {
|
|
397
|
+
if (!timeout) return fn(signal);
|
|
398
|
+
const controller = new AbortController();
|
|
399
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
400
|
+
try {
|
|
401
|
+
return await fn(controller.signal);
|
|
402
|
+
} catch (err) {
|
|
403
|
+
if (controller.signal.aborted) throw new Error(`Attempt timed out after ${timeout}ms`);
|
|
404
|
+
throw err;
|
|
405
|
+
} finally {
|
|
406
|
+
clearTimeout(timer);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
351
409
|
try {
|
|
352
|
-
return await
|
|
410
|
+
return await executeWithTimeout();
|
|
353
411
|
} catch (error) {
|
|
412
|
+
if (signal?.aborted) throw error;
|
|
354
413
|
if (retries <= 0) throw error;
|
|
355
414
|
const jitter = Math.random() * 200;
|
|
356
|
-
|
|
415
|
+
const totalDelay = delay + jitter;
|
|
416
|
+
await new Promise((resolve, reject) => {
|
|
417
|
+
const timer = setTimeout(resolve, totalDelay);
|
|
418
|
+
signal?.addEventListener(
|
|
419
|
+
"abort",
|
|
420
|
+
() => {
|
|
421
|
+
clearTimeout(timer);
|
|
422
|
+
reject(new Error("Operation aborted"));
|
|
423
|
+
},
|
|
424
|
+
{ once: true }
|
|
425
|
+
);
|
|
426
|
+
});
|
|
427
|
+
return retry(fn, { ...options, retries: retries - 1, delay: delay * 2 });
|
|
357
428
|
}
|
|
358
429
|
}
|
|
359
430
|
function wait(ms2) {
|
|
@@ -363,17 +434,13 @@ function wait(ms2) {
|
|
|
363
434
|
}, ms2)
|
|
364
435
|
);
|
|
365
436
|
}
|
|
366
|
-
var async = {
|
|
367
|
-
retry,
|
|
368
|
-
wait
|
|
369
|
-
};
|
|
370
437
|
|
|
371
438
|
// src/fn.ts
|
|
372
439
|
var fn_exports = {};
|
|
373
440
|
__export(fn_exports, {
|
|
374
|
-
|
|
441
|
+
memoize: () => memoize
|
|
375
442
|
});
|
|
376
|
-
function memoize(
|
|
443
|
+
function memoize(fn, options = {}) {
|
|
377
444
|
const cache = /* @__PURE__ */ new Map();
|
|
378
445
|
const { resolver, maxAge } = options;
|
|
379
446
|
const memoized = function(...args) {
|
|
@@ -386,21 +453,21 @@ function memoize(fn2, options = {}) {
|
|
|
386
453
|
}
|
|
387
454
|
cache.delete(key);
|
|
388
455
|
}
|
|
389
|
-
const result =
|
|
456
|
+
const result = fn.apply(this, args);
|
|
390
457
|
cache.set(key, { value: result, timestamp: now });
|
|
391
458
|
return result;
|
|
392
459
|
};
|
|
393
460
|
memoized.clear = () => cache.clear();
|
|
394
461
|
return memoized;
|
|
395
462
|
}
|
|
396
|
-
var fn = {
|
|
397
|
-
memoize
|
|
398
|
-
};
|
|
399
463
|
|
|
400
464
|
// src/date.ts
|
|
401
465
|
var date_exports = {};
|
|
402
466
|
__export(date_exports, {
|
|
403
|
-
|
|
467
|
+
duration: () => duration,
|
|
468
|
+
eta: () => eta,
|
|
469
|
+
getAge: () => getAge,
|
|
470
|
+
parse: () => parse
|
|
404
471
|
});
|
|
405
472
|
var MS_MAP = {
|
|
406
473
|
ms: 1,
|
|
@@ -440,9 +507,9 @@ function duration(target, style = "hms", options = {}) {
|
|
|
440
507
|
const last = result.pop();
|
|
441
508
|
return `${result.join(", ")} and ${last}`;
|
|
442
509
|
}
|
|
443
|
-
function eta(
|
|
510
|
+
function eta(date, locale) {
|
|
444
511
|
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
445
|
-
const elapsed = (typeof
|
|
512
|
+
const elapsed = (typeof date === "number" ? date : date.getTime()) - Date.now();
|
|
446
513
|
const units = [
|
|
447
514
|
{ unit: "year", ms: 31536e6 },
|
|
448
515
|
{ unit: "month", ms: 2628e6 },
|
|
@@ -458,9 +525,18 @@ function eta(date2, locale) {
|
|
|
458
525
|
}
|
|
459
526
|
return "";
|
|
460
527
|
}
|
|
461
|
-
function
|
|
462
|
-
|
|
463
|
-
|
|
528
|
+
function getAge(birthdate) {
|
|
529
|
+
const today2 = /* @__PURE__ */ new Date();
|
|
530
|
+
let age = today2.getFullYear() - birthdate.getFullYear();
|
|
531
|
+
const monthDiff = today2.getMonth() - birthdate.getMonth();
|
|
532
|
+
if (monthDiff < 0 || monthDiff === 0 && today2.getDate() < birthdate.getDate()) {
|
|
533
|
+
age--;
|
|
534
|
+
}
|
|
535
|
+
return age;
|
|
536
|
+
}
|
|
537
|
+
function parse(str2, options = {}) {
|
|
538
|
+
if (typeof str2 === "number") return str2;
|
|
539
|
+
const matches = str2.matchAll(/(-?\d+)([a-z]+)/gi);
|
|
464
540
|
let totalMs = 0;
|
|
465
541
|
let found = false;
|
|
466
542
|
for (const [_, value, unit] of matches) {
|
|
@@ -471,20 +547,19 @@ function parse(str3, options = {}) {
|
|
|
471
547
|
found = true;
|
|
472
548
|
}
|
|
473
549
|
}
|
|
474
|
-
if (!found) throw new Error(`parse: Invalid time format: "${
|
|
550
|
+
if (!found) throw new Error(`parse: Invalid time format: "${str2}"`);
|
|
475
551
|
const result = options.unit === "s" ? totalMs / 1e3 : totalMs;
|
|
476
552
|
return options.fromNow ? Date.now() + result : result;
|
|
477
553
|
}
|
|
478
|
-
var date = {
|
|
479
|
-
duration,
|
|
480
|
-
eta,
|
|
481
|
-
parse
|
|
482
|
-
};
|
|
483
554
|
|
|
484
555
|
// src/format.ts
|
|
485
556
|
var format_exports = {};
|
|
486
557
|
__export(format_exports, {
|
|
487
|
-
|
|
558
|
+
compactNumber: () => compactNumber,
|
|
559
|
+
currency: () => currency,
|
|
560
|
+
memory: () => memory,
|
|
561
|
+
number: () => number,
|
|
562
|
+
ordinal: () => ordinal
|
|
488
563
|
});
|
|
489
564
|
function currency(num, options = {}) {
|
|
490
565
|
return new Intl.NumberFormat(options.locale, {
|
|
@@ -525,18 +600,11 @@ function compactNumber(num, locale) {
|
|
|
525
600
|
maximumFractionDigits: 1
|
|
526
601
|
}).format(num);
|
|
527
602
|
}
|
|
528
|
-
var format = {
|
|
529
|
-
currency,
|
|
530
|
-
number,
|
|
531
|
-
memory,
|
|
532
|
-
ordinal,
|
|
533
|
-
compactNumber
|
|
534
|
-
};
|
|
535
603
|
|
|
536
604
|
// src/fs.ts
|
|
537
605
|
var fs_exports = {};
|
|
538
606
|
__export(fs_exports, {
|
|
539
|
-
|
|
607
|
+
readDir: () => readDir
|
|
540
608
|
});
|
|
541
609
|
var import_node_fs = __toESM(require("fs"));
|
|
542
610
|
var import_node_path = require("path");
|
|
@@ -544,8 +612,8 @@ function readDir(path2, options = {}) {
|
|
|
544
612
|
const { recursive = true } = options;
|
|
545
613
|
if (!import_node_fs.default.existsSync(path2)) return [];
|
|
546
614
|
if (!recursive) {
|
|
547
|
-
return import_node_fs.default.readdirSync(path2).filter((
|
|
548
|
-
return import_node_fs.default.statSync((0, import_node_path.join)(path2,
|
|
615
|
+
return import_node_fs.default.readdirSync(path2).filter((fn) => {
|
|
616
|
+
return import_node_fs.default.statSync((0, import_node_path.join)(path2, fn)).isFile();
|
|
549
617
|
});
|
|
550
618
|
}
|
|
551
619
|
const walk = (dir, base = "") => {
|
|
@@ -564,14 +632,17 @@ function readDir(path2, options = {}) {
|
|
|
564
632
|
};
|
|
565
633
|
return walk(path2);
|
|
566
634
|
}
|
|
567
|
-
var fs = {
|
|
568
|
-
readDir
|
|
569
|
-
};
|
|
570
635
|
|
|
571
636
|
// src/is.ts
|
|
572
637
|
var is_exports = {};
|
|
573
638
|
__export(is_exports, {
|
|
574
|
-
|
|
639
|
+
defined: () => defined,
|
|
640
|
+
empty: () => empty,
|
|
641
|
+
inRange: () => inRange,
|
|
642
|
+
object: () => object,
|
|
643
|
+
sorted: () => sorted,
|
|
644
|
+
string: () => string,
|
|
645
|
+
today: () => today
|
|
575
646
|
});
|
|
576
647
|
function defined(val) {
|
|
577
648
|
return val !== void 0 && val !== null;
|
|
@@ -591,9 +662,9 @@ function inRange(num, a, b) {
|
|
|
591
662
|
function object(val) {
|
|
592
663
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
593
664
|
}
|
|
594
|
-
function sorted(
|
|
595
|
-
for (let i = 0; i <
|
|
596
|
-
const comp = comparator ? comparator(
|
|
665
|
+
function sorted(arr, comparator) {
|
|
666
|
+
for (let i = 0; i < arr.length - 1; i++) {
|
|
667
|
+
const comp = comparator ? comparator(arr[i], arr[i + 1]) : arr[i] > arr[i + 1] ? 1 : -1;
|
|
597
668
|
if (comp > 0) return false;
|
|
598
669
|
}
|
|
599
670
|
return true;
|
|
@@ -601,25 +672,24 @@ function sorted(arr2, comparator) {
|
|
|
601
672
|
function string(val) {
|
|
602
673
|
return typeof val === "string";
|
|
603
674
|
}
|
|
604
|
-
function today(
|
|
605
|
-
const d =
|
|
675
|
+
function today(date) {
|
|
676
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
606
677
|
const today2 = /* @__PURE__ */ new Date();
|
|
607
678
|
return d.getDate() === today2.getDate() && d.getMonth() === today2.getMonth() && d.getFullYear() === today2.getFullYear();
|
|
608
679
|
}
|
|
609
|
-
var is = {
|
|
610
|
-
defined,
|
|
611
|
-
empty,
|
|
612
|
-
inRange,
|
|
613
|
-
object,
|
|
614
|
-
sorted,
|
|
615
|
-
string,
|
|
616
|
-
today
|
|
617
|
-
};
|
|
618
680
|
|
|
619
681
|
// src/math.ts
|
|
620
682
|
var math_exports = {};
|
|
621
683
|
__export(math_exports, {
|
|
622
|
-
|
|
684
|
+
clamp: () => clamp,
|
|
685
|
+
invLerp: () => invLerp,
|
|
686
|
+
lerp: () => lerp,
|
|
687
|
+
ms: () => ms,
|
|
688
|
+
percent: () => percent,
|
|
689
|
+
remap: () => remap,
|
|
690
|
+
secs: () => secs,
|
|
691
|
+
sum: () => sum,
|
|
692
|
+
wrap: () => wrap
|
|
623
693
|
});
|
|
624
694
|
function clamp(num, a, b) {
|
|
625
695
|
let min = b !== void 0 ? a : 0;
|
|
@@ -657,26 +727,24 @@ function sum(array, selector) {
|
|
|
657
727
|
return (isNaN(b) ? 0 : b) < 0 ? a - -b : a + (b || 0);
|
|
658
728
|
}, 0);
|
|
659
729
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
lerp,
|
|
664
|
-
ms,
|
|
665
|
-
percent,
|
|
666
|
-
remap,
|
|
667
|
-
secs,
|
|
668
|
-
sum
|
|
669
|
-
};
|
|
730
|
+
function wrap(num, max) {
|
|
731
|
+
return (num % max + max) % max;
|
|
732
|
+
}
|
|
670
733
|
|
|
671
734
|
// src/obj.ts
|
|
672
735
|
var obj_exports = {};
|
|
673
736
|
__export(obj_exports, {
|
|
674
|
-
|
|
737
|
+
get: () => get,
|
|
738
|
+
has: () => has,
|
|
739
|
+
merge: () => merge,
|
|
740
|
+
omit: () => omit,
|
|
741
|
+
pick: () => pick,
|
|
742
|
+
set: () => set
|
|
675
743
|
});
|
|
676
|
-
function get(
|
|
677
|
-
if (!
|
|
744
|
+
function get(obj, path2, defaultValue) {
|
|
745
|
+
if (!obj) throw new Error("get: Target object is null or undefined");
|
|
678
746
|
const parts = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
679
|
-
let current =
|
|
747
|
+
let current = obj;
|
|
680
748
|
const trace = [];
|
|
681
749
|
for (const part of parts) {
|
|
682
750
|
trace.push(part);
|
|
@@ -692,10 +760,10 @@ function get(obj2, path2, defaultValue) {
|
|
|
692
760
|
}
|
|
693
761
|
return current;
|
|
694
762
|
}
|
|
695
|
-
function has(
|
|
696
|
-
if (!
|
|
763
|
+
function has(obj, path2) {
|
|
764
|
+
if (!obj || !path2) return false;
|
|
697
765
|
const parts = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
698
|
-
let current =
|
|
766
|
+
let current = obj;
|
|
699
767
|
for (let i = 0; i < parts.length; i++) {
|
|
700
768
|
const part = parts[i];
|
|
701
769
|
if (current === null || typeof current !== "object") {
|
|
@@ -708,9 +776,9 @@ function has(obj2, path2) {
|
|
|
708
776
|
}
|
|
709
777
|
return true;
|
|
710
778
|
}
|
|
711
|
-
function set(
|
|
779
|
+
function set(obj, path2, value) {
|
|
712
780
|
const parts = path2.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
713
|
-
let current =
|
|
781
|
+
let current = obj;
|
|
714
782
|
for (let i = 0; i < parts.length; i++) {
|
|
715
783
|
const part = parts[i];
|
|
716
784
|
const isLast = i === parts.length - 1;
|
|
@@ -742,58 +810,53 @@ function merge(target, ...sources) {
|
|
|
742
810
|
}
|
|
743
811
|
return target;
|
|
744
812
|
}
|
|
745
|
-
function pick(
|
|
813
|
+
function pick(obj, keys) {
|
|
746
814
|
const result = {};
|
|
747
815
|
for (const key of keys) {
|
|
748
|
-
if (key in
|
|
749
|
-
result[key] =
|
|
816
|
+
if (key in obj) {
|
|
817
|
+
result[key] = obj[key];
|
|
750
818
|
}
|
|
751
819
|
}
|
|
752
820
|
return result;
|
|
753
821
|
}
|
|
754
|
-
function omit(
|
|
755
|
-
const result = { ...
|
|
822
|
+
function omit(obj, keys) {
|
|
823
|
+
const result = { ...obj };
|
|
756
824
|
for (const key of keys) {
|
|
757
825
|
delete result[key];
|
|
758
826
|
}
|
|
759
827
|
return result;
|
|
760
828
|
}
|
|
761
|
-
var obj = {
|
|
762
|
-
get,
|
|
763
|
-
has,
|
|
764
|
-
set,
|
|
765
|
-
merge,
|
|
766
|
-
pick,
|
|
767
|
-
omit
|
|
768
|
-
};
|
|
769
829
|
|
|
770
830
|
// src/str.ts
|
|
771
831
|
var str_exports = {};
|
|
772
832
|
__export(str_exports, {
|
|
773
|
-
|
|
833
|
+
escapeRegex: () => escapeRegex,
|
|
834
|
+
getFlag: () => getFlag,
|
|
835
|
+
hasFlag: () => hasFlag,
|
|
836
|
+
toTitleCase: () => toTitleCase
|
|
774
837
|
});
|
|
775
|
-
function escapeRegex(
|
|
776
|
-
return
|
|
838
|
+
function escapeRegex(str2) {
|
|
839
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
777
840
|
}
|
|
778
|
-
function getFlag(
|
|
841
|
+
function getFlag(str2, flag, length) {
|
|
779
842
|
const regex = flag instanceof RegExp ? flag : new RegExp(`${escapeRegex(flag)}\\b`, "g");
|
|
780
|
-
const match = regex.exec(
|
|
843
|
+
const match = regex.exec(str2);
|
|
781
844
|
if (!match) return null;
|
|
782
845
|
const startIndex = match.index + match[0].length;
|
|
783
|
-
let result =
|
|
846
|
+
let result = str2.slice(startIndex).trimStart();
|
|
784
847
|
if (length !== void 0) {
|
|
785
848
|
return result.split(/\s+/).slice(0, length).join(" ");
|
|
786
849
|
}
|
|
787
850
|
return result || null;
|
|
788
851
|
}
|
|
789
|
-
function hasFlag(
|
|
790
|
-
if (flag instanceof RegExp) return flag.test(
|
|
852
|
+
function hasFlag(str2, flag) {
|
|
853
|
+
if (flag instanceof RegExp) return flag.test(str2);
|
|
791
854
|
const pattern = new RegExp(`${escapeRegex(flag)}\\b`);
|
|
792
|
-
return pattern.test(
|
|
855
|
+
return pattern.test(str2);
|
|
793
856
|
}
|
|
794
|
-
function toTitleCase(
|
|
857
|
+
function toTitleCase(str2, smart = true) {
|
|
795
858
|
const minorWords = /^(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v\.?|via)$/i;
|
|
796
|
-
return
|
|
859
|
+
return str2.replace(/\w\S*/g, (txt, index2) => {
|
|
797
860
|
if (smart && index2 !== 0 && minorWords.test(txt)) {
|
|
798
861
|
return txt.toLowerCase();
|
|
799
862
|
}
|
|
@@ -803,19 +866,14 @@ function toTitleCase(str3, smart = true) {
|
|
|
803
866
|
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
804
867
|
});
|
|
805
868
|
}
|
|
806
|
-
var str2 = {
|
|
807
|
-
escapeRegex,
|
|
808
|
-
getFlag,
|
|
809
|
-
hasFlag,
|
|
810
|
-
toTitleCase
|
|
811
|
-
};
|
|
812
869
|
|
|
813
870
|
// src/timing.ts
|
|
814
871
|
var timing_exports = {};
|
|
815
872
|
__export(timing_exports, {
|
|
816
|
-
|
|
873
|
+
debounce: () => debounce,
|
|
874
|
+
throttle: () => throttle
|
|
817
875
|
});
|
|
818
|
-
function debounce(
|
|
876
|
+
function debounce(fn, wait2, options = {}) {
|
|
819
877
|
let timeoutId;
|
|
820
878
|
const leading = options.immediate ?? false;
|
|
821
879
|
const debounced = function(...args) {
|
|
@@ -823,9 +881,9 @@ function debounce(fn2, wait2, options = {}) {
|
|
|
823
881
|
if (timeoutId) clearTimeout(timeoutId);
|
|
824
882
|
timeoutId = setTimeout(() => {
|
|
825
883
|
timeoutId = void 0;
|
|
826
|
-
if (!leading)
|
|
884
|
+
if (!leading) fn.apply(this, args);
|
|
827
885
|
}, wait2);
|
|
828
|
-
if (callNow)
|
|
886
|
+
if (callNow) fn.apply(this, args);
|
|
829
887
|
};
|
|
830
888
|
debounced.cancel = () => {
|
|
831
889
|
if (timeoutId) {
|
|
@@ -835,25 +893,21 @@ function debounce(fn2, wait2, options = {}) {
|
|
|
835
893
|
};
|
|
836
894
|
return debounced;
|
|
837
895
|
}
|
|
838
|
-
function throttle(
|
|
896
|
+
function throttle(fn, limit) {
|
|
839
897
|
let inThrottle = false;
|
|
840
898
|
return function(...args) {
|
|
841
899
|
if (!inThrottle) {
|
|
842
|
-
|
|
900
|
+
fn.apply(this, args);
|
|
843
901
|
inThrottle = true;
|
|
844
902
|
setTimeout(() => inThrottle = false, limit);
|
|
845
903
|
}
|
|
846
904
|
};
|
|
847
905
|
}
|
|
848
|
-
var timing = {
|
|
849
|
-
debounce,
|
|
850
|
-
throttle
|
|
851
|
-
};
|
|
852
906
|
|
|
853
907
|
// src/to.ts
|
|
854
908
|
var to_exports = {};
|
|
855
909
|
__export(to_exports, {
|
|
856
|
-
|
|
910
|
+
record: () => record
|
|
857
911
|
});
|
|
858
912
|
function record(array, callback) {
|
|
859
913
|
const result = {};
|
|
@@ -871,13 +925,10 @@ function record(array, callback) {
|
|
|
871
925
|
}
|
|
872
926
|
return result;
|
|
873
927
|
}
|
|
874
|
-
var to = {
|
|
875
|
-
record
|
|
876
|
-
};
|
|
877
928
|
|
|
878
929
|
// src/Pipe.ts
|
|
879
930
|
function Pipe(value, ...fns) {
|
|
880
|
-
return fns.reduce((acc,
|
|
931
|
+
return fns.reduce((acc, fn) => fn(acc), value);
|
|
881
932
|
}
|
|
882
933
|
|
|
883
934
|
// src/Storage.ts
|
|
@@ -1055,9 +1106,9 @@ var Loop = class extends TypedEmitterBase {
|
|
|
1055
1106
|
* @param delay The delay between runs in milliseconds.
|
|
1056
1107
|
* @param immediate Whether to start the loop immediately. [default: true]
|
|
1057
1108
|
*/
|
|
1058
|
-
constructor(
|
|
1109
|
+
constructor(fn, delay, immediate = true) {
|
|
1059
1110
|
super();
|
|
1060
|
-
this.fn =
|
|
1111
|
+
this.fn = fn;
|
|
1061
1112
|
this.delay = delay;
|
|
1062
1113
|
if (immediate) this.start();
|
|
1063
1114
|
}
|
|
@@ -1114,19 +1165,19 @@ var Loop = class extends TypedEmitterBase {
|
|
|
1114
1165
|
|
|
1115
1166
|
// src/index.ts
|
|
1116
1167
|
var qznt = {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1168
|
+
arr: arr_exports,
|
|
1169
|
+
async: async_exports,
|
|
1170
|
+
fn: fn_exports,
|
|
1171
|
+
date: date_exports,
|
|
1172
|
+
format: format_exports,
|
|
1173
|
+
fs: fs_exports,
|
|
1174
|
+
is: is_exports,
|
|
1175
|
+
math: math_exports,
|
|
1176
|
+
obj: obj_exports,
|
|
1177
|
+
timing: timing_exports,
|
|
1178
|
+
rnd: rnd_exports,
|
|
1179
|
+
str: str_exports,
|
|
1180
|
+
to: to_exports,
|
|
1130
1181
|
Pipe,
|
|
1131
1182
|
Storage,
|
|
1132
1183
|
Cache,
|
|
@@ -1141,18 +1192,66 @@ var index_default = qznt;
|
|
|
1141
1192
|
Loop,
|
|
1142
1193
|
Pipe,
|
|
1143
1194
|
Storage,
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1195
|
+
chance,
|
|
1196
|
+
choice,
|
|
1197
|
+
chunk,
|
|
1198
|
+
chunkAdj,
|
|
1199
|
+
clamp,
|
|
1200
|
+
cluster,
|
|
1201
|
+
compact,
|
|
1202
|
+
compactNumber,
|
|
1203
|
+
currency,
|
|
1204
|
+
debounce,
|
|
1205
|
+
defined,
|
|
1206
|
+
duration,
|
|
1207
|
+
empty,
|
|
1208
|
+
escapeRegex,
|
|
1209
|
+
eta,
|
|
1210
|
+
float,
|
|
1211
|
+
forceArray,
|
|
1212
|
+
get,
|
|
1213
|
+
getAge,
|
|
1214
|
+
getFlag,
|
|
1215
|
+
has,
|
|
1216
|
+
hasFlag,
|
|
1217
|
+
inRange,
|
|
1218
|
+
index,
|
|
1219
|
+
int,
|
|
1220
|
+
invLerp,
|
|
1221
|
+
lerp,
|
|
1222
|
+
memoize,
|
|
1223
|
+
memory,
|
|
1224
|
+
merge,
|
|
1225
|
+
ms,
|
|
1226
|
+
number,
|
|
1227
|
+
object,
|
|
1228
|
+
omit,
|
|
1229
|
+
ordinal,
|
|
1230
|
+
parse,
|
|
1231
|
+
percent,
|
|
1232
|
+
pick,
|
|
1233
|
+
prng,
|
|
1234
|
+
readDir,
|
|
1235
|
+
record,
|
|
1236
|
+
remap,
|
|
1237
|
+
retry,
|
|
1238
|
+
sampler,
|
|
1239
|
+
search,
|
|
1240
|
+
secs,
|
|
1241
|
+
seqMap,
|
|
1242
|
+
set,
|
|
1243
|
+
shuffle,
|
|
1244
|
+
sortBy,
|
|
1245
|
+
sorted,
|
|
1154
1246
|
str,
|
|
1155
|
-
|
|
1156
|
-
|
|
1247
|
+
string,
|
|
1248
|
+
sum,
|
|
1249
|
+
throttle,
|
|
1250
|
+
toTitleCase,
|
|
1251
|
+
today,
|
|
1252
|
+
unique,
|
|
1253
|
+
wait,
|
|
1254
|
+
weighted,
|
|
1255
|
+
wrap
|
|
1157
1256
|
});
|
|
1158
1257
|
//# sourceMappingURL=index.cjs.map
|