qznt 1.0.0 → 1.0.2
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 +1 -0
- package/dist/index.cjs +86 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +45 -32
- package/dist/index.d.ts +45 -32
- package/dist/index.js +82 -53
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -178,6 +178,20 @@ declare const date: {
|
|
|
178
178
|
parse: typeof parse;
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
+
interface ReadDirOptions {
|
|
182
|
+
/** Whether to scan subdirectories. [default: true] */
|
|
183
|
+
recursive?: boolean;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Recursively (or shallowly) scans a directory and returns an array of relative file paths.
|
|
187
|
+
* @param path The path to the directory.
|
|
188
|
+
* @param options Options for the readDir function.
|
|
189
|
+
*/
|
|
190
|
+
declare function readDir(path: string, options?: ReadDirOptions): string[];
|
|
191
|
+
declare const fs: {
|
|
192
|
+
readDir: typeof readDir;
|
|
193
|
+
};
|
|
194
|
+
|
|
181
195
|
type AlphaCasing = "lower" | "upper" | "mixed";
|
|
182
196
|
interface RndStrOptions {
|
|
183
197
|
casing?: AlphaCasing;
|
|
@@ -299,15 +313,9 @@ declare function debounce<T extends (...args: any[]) => any>(fn: T, wait: number
|
|
|
299
313
|
* window.addEventListener('scroll', handleScroll);
|
|
300
314
|
*/
|
|
301
315
|
declare function throttle<T extends (...args: any[]) => any>(fn: T, limit: number): (...args: Parameters<T>) => void;
|
|
302
|
-
/**
|
|
303
|
-
* Returns a promise that resolves after the given number of milliseconds.
|
|
304
|
-
* @param ms The time to wait in milliseconds.
|
|
305
|
-
*/
|
|
306
|
-
declare function wait(ms: number): Promise<boolean>;
|
|
307
316
|
declare const timing: {
|
|
308
317
|
debounce: typeof debounce;
|
|
309
318
|
throttle: typeof throttle;
|
|
310
|
-
wait: typeof wait;
|
|
311
319
|
};
|
|
312
320
|
|
|
313
321
|
type ToRecordContext<T, V> = {
|
|
@@ -446,8 +454,14 @@ declare class Loop<T = any> extends TypedEmitterBase<T> {
|
|
|
446
454
|
* @param delay Initial delay in milliseconds. [default: 500ms]
|
|
447
455
|
*/
|
|
448
456
|
declare function retry<T>(fn: () => Promise<T>, retries?: number, delay?: number): Promise<T>;
|
|
457
|
+
/**
|
|
458
|
+
* Returns a promise that resolves after the given number of milliseconds.
|
|
459
|
+
* @param ms The time to wait in milliseconds.
|
|
460
|
+
*/
|
|
461
|
+
declare function wait(ms: number): Promise<boolean>;
|
|
449
462
|
declare const async: {
|
|
450
463
|
retry: typeof retry;
|
|
464
|
+
wait: typeof wait;
|
|
451
465
|
};
|
|
452
466
|
|
|
453
467
|
/**
|
|
@@ -542,6 +556,14 @@ declare const is: {
|
|
|
542
556
|
today: typeof today;
|
|
543
557
|
};
|
|
544
558
|
|
|
559
|
+
/**
|
|
560
|
+
* Clamps a number within a specified range.
|
|
561
|
+
* @param num The number to check.
|
|
562
|
+
* @param min The minimum or maximum value of the range.
|
|
563
|
+
* @param max The maximum value of the range (optional).
|
|
564
|
+
*/
|
|
565
|
+
declare function clamp(num: number, max: number): number;
|
|
566
|
+
declare function clamp(num: number, min: number, max: number): number;
|
|
545
567
|
/**
|
|
546
568
|
* Calculates the interpolation factor (0-1) of a value between two points.
|
|
547
569
|
* @param start - The starting value (0%).
|
|
@@ -599,8 +621,9 @@ declare function secs(num: number): number;
|
|
|
599
621
|
* @param selector Function that selects the item's weight.
|
|
600
622
|
* @param ignoreNaN If true, NaN values will not throw an error.
|
|
601
623
|
*/
|
|
602
|
-
declare function sum<T>(array: T[], selector
|
|
624
|
+
declare function sum<T>(array: T[], selector?: (item: T) => number): number;
|
|
603
625
|
declare const math: {
|
|
626
|
+
clamp: typeof clamp;
|
|
604
627
|
invLerp: typeof invLerp;
|
|
605
628
|
lerp: typeof lerp;
|
|
606
629
|
ms: typeof ms;
|
|
@@ -610,18 +633,6 @@ declare const math: {
|
|
|
610
633
|
sum: typeof sum;
|
|
611
634
|
};
|
|
612
635
|
|
|
613
|
-
/**
|
|
614
|
-
* Clamps a number within a specified range.
|
|
615
|
-
* @param num The number to check.
|
|
616
|
-
* @param min The minimum or maximum value of the range.
|
|
617
|
-
* @param max The maximum value of the range (optional).
|
|
618
|
-
*/
|
|
619
|
-
declare function clamp(num: number, max: number): number;
|
|
620
|
-
declare function clamp(num: number, min: number, max: number): number;
|
|
621
|
-
declare const num: {
|
|
622
|
-
clamp: typeof clamp;
|
|
623
|
-
};
|
|
624
|
-
|
|
625
636
|
/**
|
|
626
637
|
* Retrieves a nested property.
|
|
627
638
|
* @param obj The object to process.
|
|
@@ -702,7 +713,7 @@ declare const str: {
|
|
|
702
713
|
toTitleCase: typeof toTitleCase;
|
|
703
714
|
};
|
|
704
715
|
|
|
705
|
-
declare const
|
|
716
|
+
declare const qznt: {
|
|
706
717
|
Pipe: typeof Pipe;
|
|
707
718
|
Storage: typeof Storage;
|
|
708
719
|
Cache: typeof Cache;
|
|
@@ -737,7 +748,6 @@ declare const $: {
|
|
|
737
748
|
immediate?: boolean;
|
|
738
749
|
}) => DebouncedFunction<T>;
|
|
739
750
|
throttle: <T extends (...args: any[]) => any>(fn: T, limit: number) => (...args: Parameters<T>) => void;
|
|
740
|
-
wait: (ms: number) => Promise<boolean>;
|
|
741
751
|
};
|
|
742
752
|
obj: {
|
|
743
753
|
get: <T = any>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
|
|
@@ -752,20 +762,18 @@ declare const $: {
|
|
|
752
762
|
pick: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
753
763
|
omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
754
764
|
};
|
|
755
|
-
|
|
765
|
+
math: {
|
|
756
766
|
clamp: {
|
|
757
767
|
(num: number, max: number): number;
|
|
758
768
|
(num: number, min: number, max: number): number;
|
|
759
769
|
};
|
|
760
|
-
};
|
|
761
|
-
math: {
|
|
762
770
|
invLerp: (start: number, end: number, value: number) => number;
|
|
763
771
|
lerp: (start: number, end: number, t: number) => number;
|
|
764
772
|
ms: (num: number) => number;
|
|
765
773
|
percent: (a: number, b: number, round?: boolean) => number;
|
|
766
774
|
remap: (value: number, inMin: number, inMax: number, outMin: number, outMax: number) => number;
|
|
767
775
|
secs: (num: number) => number;
|
|
768
|
-
sum: <T>(array: T[], selector
|
|
776
|
+
sum: <T>(array: T[], selector?: (item: T) => number) => number;
|
|
769
777
|
};
|
|
770
778
|
is: {
|
|
771
779
|
defined: <T>(val: T | undefined | null) => val is T;
|
|
@@ -779,6 +787,9 @@ declare const $: {
|
|
|
779
787
|
string: (val: unknown) => val is string;
|
|
780
788
|
today: (date: number | Date) => boolean;
|
|
781
789
|
};
|
|
790
|
+
fs: {
|
|
791
|
+
readDir: (path: string, options?: ReadDirOptions) => string[];
|
|
792
|
+
};
|
|
782
793
|
format: {
|
|
783
794
|
currency: (num: number, options?: {
|
|
784
795
|
currency?: string;
|
|
@@ -805,6 +816,7 @@ declare const $: {
|
|
|
805
816
|
};
|
|
806
817
|
async: {
|
|
807
818
|
retry: <T>(fn: () => Promise<T>, retries?: number, delay?: number) => Promise<T>;
|
|
819
|
+
wait: (ms: number) => Promise<boolean>;
|
|
808
820
|
};
|
|
809
821
|
arr: {
|
|
810
822
|
chunk: <T>(array: ReadonlyArray<T>, size: number) => T[][];
|
|
@@ -825,7 +837,7 @@ declare const $: {
|
|
|
825
837
|
unique: <T>(array: T[], key: (item: T) => any) => T[];
|
|
826
838
|
};
|
|
827
839
|
};
|
|
828
|
-
declare const
|
|
840
|
+
declare const $: {
|
|
829
841
|
Pipe: typeof Pipe;
|
|
830
842
|
Storage: typeof Storage;
|
|
831
843
|
Cache: typeof Cache;
|
|
@@ -860,7 +872,6 @@ declare const qznt: {
|
|
|
860
872
|
immediate?: boolean;
|
|
861
873
|
}) => DebouncedFunction<T>;
|
|
862
874
|
throttle: <T extends (...args: any[]) => any>(fn: T, limit: number) => (...args: Parameters<T>) => void;
|
|
863
|
-
wait: (ms: number) => Promise<boolean>;
|
|
864
875
|
};
|
|
865
876
|
obj: {
|
|
866
877
|
get: <T = any>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
|
|
@@ -875,20 +886,18 @@ declare const qznt: {
|
|
|
875
886
|
pick: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
876
887
|
omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
877
888
|
};
|
|
878
|
-
|
|
889
|
+
math: {
|
|
879
890
|
clamp: {
|
|
880
891
|
(num: number, max: number): number;
|
|
881
892
|
(num: number, min: number, max: number): number;
|
|
882
893
|
};
|
|
883
|
-
};
|
|
884
|
-
math: {
|
|
885
894
|
invLerp: (start: number, end: number, value: number) => number;
|
|
886
895
|
lerp: (start: number, end: number, t: number) => number;
|
|
887
896
|
ms: (num: number) => number;
|
|
888
897
|
percent: (a: number, b: number, round?: boolean) => number;
|
|
889
898
|
remap: (value: number, inMin: number, inMax: number, outMin: number, outMax: number) => number;
|
|
890
899
|
secs: (num: number) => number;
|
|
891
|
-
sum: <T>(array: T[], selector
|
|
900
|
+
sum: <T>(array: T[], selector?: (item: T) => number) => number;
|
|
892
901
|
};
|
|
893
902
|
is: {
|
|
894
903
|
defined: <T>(val: T | undefined | null) => val is T;
|
|
@@ -902,6 +911,9 @@ declare const qznt: {
|
|
|
902
911
|
string: (val: unknown) => val is string;
|
|
903
912
|
today: (date: number | Date) => boolean;
|
|
904
913
|
};
|
|
914
|
+
fs: {
|
|
915
|
+
readDir: (path: string, options?: ReadDirOptions) => string[];
|
|
916
|
+
};
|
|
905
917
|
format: {
|
|
906
918
|
currency: (num: number, options?: {
|
|
907
919
|
currency?: string;
|
|
@@ -928,6 +940,7 @@ declare const qznt: {
|
|
|
928
940
|
};
|
|
929
941
|
async: {
|
|
930
942
|
retry: <T>(fn: () => Promise<T>, retries?: number, delay?: number) => Promise<T>;
|
|
943
|
+
wait: (ms: number) => Promise<boolean>;
|
|
931
944
|
};
|
|
932
945
|
arr: {
|
|
933
946
|
chunk: <T>(array: ReadonlyArray<T>, size: number) => T[][];
|
|
@@ -949,4 +962,4 @@ declare const qznt: {
|
|
|
949
962
|
};
|
|
950
963
|
};
|
|
951
964
|
|
|
952
|
-
export { type AlphaCasing, type AnyFunc, Cache, type DateOptions, type DebouncedFunction, type DeepPartial, Loop, type MemoizedFunction, type ParseOptions, Pipe, type RndStrOptions, type SequentialMapContext, Storage, type ToRecordContext, type TypedEmitter, arr, async, date,
|
|
965
|
+
export { $, type AlphaCasing, type AnyFunc, Cache, type DateOptions, type DebouncedFunction, type DeepPartial, Loop, type MemoizedFunction, type ParseOptions, Pipe, type ReadDirOptions, type RndStrOptions, type SequentialMapContext, Storage, type ToRecordContext, type TypedEmitter, arr, async, date, qznt as default, fn, format, fs, is, math, obj, rnd, str, timing, to };
|
package/dist/index.js
CHANGED
|
@@ -286,8 +286,16 @@ async function retry(fn2, retries = 3, delay = 500) {
|
|
|
286
286
|
return await new Promise((resolve) => setTimeout(resolve, delay + jitter));
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
+
function wait(ms2) {
|
|
290
|
+
return new Promise(
|
|
291
|
+
(resolve) => setTimeout(() => {
|
|
292
|
+
resolve(true);
|
|
293
|
+
}, ms2)
|
|
294
|
+
);
|
|
295
|
+
}
|
|
289
296
|
var async = {
|
|
290
|
-
retry
|
|
297
|
+
retry,
|
|
298
|
+
wait
|
|
291
299
|
};
|
|
292
300
|
|
|
293
301
|
// src/fn.ts
|
|
@@ -408,17 +416,17 @@ var format_exports = {};
|
|
|
408
416
|
__export(format_exports, {
|
|
409
417
|
format: () => format
|
|
410
418
|
});
|
|
411
|
-
function currency(
|
|
419
|
+
function currency(num, options = {}) {
|
|
412
420
|
return new Intl.NumberFormat(options.locale, {
|
|
413
421
|
style: "currency",
|
|
414
422
|
currency: options.currency
|
|
415
|
-
}).format(
|
|
423
|
+
}).format(num);
|
|
416
424
|
}
|
|
417
|
-
function number(
|
|
425
|
+
function number(num, options = {}) {
|
|
418
426
|
return new Intl.NumberFormat(options.locale, {
|
|
419
427
|
minimumFractionDigits: options.precision,
|
|
420
428
|
maximumFractionDigits: options.precision
|
|
421
|
-
}).format(
|
|
429
|
+
}).format(num);
|
|
422
430
|
}
|
|
423
431
|
function memory(bytes, decimals = 1, units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]) {
|
|
424
432
|
if (bytes <= 0) return `0 ${units[0]}`;
|
|
@@ -426,8 +434,8 @@ function memory(bytes, decimals = 1, units = ["B", "KB", "MB", "GB", "TB", "PB",
|
|
|
426
434
|
const val = bytes / Math.pow(1024, i);
|
|
427
435
|
return `${val.toFixed(i === 0 ? 0 : decimals)} ${units[i]}`;
|
|
428
436
|
}
|
|
429
|
-
function ordinal(
|
|
430
|
-
const _num = Number(
|
|
437
|
+
function ordinal(num, locale) {
|
|
438
|
+
const _num = Number(num);
|
|
431
439
|
if (isNaN(_num)) throw new TypeError("Invalid input");
|
|
432
440
|
const pr = new Intl.PluralRules(locale, { type: "ordinal" });
|
|
433
441
|
const rule = pr.select(_num);
|
|
@@ -440,12 +448,12 @@ function ordinal(num2, locale) {
|
|
|
440
448
|
const suffix = suffixes[rule] || "th";
|
|
441
449
|
return _num.toLocaleString(locale) + suffix;
|
|
442
450
|
}
|
|
443
|
-
function compactNumber(
|
|
451
|
+
function compactNumber(num, locale) {
|
|
444
452
|
return new Intl.NumberFormat(locale, {
|
|
445
453
|
notation: "compact",
|
|
446
454
|
compactDisplay: "short",
|
|
447
455
|
maximumFractionDigits: 1
|
|
448
|
-
}).format(
|
|
456
|
+
}).format(num);
|
|
449
457
|
}
|
|
450
458
|
var format = {
|
|
451
459
|
currency,
|
|
@@ -455,6 +463,41 @@ var format = {
|
|
|
455
463
|
compactNumber
|
|
456
464
|
};
|
|
457
465
|
|
|
466
|
+
// src/fs.ts
|
|
467
|
+
var fs_exports = {};
|
|
468
|
+
__export(fs_exports, {
|
|
469
|
+
fs: () => fs
|
|
470
|
+
});
|
|
471
|
+
import _fs from "fs";
|
|
472
|
+
import { join } from "path";
|
|
473
|
+
function readDir(path2, options = {}) {
|
|
474
|
+
const { recursive = true } = options;
|
|
475
|
+
if (!_fs.existsSync(path2)) return [];
|
|
476
|
+
if (!recursive) {
|
|
477
|
+
return _fs.readdirSync(path2).filter((fn2) => {
|
|
478
|
+
return _fs.statSync(join(path2, fn2)).isFile();
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
const walk = (dir, base = "") => {
|
|
482
|
+
const results = [];
|
|
483
|
+
const entries = _fs.readdirSync(dir, { withFileTypes: true });
|
|
484
|
+
for (const entry of entries) {
|
|
485
|
+
const relativePath = base ? join(base, entry.name) : entry.name;
|
|
486
|
+
const fullPath = join(dir, entry.name);
|
|
487
|
+
if (entry.isDirectory()) {
|
|
488
|
+
results.push(...walk(fullPath, relativePath));
|
|
489
|
+
} else if (entry.isFile()) {
|
|
490
|
+
results.push(relativePath);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return results;
|
|
494
|
+
};
|
|
495
|
+
return walk(path2);
|
|
496
|
+
}
|
|
497
|
+
var fs = {
|
|
498
|
+
readDir
|
|
499
|
+
};
|
|
500
|
+
|
|
458
501
|
// src/is.ts
|
|
459
502
|
var is_exports = {};
|
|
460
503
|
__export(is_exports, {
|
|
@@ -469,11 +512,11 @@ function empty(val) {
|
|
|
469
512
|
if (object(val)) return Object.keys(val).length === 0;
|
|
470
513
|
return false;
|
|
471
514
|
}
|
|
472
|
-
function inRange(
|
|
515
|
+
function inRange(num, a, b) {
|
|
473
516
|
let min = b !== void 0 ? a : 0;
|
|
474
517
|
let max = b !== void 0 ? b : a;
|
|
475
518
|
if (min > max) [min, max] = [max, min];
|
|
476
|
-
return
|
|
519
|
+
return num >= min && num <= max;
|
|
477
520
|
}
|
|
478
521
|
function object(val) {
|
|
479
522
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
@@ -508,6 +551,12 @@ var math_exports = {};
|
|
|
508
551
|
__export(math_exports, {
|
|
509
552
|
math: () => math
|
|
510
553
|
});
|
|
554
|
+
function clamp(num, a, b) {
|
|
555
|
+
let min = b !== void 0 ? a : 0;
|
|
556
|
+
let max = b !== void 0 ? b : a;
|
|
557
|
+
if (min > max) [min, max] = [max, min];
|
|
558
|
+
return Math.max(min, Math.min(num, max));
|
|
559
|
+
}
|
|
511
560
|
function invLerp(start, end, value) {
|
|
512
561
|
if (start === end) return 0;
|
|
513
562
|
return (value - start) / (end - start);
|
|
@@ -515,8 +564,8 @@ function invLerp(start, end, value) {
|
|
|
515
564
|
function lerp(start, end, t) {
|
|
516
565
|
return start + (end - start) * t;
|
|
517
566
|
}
|
|
518
|
-
function ms(
|
|
519
|
-
return Math.floor(
|
|
567
|
+
function ms(num) {
|
|
568
|
+
return Math.floor(num * 1e3);
|
|
520
569
|
}
|
|
521
570
|
function percent(a, b, round = true) {
|
|
522
571
|
const result = a / b * 100;
|
|
@@ -526,17 +575,20 @@ function remap(value, inMin, inMax, outMin, outMax) {
|
|
|
526
575
|
const t = invLerp(inMin, inMax, value);
|
|
527
576
|
return lerp(outMin, outMax, t);
|
|
528
577
|
}
|
|
529
|
-
function secs(
|
|
530
|
-
return Math.floor(
|
|
578
|
+
function secs(num) {
|
|
579
|
+
return Math.floor(num / 1e3);
|
|
531
580
|
}
|
|
532
|
-
function sum(array, selector
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
581
|
+
function sum(array, selector) {
|
|
582
|
+
const _array = selector ? array.map(selector) : array;
|
|
583
|
+
if (!_array.every((v) => typeof v === "number")) {
|
|
584
|
+
throw new TypeError(`sum: Array must only contain numbers.`);
|
|
585
|
+
}
|
|
586
|
+
return _array.reduce((a, b) => {
|
|
536
587
|
return (isNaN(b) ? 0 : b) < 0 ? a - -b : a + (b || 0);
|
|
537
588
|
}, 0);
|
|
538
589
|
}
|
|
539
590
|
var math = {
|
|
591
|
+
clamp,
|
|
540
592
|
invLerp,
|
|
541
593
|
lerp,
|
|
542
594
|
ms,
|
|
@@ -546,21 +598,6 @@ var math = {
|
|
|
546
598
|
sum
|
|
547
599
|
};
|
|
548
600
|
|
|
549
|
-
// src/num.ts
|
|
550
|
-
var num_exports = {};
|
|
551
|
-
__export(num_exports, {
|
|
552
|
-
num: () => num
|
|
553
|
-
});
|
|
554
|
-
function clamp(num2, a, b) {
|
|
555
|
-
let min = b !== void 0 ? a : 0;
|
|
556
|
-
let max = b !== void 0 ? b : a;
|
|
557
|
-
if (min > max) [min, max] = [max, min];
|
|
558
|
-
return Math.max(min, Math.min(num2, max));
|
|
559
|
-
}
|
|
560
|
-
var num = {
|
|
561
|
-
clamp
|
|
562
|
-
};
|
|
563
|
-
|
|
564
601
|
// src/obj.ts
|
|
565
602
|
var obj_exports = {};
|
|
566
603
|
__export(obj_exports, {
|
|
@@ -738,17 +775,9 @@ function throttle(fn2, limit) {
|
|
|
738
775
|
}
|
|
739
776
|
};
|
|
740
777
|
}
|
|
741
|
-
function wait(ms2) {
|
|
742
|
-
return new Promise(
|
|
743
|
-
(resolve) => setTimeout(() => {
|
|
744
|
-
resolve(true);
|
|
745
|
-
}, ms2)
|
|
746
|
-
);
|
|
747
|
-
}
|
|
748
778
|
var timing = {
|
|
749
779
|
debounce,
|
|
750
|
-
throttle
|
|
751
|
-
wait
|
|
780
|
+
throttle
|
|
752
781
|
};
|
|
753
782
|
|
|
754
783
|
// src/to.ts
|
|
@@ -782,16 +811,16 @@ function Pipe(value, ...fns) {
|
|
|
782
811
|
}
|
|
783
812
|
|
|
784
813
|
// src/Storage.ts
|
|
785
|
-
import
|
|
814
|
+
import fs2 from "fs";
|
|
786
815
|
import path from "path";
|
|
787
816
|
var Storage = class {
|
|
788
817
|
isNode = typeof window === "undefined";
|
|
789
818
|
filePath = null;
|
|
790
819
|
memoryCache = /* @__PURE__ */ new Map();
|
|
791
820
|
loadFromFile() {
|
|
792
|
-
if (this.filePath &&
|
|
821
|
+
if (this.filePath && fs2.existsSync(this.filePath)) {
|
|
793
822
|
try {
|
|
794
|
-
const data = JSON.parse(
|
|
823
|
+
const data = JSON.parse(fs2.readFileSync(this.filePath, "utf-8"));
|
|
795
824
|
Object.entries(data).forEach(([k, v]) => this.memoryCache.set(k, JSON.stringify(v)));
|
|
796
825
|
} catch (err) {
|
|
797
826
|
console.error(`Store: Failed to load file '${this.filePath}'`, err);
|
|
@@ -802,7 +831,7 @@ var Storage = class {
|
|
|
802
831
|
if (this.isNode && this.filePath) {
|
|
803
832
|
const out = {};
|
|
804
833
|
this.memoryCache.forEach((v, k) => out[k] = JSON.parse(v));
|
|
805
|
-
|
|
834
|
+
fs2.writeFileSync(this.filePath, JSON.stringify(out, null, 2));
|
|
806
835
|
}
|
|
807
836
|
}
|
|
808
837
|
/**
|
|
@@ -1014,15 +1043,15 @@ var Loop = class extends TypedEmitterBase {
|
|
|
1014
1043
|
};
|
|
1015
1044
|
|
|
1016
1045
|
// src/index.ts
|
|
1017
|
-
var
|
|
1046
|
+
var qznt = {
|
|
1018
1047
|
...arr_exports,
|
|
1019
1048
|
...async_exports,
|
|
1020
1049
|
...fn_exports,
|
|
1021
1050
|
...date_exports,
|
|
1022
1051
|
...format_exports,
|
|
1052
|
+
...fs_exports,
|
|
1023
1053
|
...is_exports,
|
|
1024
1054
|
...math_exports,
|
|
1025
|
-
...num_exports,
|
|
1026
1055
|
...obj_exports,
|
|
1027
1056
|
...timing_exports,
|
|
1028
1057
|
...rnd_exports,
|
|
@@ -1033,9 +1062,10 @@ var $ = {
|
|
|
1033
1062
|
Cache,
|
|
1034
1063
|
Loop
|
|
1035
1064
|
};
|
|
1036
|
-
var
|
|
1037
|
-
var index_default =
|
|
1065
|
+
var $ = qznt;
|
|
1066
|
+
var index_default = qznt;
|
|
1038
1067
|
export {
|
|
1068
|
+
$,
|
|
1039
1069
|
Cache,
|
|
1040
1070
|
Loop,
|
|
1041
1071
|
Pipe,
|
|
@@ -1046,11 +1076,10 @@ export {
|
|
|
1046
1076
|
index_default as default,
|
|
1047
1077
|
fn,
|
|
1048
1078
|
format,
|
|
1079
|
+
fs,
|
|
1049
1080
|
is,
|
|
1050
1081
|
math,
|
|
1051
|
-
num,
|
|
1052
1082
|
obj,
|
|
1053
|
-
qznt,
|
|
1054
1083
|
rnd,
|
|
1055
1084
|
str2 as str,
|
|
1056
1085
|
timing,
|