es-toolkit 1.27.0 → 1.28.0-dev.910

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/_chunk/{isWeakSet-D8h8bS.js → isWeakSet-CvIdTA.js} +5 -0
  3. package/dist/_chunk/{toMerged-CPY8Ug.js → toMerged-AV73JV.js} +77 -65
  4. package/dist/_chunk/{upperFirst-DK_rTF.js → upperFirst-CorAVn.js} +1 -0
  5. package/dist/array/differenceBy.d.mts +10 -3
  6. package/dist/array/differenceBy.d.ts +10 -3
  7. package/dist/array/differenceWith.d.mts +11 -4
  8. package/dist/array/differenceWith.d.ts +11 -4
  9. package/dist/array/flatMap.d.mts +1 -1
  10. package/dist/array/flatMap.d.ts +1 -1
  11. package/dist/array/intersectionBy.d.mts +16 -5
  12. package/dist/array/intersectionBy.d.ts +16 -5
  13. package/dist/array/intersectionWith.d.mts +16 -4
  14. package/dist/array/intersectionWith.d.ts +16 -4
  15. package/dist/browser.global.js +1 -1
  16. package/dist/browser.global.js.map +1 -1
  17. package/dist/compat/array/dropRightWhile.d.mts +2 -2
  18. package/dist/compat/array/dropRightWhile.d.ts +2 -2
  19. package/dist/compat/array/dropRightWhile.mjs +2 -0
  20. package/dist/compat/array/dropWhile.d.mts +2 -2
  21. package/dist/compat/array/dropWhile.d.ts +2 -2
  22. package/dist/compat/array/dropWhile.mjs +2 -0
  23. package/dist/compat/array/every.d.mts +6 -6
  24. package/dist/compat/array/every.d.ts +6 -6
  25. package/dist/compat/array/every.mjs +2 -0
  26. package/dist/compat/array/filter.d.mts +4 -4
  27. package/dist/compat/array/filter.d.ts +4 -4
  28. package/dist/compat/array/filter.mjs +2 -0
  29. package/dist/compat/array/find.d.mts +6 -6
  30. package/dist/compat/array/find.d.ts +6 -6
  31. package/dist/compat/array/find.mjs +2 -0
  32. package/dist/compat/array/findIndex.d.mts +3 -3
  33. package/dist/compat/array/findIndex.d.ts +3 -3
  34. package/dist/compat/array/findIndex.mjs +2 -0
  35. package/dist/compat/array/findLastIndex.d.mts +3 -3
  36. package/dist/compat/array/findLastIndex.d.ts +3 -3
  37. package/dist/compat/array/findLastIndex.mjs +2 -0
  38. package/dist/compat/array/some.d.mts +5 -5
  39. package/dist/compat/array/some.d.ts +5 -5
  40. package/dist/compat/array/some.mjs +2 -0
  41. package/dist/compat/array/uniqBy.d.mts +34 -13
  42. package/dist/compat/array/uniqBy.d.ts +34 -13
  43. package/dist/compat/array/uniqBy.mjs +3 -16
  44. package/dist/compat/function/debounce.d.mts +7 -5
  45. package/dist/compat/function/debounce.d.ts +7 -5
  46. package/dist/compat/function/throttle.d.mts +3 -4
  47. package/dist/compat/function/throttle.d.ts +3 -4
  48. package/dist/compat/function/throttle.mjs +6 -1
  49. package/dist/compat/index.d.mts +13 -2
  50. package/dist/compat/index.d.ts +13 -2
  51. package/dist/compat/index.js +211 -69
  52. package/dist/compat/index.mjs +11 -1
  53. package/dist/compat/math/add.d.mts +18 -0
  54. package/dist/compat/math/add.d.ts +18 -0
  55. package/dist/compat/math/add.mjs +5 -0
  56. package/dist/compat/object/assignIn.d.mts +103 -0
  57. package/dist/compat/object/assignIn.d.ts +103 -0
  58. package/dist/compat/object/assignIn.mjs +20 -0
  59. package/dist/compat/object/cloneDeep.mjs +2 -24
  60. package/dist/compat/object/cloneDeepWith.d.mts +38 -0
  61. package/dist/compat/object/cloneDeepWith.d.ts +38 -0
  62. package/dist/compat/object/cloneDeepWith.mjs +35 -0
  63. package/dist/compat/object/keysIn.d.mts +26 -0
  64. package/dist/compat/object/keysIn.d.ts +26 -0
  65. package/dist/compat/object/keysIn.mjs +53 -0
  66. package/dist/compat/predicate/isElement.d.mts +13 -0
  67. package/dist/compat/predicate/isElement.d.ts +13 -0
  68. package/dist/compat/predicate/isElement.mjs +8 -0
  69. package/dist/compat/string/toUpper.d.mts +20 -0
  70. package/dist/compat/string/toUpper.d.ts +20 -0
  71. package/dist/compat/string/toUpper.mjs +7 -0
  72. package/dist/compat/string/trim.mjs +1 -1
  73. package/dist/compat/string/trimEnd.mjs +1 -1
  74. package/dist/compat/string/trimStart.mjs +1 -1
  75. package/dist/compat/string/words.d.mts +15 -0
  76. package/dist/compat/string/words.d.ts +15 -0
  77. package/dist/compat/string/words.mjs +10 -0
  78. package/dist/compat/util/gt.d.mts +15 -0
  79. package/dist/compat/util/gt.d.ts +15 -0
  80. package/dist/compat/util/gt.mjs +10 -0
  81. package/dist/compat/util/gte.d.mts +15 -0
  82. package/dist/compat/util/gte.d.ts +15 -0
  83. package/dist/compat/util/gte.mjs +10 -0
  84. package/dist/compat/util/iteratee.d.mts +1 -1
  85. package/dist/compat/util/iteratee.d.ts +1 -1
  86. package/dist/compat/util/toArray.d.mts +15 -0
  87. package/dist/compat/util/toArray.d.ts +15 -0
  88. package/dist/compat/util/toArray.mjs +20 -0
  89. package/dist/function/debounce.d.mts +24 -22
  90. package/dist/function/debounce.d.ts +24 -22
  91. package/dist/function/index.d.mts +2 -2
  92. package/dist/function/index.d.ts +2 -2
  93. package/dist/function/partial.d.mts +533 -15
  94. package/dist/function/partial.d.ts +533 -15
  95. package/dist/function/partialRight.d.mts +610 -15
  96. package/dist/function/partialRight.d.ts +610 -15
  97. package/dist/function/throttle.d.mts +7 -5
  98. package/dist/function/throttle.d.ts +7 -5
  99. package/dist/index.d.mts +4 -2
  100. package/dist/index.d.ts +4 -2
  101. package/dist/index.js +5 -3
  102. package/dist/index.mjs +2 -0
  103. package/dist/object/cloneDeep.mjs +3 -110
  104. package/dist/object/cloneDeepWith.d.mts +38 -0
  105. package/dist/object/cloneDeepWith.d.ts +38 -0
  106. package/dist/object/cloneDeepWith.mjs +121 -0
  107. package/dist/object/index.d.mts +1 -0
  108. package/dist/object/index.d.ts +1 -0
  109. package/dist/object/index.js +2 -1
  110. package/dist/object/index.mjs +1 -0
  111. package/dist/predicate/index.d.mts +1 -0
  112. package/dist/predicate/index.d.ts +1 -0
  113. package/dist/predicate/index.js +2 -1
  114. package/dist/predicate/index.mjs +1 -0
  115. package/dist/predicate/isBuffer.d.mts +21 -0
  116. package/dist/predicate/isBuffer.d.ts +21 -0
  117. package/dist/predicate/isBuffer.mjs +5 -0
  118. package/dist/string/index.js +1 -1
  119. package/package.json +1 -1
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if value is greater than other.
3
+ *
4
+ * @param {unknown} value The value to compare.
5
+ * @param {unknown} other The other value to compare.
6
+ * @returns {boolean} Returns `true` if value is greater than other, else `false`.
7
+ *
8
+ * @example
9
+ * gt(3, 1); // true
10
+ * gt(3, 3); // false
11
+ * gt(1, 3); // false
12
+ */
13
+ declare function gt(value: unknown, other: unknown): boolean;
14
+
15
+ export { gt };
@@ -0,0 +1,10 @@
1
+ import { toNumber } from './toNumber.mjs';
2
+
3
+ function gt(value, other) {
4
+ if (typeof value === 'string' && typeof other === 'string') {
5
+ return value > other;
6
+ }
7
+ return toNumber(value) > toNumber(other);
8
+ }
9
+
10
+ export { gt };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if value is greater than or equal to other.
3
+ *
4
+ * @param {unknown} value The value to compare.
5
+ * @param {unknown} other The other value to compare.
6
+ * @returns {boolean} Returns `true` if value is greater than or equal to other, else `false`.
7
+ *
8
+ * @example
9
+ * gte(3, 1); // => true
10
+ * gte(3, 3); // => true
11
+ * gte(1, 3); // => false
12
+ */
13
+ declare function gte(value: unknown, other: unknown): boolean;
14
+
15
+ export { gte };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if value is greater than or equal to other.
3
+ *
4
+ * @param {unknown} value The value to compare.
5
+ * @param {unknown} other The other value to compare.
6
+ * @returns {boolean} Returns `true` if value is greater than or equal to other, else `false`.
7
+ *
8
+ * @example
9
+ * gte(3, 1); // => true
10
+ * gte(3, 3); // => true
11
+ * gte(1, 3); // => false
12
+ */
13
+ declare function gte(value: unknown, other: unknown): boolean;
14
+
15
+ export { gte };
@@ -0,0 +1,10 @@
1
+ import { toNumber } from './toNumber.mjs';
2
+
3
+ function gte(value, other) {
4
+ if (typeof value === 'string' && typeof other === 'string') {
5
+ return value >= other;
6
+ }
7
+ return toNumber(value) >= toNumber(other);
8
+ }
9
+
10
+ export { gte };
@@ -39,6 +39,6 @@ declare function iteratee<F extends (...args: any[]) => unknown>(func: F): F;
39
39
  * const func = iteratee(['a', 1]);
40
40
  * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
41
41
  */
42
- declare function iteratee(value: symbol | number | string | object): (...args: any[]) => any;
42
+ declare function iteratee(value?: symbol | number | string | object): (...args: any[]) => any;
43
43
 
44
44
  export { iteratee };
@@ -39,6 +39,6 @@ declare function iteratee<F extends (...args: any[]) => unknown>(func: F): F;
39
39
  * const func = iteratee(['a', 1]);
40
40
  * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }
41
41
  */
42
- declare function iteratee(value: symbol | number | string | object): (...args: any[]) => any;
42
+ declare function iteratee(value?: symbol | number | string | object): (...args: any[]) => any;
43
43
 
44
44
  export { iteratee };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Converts a value to an array.
3
+ *
4
+ * @param {unknown} value - The value to convert.
5
+ * @returns {any[]} Returns the converted array.
6
+ *
7
+ * @example
8
+ * toArray({ 'a': 1, 'b': 2 }) // => returns [1,2]
9
+ * toArray('abc') // => returns ['a', 'b', 'c']
10
+ * toArray(1) // => returns []
11
+ * toArray(null) // => returns []
12
+ */
13
+ declare function toArray(value?: unknown): any[];
14
+
15
+ export { toArray };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Converts a value to an array.
3
+ *
4
+ * @param {unknown} value - The value to convert.
5
+ * @returns {any[]} Returns the converted array.
6
+ *
7
+ * @example
8
+ * toArray({ 'a': 1, 'b': 2 }) // => returns [1,2]
9
+ * toArray('abc') // => returns ['a', 'b', 'c']
10
+ * toArray(1) // => returns []
11
+ * toArray(null) // => returns []
12
+ */
13
+ declare function toArray(value?: unknown): any[];
14
+
15
+ export { toArray };
@@ -0,0 +1,20 @@
1
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
2
+ import { isMap } from '../predicate/isMap.mjs';
3
+
4
+ function toArray(value) {
5
+ if (value == null) {
6
+ return [];
7
+ }
8
+ if (isArrayLike(value) || isMap(value)) {
9
+ return Array.from(value);
10
+ }
11
+ if (typeof value === 'string') {
12
+ return value.split('');
13
+ }
14
+ if (typeof value === 'object') {
15
+ return Object.values(value);
16
+ }
17
+ return [];
18
+ }
19
+
20
+ export { toArray };
@@ -12,6 +12,28 @@ interface DebounceOptions {
12
12
  */
13
13
  edges?: Array<'leading' | 'trailing'>;
14
14
  }
15
+ interface DebouncedFunction<F extends (...args: any[]) => void> {
16
+ (...args: Parameters<F>): void;
17
+ /**
18
+ * Schedules the execution of the debounced function after the specified debounce delay.
19
+ * This method resets any existing timer, ensuring that the function is only invoked
20
+ * after the delay has elapsed since the last call to the debounced function.
21
+ * It is typically called internally whenever the debounced function is invoked.
22
+ *
23
+ * @returns {void}
24
+ */
25
+ schedule: () => void;
26
+ /**
27
+ * Cancels any pending execution of the debounced function.
28
+ * This method clears the active timer and resets any stored context or arguments.
29
+ */
30
+ cancel: () => void;
31
+ /**
32
+ * Immediately invokes the debounced function if there is a pending execution.
33
+ * This method also cancels the current timer, ensuring that the function executes right away.
34
+ */
35
+ flush: () => void;
36
+ }
15
37
  /**
16
38
  * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
17
39
  * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
@@ -47,26 +69,6 @@ interface DebounceOptions {
47
69
  * // Will cancel the debounced function call
48
70
  * controller.abort();
49
71
  */
50
- declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): ((...args: Parameters<F>) => void) & {
51
- /**
52
- * Schedules the execution of the debounced function after the specified debounce delay.
53
- * This method resets any existing timer, ensuring that the function is only invoked
54
- * after the delay has elapsed since the last call to the debounced function.
55
- * It is typically called internally whenever the debounced function is invoked.
56
- *
57
- * @returns {void}
58
- */
59
- schedule: () => void;
60
- /**
61
- * Cancels any pending execution of the debounced function.
62
- * This method clears the active timer and resets any stored context or arguments.
63
- */
64
- cancel: () => void;
65
- /**
66
- * Immediately invokes the debounced function if there is a pending execution.
67
- * This method also cancels the current timer, ensuring that the function executes right away.
68
- */
69
- flush: () => void;
70
- };
72
+ declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
71
73
 
72
- export { debounce };
74
+ export { type DebouncedFunction, debounce };
@@ -12,6 +12,28 @@ interface DebounceOptions {
12
12
  */
13
13
  edges?: Array<'leading' | 'trailing'>;
14
14
  }
15
+ interface DebouncedFunction<F extends (...args: any[]) => void> {
16
+ (...args: Parameters<F>): void;
17
+ /**
18
+ * Schedules the execution of the debounced function after the specified debounce delay.
19
+ * This method resets any existing timer, ensuring that the function is only invoked
20
+ * after the delay has elapsed since the last call to the debounced function.
21
+ * It is typically called internally whenever the debounced function is invoked.
22
+ *
23
+ * @returns {void}
24
+ */
25
+ schedule: () => void;
26
+ /**
27
+ * Cancels any pending execution of the debounced function.
28
+ * This method clears the active timer and resets any stored context or arguments.
29
+ */
30
+ cancel: () => void;
31
+ /**
32
+ * Immediately invokes the debounced function if there is a pending execution.
33
+ * This method also cancels the current timer, ensuring that the function executes right away.
34
+ */
35
+ flush: () => void;
36
+ }
15
37
  /**
16
38
  * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
17
39
  * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
@@ -47,26 +69,6 @@ interface DebounceOptions {
47
69
  * // Will cancel the debounced function call
48
70
  * controller.abort();
49
71
  */
50
- declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): ((...args: Parameters<F>) => void) & {
51
- /**
52
- * Schedules the execution of the debounced function after the specified debounce delay.
53
- * This method resets any existing timer, ensuring that the function is only invoked
54
- * after the delay has elapsed since the last call to the debounced function.
55
- * It is typically called internally whenever the debounced function is invoked.
56
- *
57
- * @returns {void}
58
- */
59
- schedule: () => void;
60
- /**
61
- * Cancels any pending execution of the debounced function.
62
- * This method clears the active timer and resets any stored context or arguments.
63
- */
64
- cancel: () => void;
65
- /**
66
- * Immediately invokes the debounced function if there is a pending execution.
67
- * This method also cancels the current timer, ensuring that the function executes right away.
68
- */
69
- flush: () => void;
70
- };
72
+ declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
71
73
 
72
- export { debounce };
74
+ export { type DebouncedFunction, debounce };
@@ -3,7 +3,7 @@ export { ary } from './ary.mjs';
3
3
  export { before } from './before.mjs';
4
4
  export { curry } from './curry.mjs';
5
5
  export { curryRight } from './curryRight.mjs';
6
- export { debounce } from './debounce.mjs';
6
+ export { DebouncedFunction, debounce } from './debounce.mjs';
7
7
  export { flow } from './flow.mjs';
8
8
  export { flowRight } from './flowRight.mjs';
9
9
  export { identity } from './identity.mjs';
@@ -15,5 +15,5 @@ export { partial } from './partial.mjs';
15
15
  export { partialRight } from './partialRight.mjs';
16
16
  export { rest } from './rest.mjs';
17
17
  export { spread } from './spread.mjs';
18
- export { throttle } from './throttle.mjs';
18
+ export { ThrottledFunction, throttle } from './throttle.mjs';
19
19
  export { unary } from './unary.mjs';
@@ -3,7 +3,7 @@ export { ary } from './ary.js';
3
3
  export { before } from './before.js';
4
4
  export { curry } from './curry.js';
5
5
  export { curryRight } from './curryRight.js';
6
- export { debounce } from './debounce.js';
6
+ export { DebouncedFunction, debounce } from './debounce.js';
7
7
  export { flow } from './flow.js';
8
8
  export { flowRight } from './flowRight.js';
9
9
  export { identity } from './identity.js';
@@ -15,5 +15,5 @@ export { partial } from './partial.js';
15
15
  export { partialRight } from './partialRight.js';
16
16
  export { rest } from './rest.js';
17
17
  export { spread } from './spread.js';
18
- export { throttle } from './throttle.js';
18
+ export { ThrottledFunction, throttle } from './throttle.js';
19
19
  export { unary } from './unary.js';