moderndash 3.12.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -13
- package/dist/index.cjs +22 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -26
- package/dist/index.d.ts +30 -26
- package/dist/index.js +22 -41
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Paths as Paths$1 } from 'type-fest';
|
|
2
|
+
import { Call, Objects } from 'hotscript';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.
|
|
@@ -59,11 +60,10 @@ type CompareFunction<TArrays extends ArrayMinLength<unknown[], 2>> = (a: TArrays
|
|
|
59
60
|
type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U] ? U : never;
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
|
-
* @deprecated **Deprecated: Use the native [Set.prototype.difference()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference) function instead.**
|
|
63
|
-
*
|
|
64
63
|
* Create a new array with values from the first array that are not present in the other arrays.
|
|
65
64
|
* Optionally, use a compare function to determine the comparison of elements (default is `===`).
|
|
66
65
|
*
|
|
66
|
+
* **Consider using the native [Set.prototype.difference()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference) function instead.**
|
|
67
67
|
*
|
|
68
68
|
* @example
|
|
69
69
|
* difference([2, 1], [2, 3], [6])
|
|
@@ -80,6 +80,7 @@ type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U]
|
|
|
80
80
|
*
|
|
81
81
|
* difference(arr1, arr2, (a, b) => a.id === b.id)
|
|
82
82
|
* // => [{ id: 1, name: 'Yeet' }]
|
|
83
|
+
*
|
|
83
84
|
* @param arraysOrCompareFn Two or more arrays with an optional compare function at the end
|
|
84
85
|
* @template TElem The type of the array elements
|
|
85
86
|
* @template TArrays The type of the arrays provided
|
|
@@ -130,7 +131,9 @@ declare function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TE
|
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
133
|
* Creates an object with grouped items in the array.
|
|
133
|
-
*
|
|
134
|
+
*
|
|
135
|
+
* @deprecated
|
|
136
|
+
* **Deprecated: Use the native "Object.groupBy()" function instead.**
|
|
134
137
|
*
|
|
135
138
|
* @example
|
|
136
139
|
* group([6.1, 4.2, 6.3], Math.floor)
|
|
@@ -147,13 +150,13 @@ declare function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TE
|
|
|
147
150
|
declare function group<TElem, TKey extends PropertyKey>(array: readonly TElem[], getGroupKey: (elem: TElem) => TKey): Record<TKey, TElem[]>;
|
|
148
151
|
|
|
149
152
|
/**
|
|
150
|
-
* @deprecated **Deprecated: Use the native [Set.prototype.intersection()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection) function instead.**
|
|
151
|
-
*
|
|
152
153
|
* Create an array with unique values that are present in all arrays.
|
|
153
154
|
* The order of the values is based on the first array.
|
|
154
155
|
*
|
|
155
156
|
* Optionally, use a compare function for element comparison (default is `===`).
|
|
156
157
|
*
|
|
158
|
+
* **Consider using the native [Set.prototype.intersection()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection) function instead.**
|
|
159
|
+
*
|
|
157
160
|
* @example
|
|
158
161
|
* intersection([2, 1], [2, 3], [6, 2])
|
|
159
162
|
* // => [2]
|
|
@@ -466,8 +469,6 @@ declare function randomString(length: number, charSet?: string): string;
|
|
|
466
469
|
*
|
|
467
470
|
* Look at {@link debounce} for the non-decorator version.
|
|
468
471
|
*
|
|
469
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
470
|
-
*
|
|
471
472
|
* @example
|
|
472
473
|
* ```typescript
|
|
473
474
|
* class TestClass {
|
|
@@ -484,7 +485,11 @@ declare function randomString(length: number, charSet?: string): string;
|
|
|
484
485
|
* ```
|
|
485
486
|
* @param wait Milliseconds to wait before invoking the decorated function after the last invocation.
|
|
486
487
|
*/
|
|
487
|
-
declare function decDebounce(wait: number): (
|
|
488
|
+
declare function decDebounce(wait: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any> & {
|
|
489
|
+
cancel: () => void;
|
|
490
|
+
flush: () => void;
|
|
491
|
+
pending: () => boolean;
|
|
492
|
+
};
|
|
488
493
|
|
|
489
494
|
/**
|
|
490
495
|
* Only invokes the decorated function as long as it's called `<= n` times.
|
|
@@ -492,8 +497,6 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
|
|
|
492
497
|
*
|
|
493
498
|
* Look at {@link maxCalls} for the non-decorator version.
|
|
494
499
|
*
|
|
495
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
496
|
-
*
|
|
497
500
|
* @example
|
|
498
501
|
* ```typescript
|
|
499
502
|
* class TestClass {
|
|
@@ -510,7 +513,7 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
|
|
|
510
513
|
* ```
|
|
511
514
|
* @param n The number of calls before the cached result is returned.
|
|
512
515
|
*/
|
|
513
|
-
declare function decMaxCalls(n: number): (
|
|
516
|
+
declare function decMaxCalls(n: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
|
|
514
517
|
|
|
515
518
|
type GenericFunction<TFunc extends (...args: any) => any> = (...args: Parameters<TFunc>) => ReturnType<TFunc>;
|
|
516
519
|
|
|
@@ -576,8 +579,6 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
|
|
|
576
579
|
*
|
|
577
580
|
* Look at {@link memoize} for the non-decorator version.
|
|
578
581
|
*
|
|
579
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
580
|
-
*
|
|
581
582
|
* @example
|
|
582
583
|
* ```typescript
|
|
583
584
|
* class TestClass {
|
|
@@ -597,14 +598,15 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
|
|
|
597
598
|
* @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.
|
|
598
599
|
* @param options.ttl - The time to live for the cache in milliseconds.
|
|
599
600
|
*/
|
|
600
|
-
declare function decMemoize(options?: Parameters<typeof memoize>[1]): (
|
|
601
|
+
declare function decMemoize(options?: Parameters<typeof memoize>[1]): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<GenericFunction<any>> & {
|
|
602
|
+
cache: Map<string, [any, number]>;
|
|
603
|
+
};
|
|
601
604
|
|
|
602
605
|
/**
|
|
603
606
|
* Only invokes the decorated function after it's called more than `n` times.
|
|
604
607
|
*
|
|
605
608
|
* Look at {@link minCalls} for the non-decorator version.
|
|
606
609
|
*
|
|
607
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
608
610
|
* @example
|
|
609
611
|
* ```typescript
|
|
610
612
|
* class TestClass {
|
|
@@ -620,15 +622,13 @@ declare function decMemoize(options?: Parameters<typeof memoize>[1]): (_target:
|
|
|
620
622
|
* ```
|
|
621
623
|
* @param n The number of calls before the decorated function is invoked.
|
|
622
624
|
*/
|
|
623
|
-
declare function decMinCalls(n: number): (
|
|
625
|
+
declare function decMinCalls(n: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => (this: unknown, ...args: unknown[]) => any;
|
|
624
626
|
|
|
625
627
|
/**
|
|
626
628
|
* The decorated function is invoked at most once per every `wait` milliseconds.
|
|
627
629
|
*
|
|
628
630
|
* Look at {@link throttle} for the non-decorator version.
|
|
629
631
|
*
|
|
630
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
631
|
-
*
|
|
632
632
|
* @example
|
|
633
633
|
* ```typescript
|
|
634
634
|
* class TestClass {
|
|
@@ -644,7 +644,7 @@ declare function decMinCalls(n: number): (_target: unknown, _key: string, descri
|
|
|
644
644
|
* ```
|
|
645
645
|
* @param wait The number of milliseconds to wait between invocations.
|
|
646
646
|
*/
|
|
647
|
-
declare function decThrottle(wait: number): (
|
|
647
|
+
declare function decThrottle(wait: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
|
|
648
648
|
|
|
649
649
|
type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail : never;
|
|
650
650
|
/**
|
|
@@ -675,7 +675,7 @@ type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail :
|
|
|
675
675
|
* @param func The function to transform.
|
|
676
676
|
* @returns A decorator function that can be used to decorate a method.
|
|
677
677
|
*/
|
|
678
|
-
declare function toDecorator<TFunc extends GenericFunction<TFunc>>(func: TFunc): (...args: Tail<Parameters<TFunc>>) => (
|
|
678
|
+
declare function toDecorator<TFunc extends GenericFunction<TFunc>>(func: TFunc): (...args: Tail<Parameters<TFunc>>) => (originalMethod: unknown, _context: ClassMethodDecoratorContext) => ReturnType<TFunc>;
|
|
679
679
|
|
|
680
680
|
/**
|
|
681
681
|
* Creates a debounced version of a function. Only calling it after a specified amount of time has passed without any new calls.
|
|
@@ -829,13 +829,15 @@ declare function round(number: number, precision?: number): number;
|
|
|
829
829
|
* @param numbers The input array of numbers
|
|
830
830
|
* @returns The sum of the input array
|
|
831
831
|
*/
|
|
832
|
-
declare function sum(numbers: number[]): number;
|
|
833
|
-
declare function sum<TNum extends readonly number[]>(numbers: TNum): Call<Tuples.Sum, TNum>;
|
|
832
|
+
declare function sum(numbers: readonly number[]): number;
|
|
834
833
|
|
|
835
834
|
type GenericObject = Record<PropertyKey, any>;
|
|
836
835
|
|
|
837
836
|
type StringIfNever<Type> = [Type] extends [never] ? string : Type;
|
|
838
|
-
type
|
|
837
|
+
type PathOrString<TObj> = StringIfNever<Paths$1<TObj, {
|
|
838
|
+
bracketNotation: true;
|
|
839
|
+
maxRecursionDepth: 20;
|
|
840
|
+
}>>;
|
|
839
841
|
/**
|
|
840
842
|
* Flattens an object into a single level object.
|
|
841
843
|
*
|
|
@@ -848,7 +850,7 @@ type Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
|
|
|
848
850
|
* @template TObj The type of the object to flatten.
|
|
849
851
|
* @returns A new object with flattened keys.
|
|
850
852
|
*/
|
|
851
|
-
declare function flatKeys<TObj extends GenericObject>(obj: TObj): Record<
|
|
853
|
+
declare function flatKeys<TObj extends GenericObject>(obj: TObj): Record<PathOrString<TObj>, unknown>;
|
|
852
854
|
|
|
853
855
|
/**
|
|
854
856
|
* The type of a plain object.
|
|
@@ -1452,7 +1454,9 @@ declare function isPlainObject(value: unknown): value is PlainObject;
|
|
|
1452
1454
|
|
|
1453
1455
|
/**
|
|
1454
1456
|
* Checks if given string is a valid URL
|
|
1455
|
-
*
|
|
1457
|
+
*
|
|
1458
|
+
* @deprecated
|
|
1459
|
+
* **Deprecated: Use the native "URL.canParse" method instead.**
|
|
1456
1460
|
*
|
|
1457
1461
|
* @example
|
|
1458
1462
|
* isUrl('https://google.com')
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Paths as Paths$1 } from 'type-fest';
|
|
2
|
+
import { Call, Objects } from 'hotscript';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.
|
|
@@ -59,11 +60,10 @@ type CompareFunction<TArrays extends ArrayMinLength<unknown[], 2>> = (a: TArrays
|
|
|
59
60
|
type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U] ? U : never;
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
|
-
* @deprecated **Deprecated: Use the native [Set.prototype.difference()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference) function instead.**
|
|
63
|
-
*
|
|
64
63
|
* Create a new array with values from the first array that are not present in the other arrays.
|
|
65
64
|
* Optionally, use a compare function to determine the comparison of elements (default is `===`).
|
|
66
65
|
*
|
|
66
|
+
* **Consider using the native [Set.prototype.difference()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference) function instead.**
|
|
67
67
|
*
|
|
68
68
|
* @example
|
|
69
69
|
* difference([2, 1], [2, 3], [6])
|
|
@@ -80,6 +80,7 @@ type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U]
|
|
|
80
80
|
*
|
|
81
81
|
* difference(arr1, arr2, (a, b) => a.id === b.id)
|
|
82
82
|
* // => [{ id: 1, name: 'Yeet' }]
|
|
83
|
+
*
|
|
83
84
|
* @param arraysOrCompareFn Two or more arrays with an optional compare function at the end
|
|
84
85
|
* @template TElem The type of the array elements
|
|
85
86
|
* @template TArrays The type of the arrays provided
|
|
@@ -130,7 +131,9 @@ declare function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TE
|
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
133
|
* Creates an object with grouped items in the array.
|
|
133
|
-
*
|
|
134
|
+
*
|
|
135
|
+
* @deprecated
|
|
136
|
+
* **Deprecated: Use the native "Object.groupBy()" function instead.**
|
|
134
137
|
*
|
|
135
138
|
* @example
|
|
136
139
|
* group([6.1, 4.2, 6.3], Math.floor)
|
|
@@ -147,13 +150,13 @@ declare function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TE
|
|
|
147
150
|
declare function group<TElem, TKey extends PropertyKey>(array: readonly TElem[], getGroupKey: (elem: TElem) => TKey): Record<TKey, TElem[]>;
|
|
148
151
|
|
|
149
152
|
/**
|
|
150
|
-
* @deprecated **Deprecated: Use the native [Set.prototype.intersection()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection) function instead.**
|
|
151
|
-
*
|
|
152
153
|
* Create an array with unique values that are present in all arrays.
|
|
153
154
|
* The order of the values is based on the first array.
|
|
154
155
|
*
|
|
155
156
|
* Optionally, use a compare function for element comparison (default is `===`).
|
|
156
157
|
*
|
|
158
|
+
* **Consider using the native [Set.prototype.intersection()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/intersection) function instead.**
|
|
159
|
+
*
|
|
157
160
|
* @example
|
|
158
161
|
* intersection([2, 1], [2, 3], [6, 2])
|
|
159
162
|
* // => [2]
|
|
@@ -466,8 +469,6 @@ declare function randomString(length: number, charSet?: string): string;
|
|
|
466
469
|
*
|
|
467
470
|
* Look at {@link debounce} for the non-decorator version.
|
|
468
471
|
*
|
|
469
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
470
|
-
*
|
|
471
472
|
* @example
|
|
472
473
|
* ```typescript
|
|
473
474
|
* class TestClass {
|
|
@@ -484,7 +485,11 @@ declare function randomString(length: number, charSet?: string): string;
|
|
|
484
485
|
* ```
|
|
485
486
|
* @param wait Milliseconds to wait before invoking the decorated function after the last invocation.
|
|
486
487
|
*/
|
|
487
|
-
declare function decDebounce(wait: number): (
|
|
488
|
+
declare function decDebounce(wait: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any> & {
|
|
489
|
+
cancel: () => void;
|
|
490
|
+
flush: () => void;
|
|
491
|
+
pending: () => boolean;
|
|
492
|
+
};
|
|
488
493
|
|
|
489
494
|
/**
|
|
490
495
|
* Only invokes the decorated function as long as it's called `<= n` times.
|
|
@@ -492,8 +497,6 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
|
|
|
492
497
|
*
|
|
493
498
|
* Look at {@link maxCalls} for the non-decorator version.
|
|
494
499
|
*
|
|
495
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
496
|
-
*
|
|
497
500
|
* @example
|
|
498
501
|
* ```typescript
|
|
499
502
|
* class TestClass {
|
|
@@ -510,7 +513,7 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
|
|
|
510
513
|
* ```
|
|
511
514
|
* @param n The number of calls before the cached result is returned.
|
|
512
515
|
*/
|
|
513
|
-
declare function decMaxCalls(n: number): (
|
|
516
|
+
declare function decMaxCalls(n: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
|
|
514
517
|
|
|
515
518
|
type GenericFunction<TFunc extends (...args: any) => any> = (...args: Parameters<TFunc>) => ReturnType<TFunc>;
|
|
516
519
|
|
|
@@ -576,8 +579,6 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
|
|
|
576
579
|
*
|
|
577
580
|
* Look at {@link memoize} for the non-decorator version.
|
|
578
581
|
*
|
|
579
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
580
|
-
*
|
|
581
582
|
* @example
|
|
582
583
|
* ```typescript
|
|
583
584
|
* class TestClass {
|
|
@@ -597,14 +598,15 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
|
|
|
597
598
|
* @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.
|
|
598
599
|
* @param options.ttl - The time to live for the cache in milliseconds.
|
|
599
600
|
*/
|
|
600
|
-
declare function decMemoize(options?: Parameters<typeof memoize>[1]): (
|
|
601
|
+
declare function decMemoize(options?: Parameters<typeof memoize>[1]): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<GenericFunction<any>> & {
|
|
602
|
+
cache: Map<string, [any, number]>;
|
|
603
|
+
};
|
|
601
604
|
|
|
602
605
|
/**
|
|
603
606
|
* Only invokes the decorated function after it's called more than `n` times.
|
|
604
607
|
*
|
|
605
608
|
* Look at {@link minCalls} for the non-decorator version.
|
|
606
609
|
*
|
|
607
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
608
610
|
* @example
|
|
609
611
|
* ```typescript
|
|
610
612
|
* class TestClass {
|
|
@@ -620,15 +622,13 @@ declare function decMemoize(options?: Parameters<typeof memoize>[1]): (_target:
|
|
|
620
622
|
* ```
|
|
621
623
|
* @param n The number of calls before the decorated function is invoked.
|
|
622
624
|
*/
|
|
623
|
-
declare function decMinCalls(n: number): (
|
|
625
|
+
declare function decMinCalls(n: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => (this: unknown, ...args: unknown[]) => any;
|
|
624
626
|
|
|
625
627
|
/**
|
|
626
628
|
* The decorated function is invoked at most once per every `wait` milliseconds.
|
|
627
629
|
*
|
|
628
630
|
* Look at {@link throttle} for the non-decorator version.
|
|
629
631
|
*
|
|
630
|
-
* *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
|
|
631
|
-
*
|
|
632
632
|
* @example
|
|
633
633
|
* ```typescript
|
|
634
634
|
* class TestClass {
|
|
@@ -644,7 +644,7 @@ declare function decMinCalls(n: number): (_target: unknown, _key: string, descri
|
|
|
644
644
|
* ```
|
|
645
645
|
* @param wait The number of milliseconds to wait between invocations.
|
|
646
646
|
*/
|
|
647
|
-
declare function decThrottle(wait: number): (
|
|
647
|
+
declare function decThrottle(wait: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
|
|
648
648
|
|
|
649
649
|
type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail : never;
|
|
650
650
|
/**
|
|
@@ -675,7 +675,7 @@ type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail :
|
|
|
675
675
|
* @param func The function to transform.
|
|
676
676
|
* @returns A decorator function that can be used to decorate a method.
|
|
677
677
|
*/
|
|
678
|
-
declare function toDecorator<TFunc extends GenericFunction<TFunc>>(func: TFunc): (...args: Tail<Parameters<TFunc>>) => (
|
|
678
|
+
declare function toDecorator<TFunc extends GenericFunction<TFunc>>(func: TFunc): (...args: Tail<Parameters<TFunc>>) => (originalMethod: unknown, _context: ClassMethodDecoratorContext) => ReturnType<TFunc>;
|
|
679
679
|
|
|
680
680
|
/**
|
|
681
681
|
* Creates a debounced version of a function. Only calling it after a specified amount of time has passed without any new calls.
|
|
@@ -829,13 +829,15 @@ declare function round(number: number, precision?: number): number;
|
|
|
829
829
|
* @param numbers The input array of numbers
|
|
830
830
|
* @returns The sum of the input array
|
|
831
831
|
*/
|
|
832
|
-
declare function sum(numbers: number[]): number;
|
|
833
|
-
declare function sum<TNum extends readonly number[]>(numbers: TNum): Call<Tuples.Sum, TNum>;
|
|
832
|
+
declare function sum(numbers: readonly number[]): number;
|
|
834
833
|
|
|
835
834
|
type GenericObject = Record<PropertyKey, any>;
|
|
836
835
|
|
|
837
836
|
type StringIfNever<Type> = [Type] extends [never] ? string : Type;
|
|
838
|
-
type
|
|
837
|
+
type PathOrString<TObj> = StringIfNever<Paths$1<TObj, {
|
|
838
|
+
bracketNotation: true;
|
|
839
|
+
maxRecursionDepth: 20;
|
|
840
|
+
}>>;
|
|
839
841
|
/**
|
|
840
842
|
* Flattens an object into a single level object.
|
|
841
843
|
*
|
|
@@ -848,7 +850,7 @@ type Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
|
|
|
848
850
|
* @template TObj The type of the object to flatten.
|
|
849
851
|
* @returns A new object with flattened keys.
|
|
850
852
|
*/
|
|
851
|
-
declare function flatKeys<TObj extends GenericObject>(obj: TObj): Record<
|
|
853
|
+
declare function flatKeys<TObj extends GenericObject>(obj: TObj): Record<PathOrString<TObj>, unknown>;
|
|
852
854
|
|
|
853
855
|
/**
|
|
854
856
|
* The type of a plain object.
|
|
@@ -1452,7 +1454,9 @@ declare function isPlainObject(value: unknown): value is PlainObject;
|
|
|
1452
1454
|
|
|
1453
1455
|
/**
|
|
1454
1456
|
* Checks if given string is a valid URL
|
|
1455
|
-
*
|
|
1457
|
+
*
|
|
1458
|
+
* @deprecated
|
|
1459
|
+
* **Deprecated: Use the native "URL.canParse" method instead.**
|
|
1456
1460
|
*
|
|
1457
1461
|
* @example
|
|
1458
1462
|
* isUrl('https://google.com')
|
package/dist/index.js
CHANGED
|
@@ -226,12 +226,10 @@ function randomInt(min, max) {
|
|
|
226
226
|
// src/crypto/randomElem.ts
|
|
227
227
|
function randomElem(array, multi) {
|
|
228
228
|
if (multi === void 0) {
|
|
229
|
-
if (array.length === 0)
|
|
230
|
-
return void 0;
|
|
229
|
+
if (array.length === 0) return void 0;
|
|
231
230
|
return getSingleElement(array);
|
|
232
231
|
}
|
|
233
|
-
if (multi && array.length === 0)
|
|
234
|
-
return [];
|
|
232
|
+
if (multi && array.length === 0) return [];
|
|
235
233
|
const result = new Array(multi);
|
|
236
234
|
for (let i = 0; i < multi; i++) {
|
|
237
235
|
result[i] = getSingleElement(array);
|
|
@@ -257,8 +255,7 @@ function randomFloat(min, max) {
|
|
|
257
255
|
// src/crypto/randomString.ts
|
|
258
256
|
var DEFAULT_CHARSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
259
257
|
function randomString(length, charSet = DEFAULT_CHARSET) {
|
|
260
|
-
if (charSet.length <= 0)
|
|
261
|
-
return "";
|
|
258
|
+
if (charSet.length <= 0) return "";
|
|
262
259
|
let result = "";
|
|
263
260
|
for (let index = 0; index < length; index++) {
|
|
264
261
|
const randomIndex = randomInt(0, charSet.length - 1);
|
|
@@ -270,9 +267,9 @@ function randomString(length, charSet = DEFAULT_CHARSET) {
|
|
|
270
267
|
// src/decorator/toDecorator.ts
|
|
271
268
|
function toDecorator(func) {
|
|
272
269
|
return function(...args) {
|
|
273
|
-
return function(
|
|
274
|
-
const
|
|
275
|
-
|
|
270
|
+
return function(originalMethod, _context) {
|
|
271
|
+
const funcArgs = [originalMethod, ...args];
|
|
272
|
+
return func(...funcArgs);
|
|
276
273
|
};
|
|
277
274
|
};
|
|
278
275
|
}
|
|
@@ -682,8 +679,7 @@ function splitWords(str) {
|
|
|
682
679
|
|
|
683
680
|
// src/string/capitalize.ts
|
|
684
681
|
function capitalize(str) {
|
|
685
|
-
if (str === "")
|
|
686
|
-
return "";
|
|
682
|
+
if (str === "") return "";
|
|
687
683
|
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
688
684
|
}
|
|
689
685
|
|
|
@@ -695,12 +691,10 @@ function deburr(str) {
|
|
|
695
691
|
|
|
696
692
|
// src/string/camelCase.ts
|
|
697
693
|
function camelCase(str) {
|
|
698
|
-
if (str === "")
|
|
699
|
-
return "";
|
|
694
|
+
if (str === "") return "";
|
|
700
695
|
str = deburr(str);
|
|
701
696
|
const words = splitWords(str);
|
|
702
|
-
if (words.length === 0)
|
|
703
|
-
return "";
|
|
697
|
+
if (words.length === 0) return "";
|
|
704
698
|
let camelCase2 = words[0].toLowerCase();
|
|
705
699
|
for (let index = 1; index < words.length; index++) {
|
|
706
700
|
const word = words[index];
|
|
@@ -730,8 +724,7 @@ function escapeRegExp(str) {
|
|
|
730
724
|
|
|
731
725
|
// src/string/kebabCase.ts
|
|
732
726
|
function kebabCase(str) {
|
|
733
|
-
if (str === "")
|
|
734
|
-
return "";
|
|
727
|
+
if (str === "") return "";
|
|
735
728
|
str = deburr(str);
|
|
736
729
|
const words = splitWords(str);
|
|
737
730
|
let kebabCase2 = "";
|
|
@@ -743,8 +736,7 @@ function kebabCase(str) {
|
|
|
743
736
|
|
|
744
737
|
// src/string/pascalCase.ts
|
|
745
738
|
function pascalCase(str) {
|
|
746
|
-
if (str === "")
|
|
747
|
-
return "";
|
|
739
|
+
if (str === "") return "";
|
|
748
740
|
str = deburr(str);
|
|
749
741
|
const words = splitWords(str);
|
|
750
742
|
let pascalCase2 = "";
|
|
@@ -764,8 +756,7 @@ function replaceLast(str, searchFor, replaceWith) {
|
|
|
764
756
|
|
|
765
757
|
// src/string/snakeCase.ts
|
|
766
758
|
function snakeCase(str) {
|
|
767
|
-
if (str === "")
|
|
768
|
-
return "";
|
|
759
|
+
if (str === "") return "";
|
|
769
760
|
str = deburr(str);
|
|
770
761
|
const words = splitWords(str);
|
|
771
762
|
let snakeCase2 = "";
|
|
@@ -780,8 +771,7 @@ function snakeCase(str) {
|
|
|
780
771
|
|
|
781
772
|
// src/string/titleCase.ts
|
|
782
773
|
function titleCase(str) {
|
|
783
|
-
if (str === "")
|
|
784
|
-
return "";
|
|
774
|
+
if (str === "") return "";
|
|
785
775
|
str = deburr(str);
|
|
786
776
|
const words = splitWords(str);
|
|
787
777
|
let titleCase2 = "";
|
|
@@ -825,8 +815,7 @@ function trimStart(str, chars) {
|
|
|
825
815
|
// src/string/truncate.ts
|
|
826
816
|
function truncate(str, options) {
|
|
827
817
|
const { length = 30, ellipsis = "...", separator } = options ?? {};
|
|
828
|
-
if (str.length <= length)
|
|
829
|
-
return str;
|
|
818
|
+
if (str.length <= length) return str;
|
|
830
819
|
const end = length - ellipsis.length;
|
|
831
820
|
if (end < 1)
|
|
832
821
|
return ellipsis;
|
|
@@ -870,10 +859,8 @@ function isEmpty(value) {
|
|
|
870
859
|
|
|
871
860
|
// src/validate/isEqual.ts
|
|
872
861
|
function isEqual(a, b) {
|
|
873
|
-
if (Object.is(a, b))
|
|
874
|
-
|
|
875
|
-
if (typeof a !== typeof b)
|
|
876
|
-
return false;
|
|
862
|
+
if (Object.is(a, b)) return true;
|
|
863
|
+
if (typeof a !== typeof b) return false;
|
|
877
864
|
if (Array.isArray(a) && Array.isArray(b))
|
|
878
865
|
return isSameArray(a, b);
|
|
879
866
|
if (a instanceof Date && b instanceof Date)
|
|
@@ -887,8 +874,7 @@ function isEqual(a, b) {
|
|
|
887
874
|
if (a instanceof DataView && b instanceof DataView)
|
|
888
875
|
return dataViewsAreEqual(a, b);
|
|
889
876
|
if (isTypedArray(a) && isTypedArray(b)) {
|
|
890
|
-
if (a.byteLength !== b.byteLength)
|
|
891
|
-
return false;
|
|
877
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
892
878
|
return isSameArray(a, b);
|
|
893
879
|
}
|
|
894
880
|
return false;
|
|
@@ -896,25 +882,20 @@ function isEqual(a, b) {
|
|
|
896
882
|
function isSameObject(a, b) {
|
|
897
883
|
const keys1 = Object.keys(a);
|
|
898
884
|
const keys2 = Object.keys(b);
|
|
899
|
-
if (!isEqual(keys1, keys2))
|
|
900
|
-
return false;
|
|
885
|
+
if (!isEqual(keys1, keys2)) return false;
|
|
901
886
|
for (const key of keys1) {
|
|
902
|
-
if (!isEqual(a[key], b[key]))
|
|
903
|
-
return false;
|
|
887
|
+
if (!isEqual(a[key], b[key])) return false;
|
|
904
888
|
}
|
|
905
889
|
return true;
|
|
906
890
|
}
|
|
907
891
|
function isSameArray(a, b) {
|
|
908
|
-
if (a.length !== b.length)
|
|
909
|
-
return false;
|
|
892
|
+
if (a.length !== b.length) return false;
|
|
910
893
|
return a.every((element, index) => isEqual(element, b[index]));
|
|
911
894
|
}
|
|
912
895
|
function dataViewsAreEqual(a, b) {
|
|
913
|
-
if (a.byteLength !== b.byteLength)
|
|
914
|
-
return false;
|
|
896
|
+
if (a.byteLength !== b.byteLength) return false;
|
|
915
897
|
for (let offset = 0; offset < a.byteLength; offset++) {
|
|
916
|
-
if (a.getUint8(offset) !== b.getUint8(offset))
|
|
917
|
-
return false;
|
|
898
|
+
if (a.getUint8(offset) !== b.getUint8(offset)) return false;
|
|
918
899
|
}
|
|
919
900
|
return true;
|
|
920
901
|
}
|