moderndash 3.12.0 → 4.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.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { Call, Tuples, Objects } from 'hotscript';
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
- * @deprecated Use the javascript "Object.groupBy()" version instead.
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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]): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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>>) => (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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 Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
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<Paths$1<TObj>, unknown>;
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
- * @deprecated Use the native "URL.canParse" method instead.
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 { Call, Tuples, Objects } from 'hotscript';
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
- * @deprecated Use the javascript "Object.groupBy()" version instead.
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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]): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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>>) => (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
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 Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
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<Paths$1<TObj>, unknown>;
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
- * @deprecated Use the native "URL.canParse" method instead.
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(_target, _key, descriptor) {
274
- const creatorArgs = [descriptor.value, ...args];
275
- descriptor.value = func(...creatorArgs);
270
+ return function(originalMethod, _context) {
271
+ const funcArgs = [originalMethod, ...args];
272
+ return func(...funcArgs);
276
273
  };
277
274
  };
278
275
  }
@@ -457,6 +454,7 @@ function merge(target, ...sources) {
457
454
  const targetCopy = { ...target };
458
455
  for (const source of sources) {
459
456
  for (const [key, value] of Object.entries(source)) {
457
+ if (key === "__proto__") continue;
460
458
  targetCopy[key] = isPlainObject(value) && isPlainObject(targetCopy[key]) ? merge(targetCopy[key], value) : value;
461
459
  }
462
460
  }
@@ -490,6 +488,8 @@ function set(obj, path, value) {
490
488
  let currentObj = obj;
491
489
  for (let index = 0; index < pathParts.length; index++) {
492
490
  const key = pathParts[index].replace(matchBracketsRegex, "");
491
+ if (key === "__proto__")
492
+ return obj;
493
493
  if (index === pathParts.length - 1) {
494
494
  currentObj[key] = value;
495
495
  break;
@@ -682,8 +682,7 @@ function splitWords(str) {
682
682
 
683
683
  // src/string/capitalize.ts
684
684
  function capitalize(str) {
685
- if (str === "")
686
- return "";
685
+ if (str === "") return "";
687
686
  return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
688
687
  }
689
688
 
@@ -695,12 +694,10 @@ function deburr(str) {
695
694
 
696
695
  // src/string/camelCase.ts
697
696
  function camelCase(str) {
698
- if (str === "")
699
- return "";
697
+ if (str === "") return "";
700
698
  str = deburr(str);
701
699
  const words = splitWords(str);
702
- if (words.length === 0)
703
- return "";
700
+ if (words.length === 0) return "";
704
701
  let camelCase2 = words[0].toLowerCase();
705
702
  for (let index = 1; index < words.length; index++) {
706
703
  const word = words[index];
@@ -730,8 +727,7 @@ function escapeRegExp(str) {
730
727
 
731
728
  // src/string/kebabCase.ts
732
729
  function kebabCase(str) {
733
- if (str === "")
734
- return "";
730
+ if (str === "") return "";
735
731
  str = deburr(str);
736
732
  const words = splitWords(str);
737
733
  let kebabCase2 = "";
@@ -743,8 +739,7 @@ function kebabCase(str) {
743
739
 
744
740
  // src/string/pascalCase.ts
745
741
  function pascalCase(str) {
746
- if (str === "")
747
- return "";
742
+ if (str === "") return "";
748
743
  str = deburr(str);
749
744
  const words = splitWords(str);
750
745
  let pascalCase2 = "";
@@ -764,8 +759,7 @@ function replaceLast(str, searchFor, replaceWith) {
764
759
 
765
760
  // src/string/snakeCase.ts
766
761
  function snakeCase(str) {
767
- if (str === "")
768
- return "";
762
+ if (str === "") return "";
769
763
  str = deburr(str);
770
764
  const words = splitWords(str);
771
765
  let snakeCase2 = "";
@@ -780,8 +774,7 @@ function snakeCase(str) {
780
774
 
781
775
  // src/string/titleCase.ts
782
776
  function titleCase(str) {
783
- if (str === "")
784
- return "";
777
+ if (str === "") return "";
785
778
  str = deburr(str);
786
779
  const words = splitWords(str);
787
780
  let titleCase2 = "";
@@ -825,8 +818,7 @@ function trimStart(str, chars) {
825
818
  // src/string/truncate.ts
826
819
  function truncate(str, options) {
827
820
  const { length = 30, ellipsis = "...", separator } = options ?? {};
828
- if (str.length <= length)
829
- return str;
821
+ if (str.length <= length) return str;
830
822
  const end = length - ellipsis.length;
831
823
  if (end < 1)
832
824
  return ellipsis;
@@ -870,10 +862,8 @@ function isEmpty(value) {
870
862
 
871
863
  // src/validate/isEqual.ts
872
864
  function isEqual(a, b) {
873
- if (Object.is(a, b))
874
- return true;
875
- if (typeof a !== typeof b)
876
- return false;
865
+ if (Object.is(a, b)) return true;
866
+ if (typeof a !== typeof b) return false;
877
867
  if (Array.isArray(a) && Array.isArray(b))
878
868
  return isSameArray(a, b);
879
869
  if (a instanceof Date && b instanceof Date)
@@ -887,8 +877,7 @@ function isEqual(a, b) {
887
877
  if (a instanceof DataView && b instanceof DataView)
888
878
  return dataViewsAreEqual(a, b);
889
879
  if (isTypedArray(a) && isTypedArray(b)) {
890
- if (a.byteLength !== b.byteLength)
891
- return false;
880
+ if (a.byteLength !== b.byteLength) return false;
892
881
  return isSameArray(a, b);
893
882
  }
894
883
  return false;
@@ -896,25 +885,20 @@ function isEqual(a, b) {
896
885
  function isSameObject(a, b) {
897
886
  const keys1 = Object.keys(a);
898
887
  const keys2 = Object.keys(b);
899
- if (!isEqual(keys1, keys2))
900
- return false;
888
+ if (!isEqual(keys1, keys2)) return false;
901
889
  for (const key of keys1) {
902
- if (!isEqual(a[key], b[key]))
903
- return false;
890
+ if (!isEqual(a[key], b[key])) return false;
904
891
  }
905
892
  return true;
906
893
  }
907
894
  function isSameArray(a, b) {
908
- if (a.length !== b.length)
909
- return false;
895
+ if (a.length !== b.length) return false;
910
896
  return a.every((element, index) => isEqual(element, b[index]));
911
897
  }
912
898
  function dataViewsAreEqual(a, b) {
913
- if (a.byteLength !== b.byteLength)
914
- return false;
899
+ if (a.byteLength !== b.byteLength) return false;
915
900
  for (let offset = 0; offset < a.byteLength; offset++) {
916
- if (a.getUint8(offset) !== b.getUint8(offset))
917
- return false;
901
+ if (a.getUint8(offset) !== b.getUint8(offset)) return false;
918
902
  }
919
903
  return true;
920
904
  }