qznt 1.0.0 → 1.0.1
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 +36 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +22 -29
- package/dist/index.d.ts +22 -29
- package/dist/index.js +35 -45
- 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.mts
CHANGED
|
@@ -299,15 +299,9 @@ declare function debounce<T extends (...args: any[]) => any>(fn: T, wait: number
|
|
|
299
299
|
* window.addEventListener('scroll', handleScroll);
|
|
300
300
|
*/
|
|
301
301
|
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
302
|
declare const timing: {
|
|
308
303
|
debounce: typeof debounce;
|
|
309
304
|
throttle: typeof throttle;
|
|
310
|
-
wait: typeof wait;
|
|
311
305
|
};
|
|
312
306
|
|
|
313
307
|
type ToRecordContext<T, V> = {
|
|
@@ -446,8 +440,14 @@ declare class Loop<T = any> extends TypedEmitterBase<T> {
|
|
|
446
440
|
* @param delay Initial delay in milliseconds. [default: 500ms]
|
|
447
441
|
*/
|
|
448
442
|
declare function retry<T>(fn: () => Promise<T>, retries?: number, delay?: number): Promise<T>;
|
|
443
|
+
/**
|
|
444
|
+
* Returns a promise that resolves after the given number of milliseconds.
|
|
445
|
+
* @param ms The time to wait in milliseconds.
|
|
446
|
+
*/
|
|
447
|
+
declare function wait(ms: number): Promise<boolean>;
|
|
449
448
|
declare const async: {
|
|
450
449
|
retry: typeof retry;
|
|
450
|
+
wait: typeof wait;
|
|
451
451
|
};
|
|
452
452
|
|
|
453
453
|
/**
|
|
@@ -542,6 +542,14 @@ declare const is: {
|
|
|
542
542
|
today: typeof today;
|
|
543
543
|
};
|
|
544
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Clamps a number within a specified range.
|
|
547
|
+
* @param num The number to check.
|
|
548
|
+
* @param min The minimum or maximum value of the range.
|
|
549
|
+
* @param max The maximum value of the range (optional).
|
|
550
|
+
*/
|
|
551
|
+
declare function clamp(num: number, max: number): number;
|
|
552
|
+
declare function clamp(num: number, min: number, max: number): number;
|
|
545
553
|
/**
|
|
546
554
|
* Calculates the interpolation factor (0-1) of a value between two points.
|
|
547
555
|
* @param start - The starting value (0%).
|
|
@@ -601,6 +609,7 @@ declare function secs(num: number): number;
|
|
|
601
609
|
*/
|
|
602
610
|
declare function sum<T>(array: T[], selector: (item: T) => number, ignoreNaN?: boolean): number;
|
|
603
611
|
declare const math: {
|
|
612
|
+
clamp: typeof clamp;
|
|
604
613
|
invLerp: typeof invLerp;
|
|
605
614
|
lerp: typeof lerp;
|
|
606
615
|
ms: typeof ms;
|
|
@@ -610,18 +619,6 @@ declare const math: {
|
|
|
610
619
|
sum: typeof sum;
|
|
611
620
|
};
|
|
612
621
|
|
|
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
622
|
/**
|
|
626
623
|
* Retrieves a nested property.
|
|
627
624
|
* @param obj The object to process.
|
|
@@ -702,7 +699,7 @@ declare const str: {
|
|
|
702
699
|
toTitleCase: typeof toTitleCase;
|
|
703
700
|
};
|
|
704
701
|
|
|
705
|
-
declare const
|
|
702
|
+
declare const qznt: {
|
|
706
703
|
Pipe: typeof Pipe;
|
|
707
704
|
Storage: typeof Storage;
|
|
708
705
|
Cache: typeof Cache;
|
|
@@ -737,7 +734,6 @@ declare const $: {
|
|
|
737
734
|
immediate?: boolean;
|
|
738
735
|
}) => DebouncedFunction<T>;
|
|
739
736
|
throttle: <T extends (...args: any[]) => any>(fn: T, limit: number) => (...args: Parameters<T>) => void;
|
|
740
|
-
wait: (ms: number) => Promise<boolean>;
|
|
741
737
|
};
|
|
742
738
|
obj: {
|
|
743
739
|
get: <T = any>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
|
|
@@ -752,13 +748,11 @@ declare const $: {
|
|
|
752
748
|
pick: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
753
749
|
omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
754
750
|
};
|
|
755
|
-
|
|
751
|
+
math: {
|
|
756
752
|
clamp: {
|
|
757
753
|
(num: number, max: number): number;
|
|
758
754
|
(num: number, min: number, max: number): number;
|
|
759
755
|
};
|
|
760
|
-
};
|
|
761
|
-
math: {
|
|
762
756
|
invLerp: (start: number, end: number, value: number) => number;
|
|
763
757
|
lerp: (start: number, end: number, t: number) => number;
|
|
764
758
|
ms: (num: number) => number;
|
|
@@ -805,6 +799,7 @@ declare const $: {
|
|
|
805
799
|
};
|
|
806
800
|
async: {
|
|
807
801
|
retry: <T>(fn: () => Promise<T>, retries?: number, delay?: number) => Promise<T>;
|
|
802
|
+
wait: (ms: number) => Promise<boolean>;
|
|
808
803
|
};
|
|
809
804
|
arr: {
|
|
810
805
|
chunk: <T>(array: ReadonlyArray<T>, size: number) => T[][];
|
|
@@ -825,7 +820,7 @@ declare const $: {
|
|
|
825
820
|
unique: <T>(array: T[], key: (item: T) => any) => T[];
|
|
826
821
|
};
|
|
827
822
|
};
|
|
828
|
-
declare const
|
|
823
|
+
declare const $: {
|
|
829
824
|
Pipe: typeof Pipe;
|
|
830
825
|
Storage: typeof Storage;
|
|
831
826
|
Cache: typeof Cache;
|
|
@@ -860,7 +855,6 @@ declare const qznt: {
|
|
|
860
855
|
immediate?: boolean;
|
|
861
856
|
}) => DebouncedFunction<T>;
|
|
862
857
|
throttle: <T extends (...args: any[]) => any>(fn: T, limit: number) => (...args: Parameters<T>) => void;
|
|
863
|
-
wait: (ms: number) => Promise<boolean>;
|
|
864
858
|
};
|
|
865
859
|
obj: {
|
|
866
860
|
get: <T = any>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
|
|
@@ -875,13 +869,11 @@ declare const qznt: {
|
|
|
875
869
|
pick: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
876
870
|
omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
877
871
|
};
|
|
878
|
-
|
|
872
|
+
math: {
|
|
879
873
|
clamp: {
|
|
880
874
|
(num: number, max: number): number;
|
|
881
875
|
(num: number, min: number, max: number): number;
|
|
882
876
|
};
|
|
883
|
-
};
|
|
884
|
-
math: {
|
|
885
877
|
invLerp: (start: number, end: number, value: number) => number;
|
|
886
878
|
lerp: (start: number, end: number, t: number) => number;
|
|
887
879
|
ms: (num: number) => number;
|
|
@@ -928,6 +920,7 @@ declare const qznt: {
|
|
|
928
920
|
};
|
|
929
921
|
async: {
|
|
930
922
|
retry: <T>(fn: () => Promise<T>, retries?: number, delay?: number) => Promise<T>;
|
|
923
|
+
wait: (ms: number) => Promise<boolean>;
|
|
931
924
|
};
|
|
932
925
|
arr: {
|
|
933
926
|
chunk: <T>(array: ReadonlyArray<T>, size: number) => T[][];
|
|
@@ -949,4 +942,4 @@ declare const qznt: {
|
|
|
949
942
|
};
|
|
950
943
|
};
|
|
951
944
|
|
|
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,
|
|
945
|
+
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, qznt as default, fn, format, is, math, obj, rnd, str, timing, to };
|
package/dist/index.d.ts
CHANGED
|
@@ -299,15 +299,9 @@ declare function debounce<T extends (...args: any[]) => any>(fn: T, wait: number
|
|
|
299
299
|
* window.addEventListener('scroll', handleScroll);
|
|
300
300
|
*/
|
|
301
301
|
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
302
|
declare const timing: {
|
|
308
303
|
debounce: typeof debounce;
|
|
309
304
|
throttle: typeof throttle;
|
|
310
|
-
wait: typeof wait;
|
|
311
305
|
};
|
|
312
306
|
|
|
313
307
|
type ToRecordContext<T, V> = {
|
|
@@ -446,8 +440,14 @@ declare class Loop<T = any> extends TypedEmitterBase<T> {
|
|
|
446
440
|
* @param delay Initial delay in milliseconds. [default: 500ms]
|
|
447
441
|
*/
|
|
448
442
|
declare function retry<T>(fn: () => Promise<T>, retries?: number, delay?: number): Promise<T>;
|
|
443
|
+
/**
|
|
444
|
+
* Returns a promise that resolves after the given number of milliseconds.
|
|
445
|
+
* @param ms The time to wait in milliseconds.
|
|
446
|
+
*/
|
|
447
|
+
declare function wait(ms: number): Promise<boolean>;
|
|
449
448
|
declare const async: {
|
|
450
449
|
retry: typeof retry;
|
|
450
|
+
wait: typeof wait;
|
|
451
451
|
};
|
|
452
452
|
|
|
453
453
|
/**
|
|
@@ -542,6 +542,14 @@ declare const is: {
|
|
|
542
542
|
today: typeof today;
|
|
543
543
|
};
|
|
544
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Clamps a number within a specified range.
|
|
547
|
+
* @param num The number to check.
|
|
548
|
+
* @param min The minimum or maximum value of the range.
|
|
549
|
+
* @param max The maximum value of the range (optional).
|
|
550
|
+
*/
|
|
551
|
+
declare function clamp(num: number, max: number): number;
|
|
552
|
+
declare function clamp(num: number, min: number, max: number): number;
|
|
545
553
|
/**
|
|
546
554
|
* Calculates the interpolation factor (0-1) of a value between two points.
|
|
547
555
|
* @param start - The starting value (0%).
|
|
@@ -601,6 +609,7 @@ declare function secs(num: number): number;
|
|
|
601
609
|
*/
|
|
602
610
|
declare function sum<T>(array: T[], selector: (item: T) => number, ignoreNaN?: boolean): number;
|
|
603
611
|
declare const math: {
|
|
612
|
+
clamp: typeof clamp;
|
|
604
613
|
invLerp: typeof invLerp;
|
|
605
614
|
lerp: typeof lerp;
|
|
606
615
|
ms: typeof ms;
|
|
@@ -610,18 +619,6 @@ declare const math: {
|
|
|
610
619
|
sum: typeof sum;
|
|
611
620
|
};
|
|
612
621
|
|
|
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
622
|
/**
|
|
626
623
|
* Retrieves a nested property.
|
|
627
624
|
* @param obj The object to process.
|
|
@@ -702,7 +699,7 @@ declare const str: {
|
|
|
702
699
|
toTitleCase: typeof toTitleCase;
|
|
703
700
|
};
|
|
704
701
|
|
|
705
|
-
declare const
|
|
702
|
+
declare const qznt: {
|
|
706
703
|
Pipe: typeof Pipe;
|
|
707
704
|
Storage: typeof Storage;
|
|
708
705
|
Cache: typeof Cache;
|
|
@@ -737,7 +734,6 @@ declare const $: {
|
|
|
737
734
|
immediate?: boolean;
|
|
738
735
|
}) => DebouncedFunction<T>;
|
|
739
736
|
throttle: <T extends (...args: any[]) => any>(fn: T, limit: number) => (...args: Parameters<T>) => void;
|
|
740
|
-
wait: (ms: number) => Promise<boolean>;
|
|
741
737
|
};
|
|
742
738
|
obj: {
|
|
743
739
|
get: <T = any>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
|
|
@@ -752,13 +748,11 @@ declare const $: {
|
|
|
752
748
|
pick: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
753
749
|
omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
754
750
|
};
|
|
755
|
-
|
|
751
|
+
math: {
|
|
756
752
|
clamp: {
|
|
757
753
|
(num: number, max: number): number;
|
|
758
754
|
(num: number, min: number, max: number): number;
|
|
759
755
|
};
|
|
760
|
-
};
|
|
761
|
-
math: {
|
|
762
756
|
invLerp: (start: number, end: number, value: number) => number;
|
|
763
757
|
lerp: (start: number, end: number, t: number) => number;
|
|
764
758
|
ms: (num: number) => number;
|
|
@@ -805,6 +799,7 @@ declare const $: {
|
|
|
805
799
|
};
|
|
806
800
|
async: {
|
|
807
801
|
retry: <T>(fn: () => Promise<T>, retries?: number, delay?: number) => Promise<T>;
|
|
802
|
+
wait: (ms: number) => Promise<boolean>;
|
|
808
803
|
};
|
|
809
804
|
arr: {
|
|
810
805
|
chunk: <T>(array: ReadonlyArray<T>, size: number) => T[][];
|
|
@@ -825,7 +820,7 @@ declare const $: {
|
|
|
825
820
|
unique: <T>(array: T[], key: (item: T) => any) => T[];
|
|
826
821
|
};
|
|
827
822
|
};
|
|
828
|
-
declare const
|
|
823
|
+
declare const $: {
|
|
829
824
|
Pipe: typeof Pipe;
|
|
830
825
|
Storage: typeof Storage;
|
|
831
826
|
Cache: typeof Cache;
|
|
@@ -860,7 +855,6 @@ declare const qznt: {
|
|
|
860
855
|
immediate?: boolean;
|
|
861
856
|
}) => DebouncedFunction<T>;
|
|
862
857
|
throttle: <T extends (...args: any[]) => any>(fn: T, limit: number) => (...args: Parameters<T>) => void;
|
|
863
|
-
wait: (ms: number) => Promise<boolean>;
|
|
864
858
|
};
|
|
865
859
|
obj: {
|
|
866
860
|
get: <T = any>(obj: Record<string, any>, path: string, defaultValue?: T) => T;
|
|
@@ -875,13 +869,11 @@ declare const qznt: {
|
|
|
875
869
|
pick: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
876
870
|
omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
877
871
|
};
|
|
878
|
-
|
|
872
|
+
math: {
|
|
879
873
|
clamp: {
|
|
880
874
|
(num: number, max: number): number;
|
|
881
875
|
(num: number, min: number, max: number): number;
|
|
882
876
|
};
|
|
883
|
-
};
|
|
884
|
-
math: {
|
|
885
877
|
invLerp: (start: number, end: number, value: number) => number;
|
|
886
878
|
lerp: (start: number, end: number, t: number) => number;
|
|
887
879
|
ms: (num: number) => number;
|
|
@@ -928,6 +920,7 @@ declare const qznt: {
|
|
|
928
920
|
};
|
|
929
921
|
async: {
|
|
930
922
|
retry: <T>(fn: () => Promise<T>, retries?: number, delay?: number) => Promise<T>;
|
|
923
|
+
wait: (ms: number) => Promise<boolean>;
|
|
931
924
|
};
|
|
932
925
|
arr: {
|
|
933
926
|
chunk: <T>(array: ReadonlyArray<T>, size: number) => T[][];
|
|
@@ -949,4 +942,4 @@ declare const qznt: {
|
|
|
949
942
|
};
|
|
950
943
|
};
|
|
951
944
|
|
|
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,
|
|
945
|
+
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, qznt as default, fn, format, 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,
|
|
@@ -469,11 +477,11 @@ function empty(val) {
|
|
|
469
477
|
if (object(val)) return Object.keys(val).length === 0;
|
|
470
478
|
return false;
|
|
471
479
|
}
|
|
472
|
-
function inRange(
|
|
480
|
+
function inRange(num, a, b) {
|
|
473
481
|
let min = b !== void 0 ? a : 0;
|
|
474
482
|
let max = b !== void 0 ? b : a;
|
|
475
483
|
if (min > max) [min, max] = [max, min];
|
|
476
|
-
return
|
|
484
|
+
return num >= min && num <= max;
|
|
477
485
|
}
|
|
478
486
|
function object(val) {
|
|
479
487
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
@@ -508,6 +516,12 @@ var math_exports = {};
|
|
|
508
516
|
__export(math_exports, {
|
|
509
517
|
math: () => math
|
|
510
518
|
});
|
|
519
|
+
function clamp(num, a, b) {
|
|
520
|
+
let min = b !== void 0 ? a : 0;
|
|
521
|
+
let max = b !== void 0 ? b : a;
|
|
522
|
+
if (min > max) [min, max] = [max, min];
|
|
523
|
+
return Math.max(min, Math.min(num, max));
|
|
524
|
+
}
|
|
511
525
|
function invLerp(start, end, value) {
|
|
512
526
|
if (start === end) return 0;
|
|
513
527
|
return (value - start) / (end - start);
|
|
@@ -515,8 +529,8 @@ function invLerp(start, end, value) {
|
|
|
515
529
|
function lerp(start, end, t) {
|
|
516
530
|
return start + (end - start) * t;
|
|
517
531
|
}
|
|
518
|
-
function ms(
|
|
519
|
-
return Math.floor(
|
|
532
|
+
function ms(num) {
|
|
533
|
+
return Math.floor(num * 1e3);
|
|
520
534
|
}
|
|
521
535
|
function percent(a, b, round = true) {
|
|
522
536
|
const result = a / b * 100;
|
|
@@ -526,8 +540,8 @@ function remap(value, inMin, inMax, outMin, outMax) {
|
|
|
526
540
|
const t = invLerp(inMin, inMax, value);
|
|
527
541
|
return lerp(outMin, outMax, t);
|
|
528
542
|
}
|
|
529
|
-
function secs(
|
|
530
|
-
return Math.floor(
|
|
543
|
+
function secs(num) {
|
|
544
|
+
return Math.floor(num / 1e3);
|
|
531
545
|
}
|
|
532
546
|
function sum(array, selector, ignoreNaN) {
|
|
533
547
|
return array.map(selector).reduce((a, b) => {
|
|
@@ -537,6 +551,7 @@ function sum(array, selector, ignoreNaN) {
|
|
|
537
551
|
}, 0);
|
|
538
552
|
}
|
|
539
553
|
var math = {
|
|
554
|
+
clamp,
|
|
540
555
|
invLerp,
|
|
541
556
|
lerp,
|
|
542
557
|
ms,
|
|
@@ -546,21 +561,6 @@ var math = {
|
|
|
546
561
|
sum
|
|
547
562
|
};
|
|
548
563
|
|
|
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
564
|
// src/obj.ts
|
|
565
565
|
var obj_exports = {};
|
|
566
566
|
__export(obj_exports, {
|
|
@@ -738,17 +738,9 @@ function throttle(fn2, limit) {
|
|
|
738
738
|
}
|
|
739
739
|
};
|
|
740
740
|
}
|
|
741
|
-
function wait(ms2) {
|
|
742
|
-
return new Promise(
|
|
743
|
-
(resolve) => setTimeout(() => {
|
|
744
|
-
resolve(true);
|
|
745
|
-
}, ms2)
|
|
746
|
-
);
|
|
747
|
-
}
|
|
748
741
|
var timing = {
|
|
749
742
|
debounce,
|
|
750
|
-
throttle
|
|
751
|
-
wait
|
|
743
|
+
throttle
|
|
752
744
|
};
|
|
753
745
|
|
|
754
746
|
// src/to.ts
|
|
@@ -1014,7 +1006,7 @@ var Loop = class extends TypedEmitterBase {
|
|
|
1014
1006
|
};
|
|
1015
1007
|
|
|
1016
1008
|
// src/index.ts
|
|
1017
|
-
var
|
|
1009
|
+
var qznt = {
|
|
1018
1010
|
...arr_exports,
|
|
1019
1011
|
...async_exports,
|
|
1020
1012
|
...fn_exports,
|
|
@@ -1022,7 +1014,6 @@ var $ = {
|
|
|
1022
1014
|
...format_exports,
|
|
1023
1015
|
...is_exports,
|
|
1024
1016
|
...math_exports,
|
|
1025
|
-
...num_exports,
|
|
1026
1017
|
...obj_exports,
|
|
1027
1018
|
...timing_exports,
|
|
1028
1019
|
...rnd_exports,
|
|
@@ -1033,9 +1024,10 @@ var $ = {
|
|
|
1033
1024
|
Cache,
|
|
1034
1025
|
Loop
|
|
1035
1026
|
};
|
|
1036
|
-
var
|
|
1037
|
-
var index_default =
|
|
1027
|
+
var $ = qznt;
|
|
1028
|
+
var index_default = qznt;
|
|
1038
1029
|
export {
|
|
1030
|
+
$,
|
|
1039
1031
|
Cache,
|
|
1040
1032
|
Loop,
|
|
1041
1033
|
Pipe,
|
|
@@ -1048,9 +1040,7 @@ export {
|
|
|
1048
1040
|
format,
|
|
1049
1041
|
is,
|
|
1050
1042
|
math,
|
|
1051
|
-
num,
|
|
1052
1043
|
obj,
|
|
1053
|
-
qznt,
|
|
1054
1044
|
rnd,
|
|
1055
1045
|
str2 as str,
|
|
1056
1046
|
timing,
|