moderndash 3.11.1 → 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/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.
@@ -60,9 +61,10 @@ type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U]
60
61
 
61
62
  /**
62
63
  * Create a new array with values from the first array that are not present in the other arrays.
63
- *
64
64
  * Optionally, use a compare function to determine the comparison of elements (default is `===`).
65
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
+ *
66
68
  * @example
67
69
  * difference([2, 1], [2, 3], [6])
68
70
  * // => [1]
@@ -78,6 +80,7 @@ type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U]
78
80
  *
79
81
  * difference(arr1, arr2, (a, b) => a.id === b.id)
80
82
  * // => [{ id: 1, name: 'Yeet' }]
83
+ *
81
84
  * @param arraysOrCompareFn Two or more arrays with an optional compare function at the end
82
85
  * @template TElem The type of the array elements
83
86
  * @template TArrays The type of the arrays provided
@@ -128,7 +131,9 @@ declare function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TE
128
131
 
129
132
  /**
130
133
  * Creates an object with grouped items in the array.
131
- * @deprecated Use the javascript "Object.groupBy()" version instead.
134
+ *
135
+ * @deprecated
136
+ * **Deprecated: Use the native "Object.groupBy()" function instead.**
132
137
  *
133
138
  * @example
134
139
  * group([6.1, 4.2, 6.3], Math.floor)
@@ -150,6 +155,8 @@ declare function group<TElem, TKey extends PropertyKey>(array: readonly TElem[],
150
155
  *
151
156
  * Optionally, use a compare function for element comparison (default is `===`).
152
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
+ *
153
160
  * @example
154
161
  * intersection([2, 1], [2, 3], [6, 2])
155
162
  * // => [2]
@@ -462,8 +469,6 @@ declare function randomString(length: number, charSet?: string): string;
462
469
  *
463
470
  * Look at {@link debounce} for the non-decorator version.
464
471
  *
465
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
466
- *
467
472
  * @example
468
473
  * ```typescript
469
474
  * class TestClass {
@@ -480,7 +485,11 @@ declare function randomString(length: number, charSet?: string): string;
480
485
  * ```
481
486
  * @param wait Milliseconds to wait before invoking the decorated function after the last invocation.
482
487
  */
483
- 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
+ };
484
493
 
485
494
  /**
486
495
  * Only invokes the decorated function as long as it's called `<= n` times.
@@ -488,8 +497,6 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
488
497
  *
489
498
  * Look at {@link maxCalls} for the non-decorator version.
490
499
  *
491
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
492
- *
493
500
  * @example
494
501
  * ```typescript
495
502
  * class TestClass {
@@ -506,7 +513,7 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
506
513
  * ```
507
514
  * @param n The number of calls before the cached result is returned.
508
515
  */
509
- declare function decMaxCalls(n: number): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
516
+ declare function decMaxCalls(n: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
510
517
 
511
518
  type GenericFunction<TFunc extends (...args: any) => any> = (...args: Parameters<TFunc>) => ReturnType<TFunc>;
512
519
 
@@ -572,8 +579,6 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
572
579
  *
573
580
  * Look at {@link memoize} for the non-decorator version.
574
581
  *
575
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
576
- *
577
582
  * @example
578
583
  * ```typescript
579
584
  * class TestClass {
@@ -593,14 +598,15 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
593
598
  * @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.
594
599
  * @param options.ttl - The time to live for the cache in milliseconds.
595
600
  */
596
- 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
+ };
597
604
 
598
605
  /**
599
606
  * Only invokes the decorated function after it's called more than `n` times.
600
607
  *
601
608
  * Look at {@link minCalls} for the non-decorator version.
602
609
  *
603
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
604
610
  * @example
605
611
  * ```typescript
606
612
  * class TestClass {
@@ -616,15 +622,13 @@ declare function decMemoize(options?: Parameters<typeof memoize>[1]): (_target:
616
622
  * ```
617
623
  * @param n The number of calls before the decorated function is invoked.
618
624
  */
619
- 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;
620
626
 
621
627
  /**
622
628
  * The decorated function is invoked at most once per every `wait` milliseconds.
623
629
  *
624
630
  * Look at {@link throttle} for the non-decorator version.
625
631
  *
626
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
627
- *
628
632
  * @example
629
633
  * ```typescript
630
634
  * class TestClass {
@@ -640,7 +644,7 @@ declare function decMinCalls(n: number): (_target: unknown, _key: string, descri
640
644
  * ```
641
645
  * @param wait The number of milliseconds to wait between invocations.
642
646
  */
643
- declare function decThrottle(wait: number): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
647
+ declare function decThrottle(wait: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
644
648
 
645
649
  type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail : never;
646
650
  /**
@@ -671,7 +675,7 @@ type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail :
671
675
  * @param func The function to transform.
672
676
  * @returns A decorator function that can be used to decorate a method.
673
677
  */
674
- 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>;
675
679
 
676
680
  /**
677
681
  * Creates a debounced version of a function. Only calling it after a specified amount of time has passed without any new calls.
@@ -825,13 +829,15 @@ declare function round(number: number, precision?: number): number;
825
829
  * @param numbers The input array of numbers
826
830
  * @returns The sum of the input array
827
831
  */
828
- declare function sum(numbers: number[]): number;
829
- declare function sum<TNum extends readonly number[]>(numbers: TNum): Call<Tuples.Sum, TNum>;
832
+ declare function sum(numbers: readonly number[]): number;
830
833
 
831
834
  type GenericObject = Record<PropertyKey, any>;
832
835
 
833
836
  type StringIfNever<Type> = [Type] extends [never] ? string : Type;
834
- type Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
837
+ type PathOrString<TObj> = StringIfNever<Paths$1<TObj, {
838
+ bracketNotation: true;
839
+ maxRecursionDepth: 20;
840
+ }>>;
835
841
  /**
836
842
  * Flattens an object into a single level object.
837
843
  *
@@ -844,7 +850,7 @@ type Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
844
850
  * @template TObj The type of the object to flatten.
845
851
  * @returns A new object with flattened keys.
846
852
  */
847
- 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>;
848
854
 
849
855
  /**
850
856
  * The type of a plain object.
@@ -1341,18 +1347,6 @@ declare function trimEnd(str: string, chars: string): string;
1341
1347
  */
1342
1348
  declare function trimStart(str: string, chars: string): string;
1343
1349
 
1344
- /**
1345
- * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`
1346
- * in a string to their corresponding characters.
1347
- *
1348
- * @example
1349
- * unescapeHtml('fred, barney, &amp; pebbles')
1350
- * // => 'fred, barney, & pebbles'
1351
- * @param str The string to unescape.
1352
- * @returns Returns the unescaped string.
1353
- */
1354
- declare function unescapeHtml(str: string): string;
1355
-
1356
1350
  /**
1357
1351
  * Truncates a string if it's longer than the given maximum length.
1358
1352
  * The last characters of the truncated string are replaced with the ellipsis
@@ -1381,6 +1375,18 @@ declare function truncate(str: string, options?: {
1381
1375
  separator?: string;
1382
1376
  }): string;
1383
1377
 
1378
+ /**
1379
+ * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`
1380
+ * in a string to their corresponding characters.
1381
+ *
1382
+ * @example
1383
+ * unescapeHtml('fred, barney, &amp; pebbles')
1384
+ * // => 'fred, barney, & pebbles'
1385
+ * @param str The string to unescape.
1386
+ * @returns Returns the unescaped string.
1387
+ */
1388
+ declare function unescapeHtml(str: string): string;
1389
+
1384
1390
  /**
1385
1391
  * Checks if a value is empty.
1386
1392
  *
@@ -1448,7 +1454,9 @@ declare function isPlainObject(value: unknown): value is PlainObject;
1448
1454
 
1449
1455
  /**
1450
1456
  * Checks if given string is a valid URL
1451
- * @deprecated Use the native "URL.canParse" method instead.
1457
+ *
1458
+ * @deprecated
1459
+ * **Deprecated: Use the native "URL.canParse" method instead.**
1452
1460
  *
1453
1461
  * @example
1454
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.
@@ -60,9 +61,10 @@ type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U]
60
61
 
61
62
  /**
62
63
  * Create a new array with values from the first array that are not present in the other arrays.
63
- *
64
64
  * Optionally, use a compare function to determine the comparison of elements (default is `===`).
65
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
+ *
66
68
  * @example
67
69
  * difference([2, 1], [2, 3], [6])
68
70
  * // => [1]
@@ -78,6 +80,7 @@ type ArrayTail<TArray extends unknown[]> = TArray extends [unknown, ...infer U]
78
80
  *
79
81
  * difference(arr1, arr2, (a, b) => a.id === b.id)
80
82
  * // => [{ id: 1, name: 'Yeet' }]
83
+ *
81
84
  * @param arraysOrCompareFn Two or more arrays with an optional compare function at the end
82
85
  * @template TElem The type of the array elements
83
86
  * @template TArrays The type of the arrays provided
@@ -128,7 +131,9 @@ declare function dropWhile<TElem>(array: readonly TElem[], predicate: (value: TE
128
131
 
129
132
  /**
130
133
  * Creates an object with grouped items in the array.
131
- * @deprecated Use the javascript "Object.groupBy()" version instead.
134
+ *
135
+ * @deprecated
136
+ * **Deprecated: Use the native "Object.groupBy()" function instead.**
132
137
  *
133
138
  * @example
134
139
  * group([6.1, 4.2, 6.3], Math.floor)
@@ -150,6 +155,8 @@ declare function group<TElem, TKey extends PropertyKey>(array: readonly TElem[],
150
155
  *
151
156
  * Optionally, use a compare function for element comparison (default is `===`).
152
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
+ *
153
160
  * @example
154
161
  * intersection([2, 1], [2, 3], [6, 2])
155
162
  * // => [2]
@@ -462,8 +469,6 @@ declare function randomString(length: number, charSet?: string): string;
462
469
  *
463
470
  * Look at {@link debounce} for the non-decorator version.
464
471
  *
465
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
466
- *
467
472
  * @example
468
473
  * ```typescript
469
474
  * class TestClass {
@@ -480,7 +485,11 @@ declare function randomString(length: number, charSet?: string): string;
480
485
  * ```
481
486
  * @param wait Milliseconds to wait before invoking the decorated function after the last invocation.
482
487
  */
483
- 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
+ };
484
493
 
485
494
  /**
486
495
  * Only invokes the decorated function as long as it's called `<= n` times.
@@ -488,8 +497,6 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
488
497
  *
489
498
  * Look at {@link maxCalls} for the non-decorator version.
490
499
  *
491
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
492
- *
493
500
  * @example
494
501
  * ```typescript
495
502
  * class TestClass {
@@ -506,7 +513,7 @@ declare function decDebounce(wait: number): (_target: unknown, _key: string, des
506
513
  * ```
507
514
  * @param n The number of calls before the cached result is returned.
508
515
  */
509
- declare function decMaxCalls(n: number): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
516
+ declare function decMaxCalls(n: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
510
517
 
511
518
  type GenericFunction<TFunc extends (...args: any) => any> = (...args: Parameters<TFunc>) => ReturnType<TFunc>;
512
519
 
@@ -572,8 +579,6 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
572
579
  *
573
580
  * Look at {@link memoize} for the non-decorator version.
574
581
  *
575
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
576
- *
577
582
  * @example
578
583
  * ```typescript
579
584
  * class TestClass {
@@ -593,14 +598,15 @@ declare function memoize<TFunc extends GenericFunction<TFunc>, Cache extends Map
593
598
  * @param options.resolver - A function that determines the cache key for storing the result based on the arguments provided.
594
599
  * @param options.ttl - The time to live for the cache in milliseconds.
595
600
  */
596
- 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
+ };
597
604
 
598
605
  /**
599
606
  * Only invokes the decorated function after it's called more than `n` times.
600
607
  *
601
608
  * Look at {@link minCalls} for the non-decorator version.
602
609
  *
603
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
604
610
  * @example
605
611
  * ```typescript
606
612
  * class TestClass {
@@ -616,15 +622,13 @@ declare function decMemoize(options?: Parameters<typeof memoize>[1]): (_target:
616
622
  * ```
617
623
  * @param n The number of calls before the decorated function is invoked.
618
624
  */
619
- 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;
620
626
 
621
627
  /**
622
628
  * The decorated function is invoked at most once per every `wait` milliseconds.
623
629
  *
624
630
  * Look at {@link throttle} for the non-decorator version.
625
631
  *
626
- * *Requires the [experimentalDecorators](https://www.typescriptlang.org/tsconfig#experimentalDecorators) flag to be set.*
627
- *
628
632
  * @example
629
633
  * ```typescript
630
634
  * class TestClass {
@@ -640,7 +644,7 @@ declare function decMinCalls(n: number): (_target: unknown, _key: string, descri
640
644
  * ```
641
645
  * @param wait The number of milliseconds to wait between invocations.
642
646
  */
643
- declare function decThrottle(wait: number): (_target: unknown, _key: string, descriptor: PropertyDescriptor) => void;
647
+ declare function decThrottle(wait: number): (originalMethod: unknown, _context: ClassMethodDecoratorContext) => GenericFunction<any>;
644
648
 
645
649
  type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail : never;
646
650
  /**
@@ -671,7 +675,7 @@ type Tail<T extends unknown[]> = T extends [infer _Head, ...infer Tail] ? Tail :
671
675
  * @param func The function to transform.
672
676
  * @returns A decorator function that can be used to decorate a method.
673
677
  */
674
- 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>;
675
679
 
676
680
  /**
677
681
  * Creates a debounced version of a function. Only calling it after a specified amount of time has passed without any new calls.
@@ -825,13 +829,15 @@ declare function round(number: number, precision?: number): number;
825
829
  * @param numbers The input array of numbers
826
830
  * @returns The sum of the input array
827
831
  */
828
- declare function sum(numbers: number[]): number;
829
- declare function sum<TNum extends readonly number[]>(numbers: TNum): Call<Tuples.Sum, TNum>;
832
+ declare function sum(numbers: readonly number[]): number;
830
833
 
831
834
  type GenericObject = Record<PropertyKey, any>;
832
835
 
833
836
  type StringIfNever<Type> = [Type] extends [never] ? string : Type;
834
- type Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
837
+ type PathOrString<TObj> = StringIfNever<Paths$1<TObj, {
838
+ bracketNotation: true;
839
+ maxRecursionDepth: 20;
840
+ }>>;
835
841
  /**
836
842
  * Flattens an object into a single level object.
837
843
  *
@@ -844,7 +850,7 @@ type Paths$1<TObj> = StringIfNever<Call<Objects.AllPaths, TObj>>;
844
850
  * @template TObj The type of the object to flatten.
845
851
  * @returns A new object with flattened keys.
846
852
  */
847
- 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>;
848
854
 
849
855
  /**
850
856
  * The type of a plain object.
@@ -1341,18 +1347,6 @@ declare function trimEnd(str: string, chars: string): string;
1341
1347
  */
1342
1348
  declare function trimStart(str: string, chars: string): string;
1343
1349
 
1344
- /**
1345
- * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`
1346
- * in a string to their corresponding characters.
1347
- *
1348
- * @example
1349
- * unescapeHtml('fred, barney, &amp; pebbles')
1350
- * // => 'fred, barney, & pebbles'
1351
- * @param str The string to unescape.
1352
- * @returns Returns the unescaped string.
1353
- */
1354
- declare function unescapeHtml(str: string): string;
1355
-
1356
1350
  /**
1357
1351
  * Truncates a string if it's longer than the given maximum length.
1358
1352
  * The last characters of the truncated string are replaced with the ellipsis
@@ -1381,6 +1375,18 @@ declare function truncate(str: string, options?: {
1381
1375
  separator?: string;
1382
1376
  }): string;
1383
1377
 
1378
+ /**
1379
+ * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`
1380
+ * in a string to their corresponding characters.
1381
+ *
1382
+ * @example
1383
+ * unescapeHtml('fred, barney, &amp; pebbles')
1384
+ * // => 'fred, barney, & pebbles'
1385
+ * @param str The string to unescape.
1386
+ * @returns Returns the unescaped string.
1387
+ */
1388
+ declare function unescapeHtml(str: string): string;
1389
+
1384
1390
  /**
1385
1391
  * Checks if a value is empty.
1386
1392
  *
@@ -1448,7 +1454,9 @@ declare function isPlainObject(value: unknown): value is PlainObject;
1448
1454
 
1449
1455
  /**
1450
1456
  * Checks if given string is a valid URL
1451
- * @deprecated Use the native "URL.canParse" method instead.
1457
+ *
1458
+ * @deprecated
1459
+ * **Deprecated: Use the native "URL.canParse" method instead.**
1452
1460
  *
1453
1461
  * @example
1454
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
  }
@@ -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 = "";
@@ -822,24 +812,10 @@ function trimStart(str, chars) {
822
812
  return str.slice(startIndex);
823
813
  }
824
814
 
825
- // src/string/unescapeHtml.ts
826
- var htmlEntitiesRegex = /&(?:amp|lt|gt|quot|#39);/g;
827
- var entityMap = /* @__PURE__ */ new Map([
828
- ["&amp;", "&"],
829
- ["&lt;", "<"],
830
- ["&gt;", ">"],
831
- ["&quot;", '"'],
832
- ["&#39;", "'"]
833
- ]);
834
- function unescapeHtml(str) {
835
- return str.replace(htmlEntitiesRegex, (entity) => entityMap.get(entity));
836
- }
837
-
838
815
  // src/string/truncate.ts
839
816
  function truncate(str, options) {
840
817
  const { length = 30, ellipsis = "...", separator } = options ?? {};
841
- if (str.length <= length)
842
- return str;
818
+ if (str.length <= length) return str;
843
819
  const end = length - ellipsis.length;
844
820
  if (end < 1)
845
821
  return ellipsis;
@@ -853,6 +829,19 @@ function truncate(str, options) {
853
829
  return truncated + ellipsis;
854
830
  }
855
831
 
832
+ // src/string/unescapeHtml.ts
833
+ var htmlEntitiesRegex = /&(?:amp|lt|gt|quot|#39);/g;
834
+ var entityMap = /* @__PURE__ */ new Map([
835
+ ["&amp;", "&"],
836
+ ["&lt;", "<"],
837
+ ["&gt;", ">"],
838
+ ["&quot;", '"'],
839
+ ["&#39;", "'"]
840
+ ]);
841
+ function unescapeHtml(str) {
842
+ return str.replace(htmlEntitiesRegex, (entity) => entityMap.get(entity));
843
+ }
844
+
856
845
  // src/validate/isEmpty.ts
857
846
  function isEmpty(value) {
858
847
  if (value === null || value === void 0)
@@ -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
- return true;
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
  }