es-toolkit 1.17.0 → 1.18.0-dev.573

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 (221) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/dist/_chunk/{index-CoqN5B.js → index-BGZDR9.js} +4 -1
  4. package/dist/_chunk/{isTypedArray-BBEkFl.js → isTypedArray-Dsrnb1.js} +1 -11
  5. package/dist/_chunk/{isFunction-aCEz9d.js → isWeakSet-BerD1A.js} +12 -2
  6. package/dist/_chunk/rest-CXt9w3.js +182 -0
  7. package/dist/_chunk/{toMerged-BGwYW5.js → toMerged-DN1PPP.js} +1 -1
  8. package/dist/_chunk/{initial-Ci2bn_.js → zipWith-CYaH1Y.js} +46 -70
  9. package/dist/array/countBy.d.mts +10 -0
  10. package/dist/array/countBy.d.ts +10 -0
  11. package/dist/array/fill.d.mts +55 -2
  12. package/dist/array/fill.d.ts +55 -2
  13. package/dist/array/flatMapDeep.d.mts +18 -0
  14. package/dist/array/flatMapDeep.d.ts +18 -0
  15. package/dist/array/flatMapDeep.mjs +7 -0
  16. package/dist/array/flattenDeep.d.mts +1 -1
  17. package/dist/array/flattenDeep.d.ts +1 -1
  18. package/dist/array/head.d.mts +14 -3
  19. package/dist/array/head.d.ts +14 -3
  20. package/dist/array/index.d.mts +9 -8
  21. package/dist/array/index.d.ts +9 -8
  22. package/dist/array/index.js +87 -58
  23. package/dist/array/index.mjs +9 -8
  24. package/dist/array/last.d.mts +23 -1
  25. package/dist/array/last.d.ts +23 -1
  26. package/dist/array/maxBy.d.mts +13 -1
  27. package/dist/array/maxBy.d.ts +13 -1
  28. package/dist/array/minBy.d.mts +13 -1
  29. package/dist/array/minBy.d.ts +13 -1
  30. package/dist/array/toFilled.d.mts +59 -2
  31. package/dist/array/toFilled.d.ts +59 -2
  32. package/dist/array/zip.d.mts +65 -7
  33. package/dist/array/zip.d.ts +65 -7
  34. package/dist/array/zipObject.d.mts +2 -4
  35. package/dist/array/zipObject.d.ts +2 -4
  36. package/dist/array/zipWith.d.mts +39 -6
  37. package/dist/array/zipWith.d.ts +39 -6
  38. package/dist/browser.global.js +1 -1
  39. package/dist/browser.global.js.map +1 -1
  40. package/dist/compat/_internal/compareValues.mjs +30 -5
  41. package/dist/compat/_internal/normalizeForCase.mjs +9 -0
  42. package/dist/compat/array/castArray.d.mts +29 -0
  43. package/dist/compat/array/castArray.d.ts +29 -0
  44. package/dist/compat/array/castArray.mjs +8 -0
  45. package/dist/compat/array/difference.d.mts +19 -0
  46. package/dist/compat/array/difference.d.ts +19 -0
  47. package/dist/compat/array/fill.d.mts +55 -2
  48. package/dist/compat/array/fill.d.ts +55 -2
  49. package/dist/compat/array/findLastIndex.d.mts +66 -0
  50. package/dist/compat/array/findLastIndex.d.ts +66 -0
  51. package/dist/compat/array/findLastIndex.mjs +33 -0
  52. package/dist/compat/array/join.d.mts +16 -0
  53. package/dist/compat/array/join.d.ts +16 -0
  54. package/dist/compat/array/join.mjs +5 -0
  55. package/dist/compat/array/orderBy.d.mts +6 -6
  56. package/dist/compat/array/orderBy.d.ts +6 -6
  57. package/dist/compat/array/orderBy.mjs +26 -18
  58. package/dist/compat/array/some.d.mts +86 -0
  59. package/dist/compat/array/some.d.ts +86 -0
  60. package/dist/compat/array/some.mjs +36 -0
  61. package/dist/compat/array/sortBy.d.mts +34 -0
  62. package/dist/compat/array/sortBy.d.ts +34 -0
  63. package/dist/compat/array/sortBy.mjs +7 -0
  64. package/dist/compat/function/ary.d.mts +11 -1
  65. package/dist/compat/function/ary.d.ts +11 -1
  66. package/dist/compat/function/attempt.d.mts +33 -0
  67. package/dist/compat/function/attempt.d.ts +33 -0
  68. package/dist/compat/function/attempt.mjs +10 -0
  69. package/dist/compat/function/bindKey.d.mts +45 -0
  70. package/dist/compat/function/bindKey.d.ts +45 -0
  71. package/dist/compat/function/bindKey.mjs +27 -0
  72. package/dist/compat/function/rearg.d.mts +18 -0
  73. package/dist/compat/function/rearg.d.ts +18 -0
  74. package/dist/compat/function/rearg.mjs +14 -0
  75. package/dist/compat/function/spread.d.mts +47 -0
  76. package/dist/compat/function/spread.d.ts +47 -0
  77. package/dist/compat/function/spread.mjs +16 -0
  78. package/dist/compat/index.d.mts +31 -10
  79. package/dist/compat/index.d.ts +31 -10
  80. package/dist/compat/index.js +401 -143
  81. package/dist/compat/index.mjs +32 -11
  82. package/dist/compat/math/max.d.mts +16 -5
  83. package/dist/compat/math/max.d.ts +16 -5
  84. package/dist/compat/math/min.d.mts +16 -4
  85. package/dist/compat/math/min.d.ts +16 -4
  86. package/dist/compat/math/parseInt.d.mts +20 -0
  87. package/dist/compat/math/parseInt.d.ts +20 -0
  88. package/dist/compat/math/parseInt.mjs +8 -0
  89. package/dist/compat/object/fromPairs.d.mts +29 -0
  90. package/dist/compat/object/fromPairs.d.ts +29 -0
  91. package/dist/compat/object/fromPairs.mjs +14 -0
  92. package/dist/compat/predicate/conforms.d.mts +22 -0
  93. package/dist/compat/predicate/conforms.d.ts +22 -0
  94. package/dist/compat/predicate/conforms.mjs +11 -0
  95. package/dist/compat/predicate/conformsTo.d.mts +29 -0
  96. package/dist/compat/predicate/conformsTo.d.ts +29 -0
  97. package/dist/compat/predicate/conformsTo.mjs +18 -0
  98. package/dist/compat/predicate/isObject.d.mts +26 -0
  99. package/dist/compat/predicate/isObject.d.ts +26 -0
  100. package/dist/compat/predicate/isObject.mjs +5 -0
  101. package/dist/compat/predicate/isRegExp.d.mts +7 -0
  102. package/dist/compat/predicate/isRegExp.d.ts +7 -0
  103. package/dist/compat/predicate/isTypedArray.d.mts +10 -0
  104. package/dist/compat/predicate/isTypedArray.d.ts +10 -0
  105. package/dist/compat/predicate/isWeakMap.d.mts +23 -0
  106. package/dist/compat/predicate/isWeakMap.d.ts +23 -0
  107. package/dist/compat/predicate/isWeakMap.mjs +7 -0
  108. package/dist/compat/predicate/isWeakSet.d.mts +23 -0
  109. package/dist/compat/predicate/isWeakSet.d.ts +23 -0
  110. package/dist/compat/predicate/isWeakSet.mjs +7 -0
  111. package/dist/compat/string/camelCase.d.mts +18 -0
  112. package/dist/compat/string/camelCase.d.ts +18 -0
  113. package/dist/compat/string/camelCase.mjs +8 -0
  114. package/dist/compat/string/endsWith.d.mts +1 -1
  115. package/dist/compat/string/endsWith.d.ts +1 -1
  116. package/dist/compat/string/endsWith.mjs +2 -2
  117. package/dist/compat/string/repeat.d.mts +17 -0
  118. package/dist/compat/string/repeat.d.ts +17 -0
  119. package/dist/compat/string/repeat.mjs +5 -0
  120. package/dist/compat/string/startsWith.d.mts +1 -1
  121. package/dist/compat/string/startsWith.d.ts +1 -1
  122. package/dist/compat/string/startsWith.mjs +2 -2
  123. package/dist/function/after.d.mts +1 -1
  124. package/dist/function/after.d.ts +1 -1
  125. package/dist/function/after.mjs +2 -2
  126. package/dist/function/before.d.mts +1 -1
  127. package/dist/function/before.d.ts +1 -1
  128. package/dist/function/before.mjs +2 -2
  129. package/dist/function/debounce.d.mts +3 -3
  130. package/dist/function/debounce.d.ts +3 -3
  131. package/dist/function/index.d.mts +1 -0
  132. package/dist/function/index.d.ts +1 -0
  133. package/dist/function/index.js +22 -180
  134. package/dist/function/index.mjs +1 -0
  135. package/dist/function/memoize.d.mts +37 -1
  136. package/dist/function/memoize.d.ts +37 -1
  137. package/dist/function/negate.d.mts +7 -1
  138. package/dist/function/negate.d.ts +7 -1
  139. package/dist/function/spread.d.mts +19 -0
  140. package/dist/function/spread.d.ts +19 -0
  141. package/dist/function/spread.mjs +7 -0
  142. package/dist/function/unary.d.mts +7 -0
  143. package/dist/function/unary.d.ts +7 -0
  144. package/dist/index.d.mts +16 -8
  145. package/dist/index.d.ts +16 -8
  146. package/dist/index.js +89 -80
  147. package/dist/index.mjs +16 -8
  148. package/dist/math/clamp.d.mts +14 -3
  149. package/dist/math/clamp.d.ts +14 -3
  150. package/dist/math/random.d.mts +13 -2
  151. package/dist/math/random.d.ts +13 -2
  152. package/dist/math/randomInt.d.mts +11 -3
  153. package/dist/math/randomInt.d.ts +11 -3
  154. package/dist/math/range.d.mts +25 -0
  155. package/dist/math/range.d.ts +25 -0
  156. package/dist/object/index.js +1 -1
  157. package/dist/object/invert.d.mts +2 -4
  158. package/dist/object/invert.d.ts +2 -4
  159. package/dist/predicate/index.d.mts +2 -0
  160. package/dist/predicate/index.d.ts +2 -0
  161. package/dist/predicate/index.js +11 -9
  162. package/dist/predicate/index.mjs +2 -0
  163. package/dist/predicate/isNotNil.mjs +1 -1
  164. package/dist/predicate/isPrimitive.d.mts +14 -0
  165. package/dist/predicate/isPrimitive.d.ts +14 -0
  166. package/dist/predicate/isRegExp.d.mts +8 -1
  167. package/dist/predicate/isRegExp.d.ts +8 -1
  168. package/dist/predicate/isSymbol.d.mts +15 -0
  169. package/dist/predicate/isSymbol.d.ts +15 -0
  170. package/dist/predicate/isTypedArray.d.mts +10 -0
  171. package/dist/predicate/isTypedArray.d.ts +10 -0
  172. package/dist/predicate/isTypedArray.mjs +1 -11
  173. package/dist/predicate/isWeakMap.d.mts +23 -0
  174. package/dist/predicate/isWeakMap.d.ts +23 -0
  175. package/dist/predicate/isWeakMap.mjs +5 -0
  176. package/dist/predicate/isWeakSet.d.mts +23 -0
  177. package/dist/predicate/isWeakSet.d.ts +23 -0
  178. package/dist/predicate/isWeakSet.mjs +5 -0
  179. package/dist/promise/delay.mjs +4 -1
  180. package/dist/promise/index.js +1 -1
  181. package/dist/promise/timeout.d.mts +7 -0
  182. package/dist/promise/timeout.d.ts +7 -0
  183. package/dist/string/capitalize.d.mts +1 -1
  184. package/dist/string/capitalize.d.ts +1 -1
  185. package/dist/string/capitalize.mjs +2 -2
  186. package/dist/string/deburr.mjs +5 -5
  187. package/dist/string/escape.d.mts +16 -0
  188. package/dist/string/escape.d.ts +16 -0
  189. package/dist/string/escape.mjs +12 -0
  190. package/dist/string/escapeRegExp.d.mts +14 -0
  191. package/dist/string/escapeRegExp.d.ts +14 -0
  192. package/dist/string/escapeRegExp.mjs +5 -0
  193. package/dist/string/index.d.mts +4 -0
  194. package/dist/string/index.d.ts +4 -0
  195. package/dist/string/index.js +53 -19
  196. package/dist/string/index.mjs +4 -0
  197. package/dist/string/kebabCase.d.mts +1 -1
  198. package/dist/string/kebabCase.d.ts +1 -1
  199. package/dist/string/kebabCase.mjs +2 -2
  200. package/dist/string/lowerCase.d.mts +1 -1
  201. package/dist/string/lowerCase.d.ts +1 -1
  202. package/dist/string/lowerCase.mjs +2 -2
  203. package/dist/string/lowerFirst.d.mts +1 -1
  204. package/dist/string/lowerFirst.d.ts +1 -1
  205. package/dist/string/lowerFirst.mjs +2 -2
  206. package/dist/string/pad.d.mts +19 -0
  207. package/dist/string/pad.d.ts +19 -0
  208. package/dist/string/pad.mjs +5 -0
  209. package/dist/string/pascalCase.d.mts +1 -1
  210. package/dist/string/pascalCase.d.ts +1 -1
  211. package/dist/string/pascalCase.mjs +2 -2
  212. package/dist/string/snakeCase.d.mts +1 -1
  213. package/dist/string/snakeCase.d.ts +1 -1
  214. package/dist/string/snakeCase.mjs +2 -2
  215. package/dist/string/unescape.d.mts +16 -0
  216. package/dist/string/unescape.d.ts +16 -0
  217. package/dist/string/unescape.mjs +12 -0
  218. package/dist/string/upperFirst.d.mts +1 -1
  219. package/dist/string/upperFirst.d.ts +1 -1
  220. package/dist/string/upperFirst.mjs +2 -2
  221. package/package.json +7 -2
@@ -6,8 +6,6 @@
6
6
  * @template U - The type of the value to fill the new array with.
7
7
  * @param {Array<T>} arr - The array to base the new array on.
8
8
  * @param {U} value - The value to fill the new array with.
9
- * @param {number} [start=0] - The start position. Defaults to 0.
10
- * @param {number} [end=arr.length] - The end position. Defaults to the array's length.
11
9
  * @returns {Array<T | U>} The new array with the filled values.
12
10
  *
13
11
  * @example
@@ -29,7 +27,66 @@
29
27
  * console.log(array); // [1, 2, 3, 4, 5]
30
28
  */
31
29
  declare function toFilled<T, U>(arr: readonly T[], value: U): Array<T | U>;
30
+ /**
31
+ * Creates a new array filled with the specified value from the start position up to, but not including, the end position.
32
+ * This function does not mutate the original array.
33
+ *
34
+ * @template T - The type of elements in the original array.
35
+ * @template U - The type of the value to fill the new array with.
36
+ * @param {Array<T>} arr - The array to base the new array on.
37
+ * @param {U} value - The value to fill the new array with.
38
+ * @param {number} [start=0] - The start position. Defaults to 0.
39
+ * @returns {Array<T | U>} The new array with the filled values.
40
+ *
41
+ * @example
42
+ * const array = [1, 2, 3, 4, 5];
43
+ * let result = toFilled(array, '*', 2);
44
+ * console.log(result); // [1, 2, '*', '*', '*']
45
+ * console.log(array); // [1, 2, 3, 4, 5]
46
+ *
47
+ * result = toFilled(array, '*', 1, 4);
48
+ * console.log(result); // [1, '*', '*', '*', 5]
49
+ * console.log(array); // [1, 2, 3, 4, 5]
50
+ *
51
+ * result = toFilled(array, '*');
52
+ * console.log(result); // ['*', '*', '*', '*', '*']
53
+ * console.log(array); // [1, 2, 3, 4, 5]
54
+ *
55
+ * result = toFilled(array, '*', -4, -1);
56
+ * console.log(result); // [1, '*', '*', '*', 5]
57
+ * console.log(array); // [1, 2, 3, 4, 5]
58
+ */
32
59
  declare function toFilled<T, U>(arr: readonly T[], value: U, start: number): Array<T | U>;
60
+ /**
61
+ * Creates a new array filled with the specified value from the start position up to, but not including, the end position.
62
+ * This function does not mutate the original array.
63
+ *
64
+ * @template T - The type of elements in the original array.
65
+ * @template U - The type of the value to fill the new array with.
66
+ * @param {Array<T>} arr - The array to base the new array on.
67
+ * @param {U} value - The value to fill the new array with.
68
+ * @param {number} [start=0] - The start position. Defaults to 0.
69
+ * @param {number} [end=arr.length] - The end position. Defaults to the array's length.
70
+ * @returns {Array<T | U>} The new array with the filled values.
71
+ *
72
+ * @example
73
+ * const array = [1, 2, 3, 4, 5];
74
+ * let result = toFilled(array, '*', 2);
75
+ * console.log(result); // [1, 2, '*', '*', '*']
76
+ * console.log(array); // [1, 2, 3, 4, 5]
77
+ *
78
+ * result = toFilled(array, '*', 1, 4);
79
+ * console.log(result); // [1, '*', '*', '*', 5]
80
+ * console.log(array); // [1, 2, 3, 4, 5]
81
+ *
82
+ * result = toFilled(array, '*');
83
+ * console.log(result); // ['*', '*', '*', '*', '*']
84
+ * console.log(array); // [1, 2, 3, 4, 5]
85
+ *
86
+ * result = toFilled(array, '*', -4, -1);
87
+ * console.log(result); // [1, '*', '*', '*', 5]
88
+ * console.log(array); // [1, 2, 3, 4, 5]
89
+ */
33
90
  declare function toFilled<T, U>(arr: readonly T[], value: U, start: number, end: number): Array<T | U>;
34
91
 
35
92
  export { toFilled };
@@ -6,8 +6,6 @@
6
6
  * @template U - The type of the value to fill the new array with.
7
7
  * @param {Array<T>} arr - The array to base the new array on.
8
8
  * @param {U} value - The value to fill the new array with.
9
- * @param {number} [start=0] - The start position. Defaults to 0.
10
- * @param {number} [end=arr.length] - The end position. Defaults to the array's length.
11
9
  * @returns {Array<T | U>} The new array with the filled values.
12
10
  *
13
11
  * @example
@@ -29,7 +27,66 @@
29
27
  * console.log(array); // [1, 2, 3, 4, 5]
30
28
  */
31
29
  declare function toFilled<T, U>(arr: readonly T[], value: U): Array<T | U>;
30
+ /**
31
+ * Creates a new array filled with the specified value from the start position up to, but not including, the end position.
32
+ * This function does not mutate the original array.
33
+ *
34
+ * @template T - The type of elements in the original array.
35
+ * @template U - The type of the value to fill the new array with.
36
+ * @param {Array<T>} arr - The array to base the new array on.
37
+ * @param {U} value - The value to fill the new array with.
38
+ * @param {number} [start=0] - The start position. Defaults to 0.
39
+ * @returns {Array<T | U>} The new array with the filled values.
40
+ *
41
+ * @example
42
+ * const array = [1, 2, 3, 4, 5];
43
+ * let result = toFilled(array, '*', 2);
44
+ * console.log(result); // [1, 2, '*', '*', '*']
45
+ * console.log(array); // [1, 2, 3, 4, 5]
46
+ *
47
+ * result = toFilled(array, '*', 1, 4);
48
+ * console.log(result); // [1, '*', '*', '*', 5]
49
+ * console.log(array); // [1, 2, 3, 4, 5]
50
+ *
51
+ * result = toFilled(array, '*');
52
+ * console.log(result); // ['*', '*', '*', '*', '*']
53
+ * console.log(array); // [1, 2, 3, 4, 5]
54
+ *
55
+ * result = toFilled(array, '*', -4, -1);
56
+ * console.log(result); // [1, '*', '*', '*', 5]
57
+ * console.log(array); // [1, 2, 3, 4, 5]
58
+ */
32
59
  declare function toFilled<T, U>(arr: readonly T[], value: U, start: number): Array<T | U>;
60
+ /**
61
+ * Creates a new array filled with the specified value from the start position up to, but not including, the end position.
62
+ * This function does not mutate the original array.
63
+ *
64
+ * @template T - The type of elements in the original array.
65
+ * @template U - The type of the value to fill the new array with.
66
+ * @param {Array<T>} arr - The array to base the new array on.
67
+ * @param {U} value - The value to fill the new array with.
68
+ * @param {number} [start=0] - The start position. Defaults to 0.
69
+ * @param {number} [end=arr.length] - The end position. Defaults to the array's length.
70
+ * @returns {Array<T | U>} The new array with the filled values.
71
+ *
72
+ * @example
73
+ * const array = [1, 2, 3, 4, 5];
74
+ * let result = toFilled(array, '*', 2);
75
+ * console.log(result); // [1, 2, '*', '*', '*']
76
+ * console.log(array); // [1, 2, 3, 4, 5]
77
+ *
78
+ * result = toFilled(array, '*', 1, 4);
79
+ * console.log(result); // [1, '*', '*', '*', 5]
80
+ * console.log(array); // [1, 2, 3, 4, 5]
81
+ *
82
+ * result = toFilled(array, '*');
83
+ * console.log(result); // ['*', '*', '*', '*', '*']
84
+ * console.log(array); // [1, 2, 3, 4, 5]
85
+ *
86
+ * result = toFilled(array, '*', -4, -1);
87
+ * console.log(result); // [1, '*', '*', '*', 5]
88
+ * console.log(array); // [1, 2, 3, 4, 5]
89
+ */
33
90
  declare function toFilled<T, U>(arr: readonly T[], value: U, start: number, end: number): Array<T | U>;
34
91
 
35
92
  export { toFilled };
@@ -6,23 +6,81 @@
6
6
  * different lengths, the resulting array will have the length of the longest input array,
7
7
  * with undefined values for missing elements.
8
8
  *
9
- * @param {...T[][]} arrs - The arrays to zip together.
10
- * @param arr1
11
- * @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.
9
+ * @template T
10
+ * @param {T[]} arr1 - The first array to zip.
11
+ * @returns {Array<[T]>} A new array of tuples containing the corresponding elements from the input arrays.
12
+ *
13
+ * @example
14
+ * const arr1 = [1, 2, 3];
15
+ * const result = zip(arr1);
16
+ * // result will be [[1], [2], [3]]
17
+ */
18
+ declare function zip<T>(arr1: readonly T[]): Array<[T]>;
19
+ /**
20
+ * Combines multiple arrays into a single array of tuples.
21
+ *
22
+ * This function takes multiple arrays and returns a new array where each element is a tuple
23
+ * containing the corresponding elements from the input arrays. If the input arrays are of
24
+ * different lengths, the resulting array will have the length of the longest input array,
25
+ * with undefined values for missing elements.
26
+ *
27
+ * @template T, U
28
+ * @param {T[]} arr1 - The first array to zip.
29
+ * @param {U[]} arr2 - The second array to zip.
30
+ * @returns {Array<[T, U]>} A new array of tuples containing the corresponding elements from the input arrays.
12
31
  *
13
32
  * @example
14
33
  * const arr1 = [1, 2, 3];
15
34
  * const arr2 = ['a', 'b', 'c'];
16
35
  * const result = zip(arr1, arr2);
17
36
  * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
37
+ */
38
+ declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
39
+ /**
40
+ * Combines multiple arrays into a single array of tuples.
41
+ *
42
+ * This function takes multiple arrays and returns a new array where each element is a tuple
43
+ * containing the corresponding elements from the input arrays. If the input arrays are of
44
+ * different lengths, the resulting array will have the length of the longest input array,
45
+ * with undefined values for missing elements.
46
+ *
47
+ * @template T, U, V
48
+ * @param {T[]} arr1 - The first array to zip.
49
+ * @param {U[]} arr2 - The second array to zip.
50
+ * @param {V[]} arr3 - The third array to zip.
51
+ * @returns {Array<[T, U, V]>} A new array of tuples containing the corresponding elements from the input arrays.
18
52
  *
53
+ * @example
54
+ * const arr1 = [1, 2, 3];
55
+ * const arr2 = ['a', 'b', 'c'];
19
56
  * const arr3 = [true, false];
20
- * const result2 = zip(arr1, arr2, arr3);
21
- * // result2 will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
57
+ * const result = zip(arr1, arr2, arr3);
58
+ * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
22
59
  */
23
- declare function zip<T>(arr1: readonly T[]): Array<[T]>;
24
- declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
25
60
  declare function zip<T, U, V>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>;
61
+ /**
62
+ * Combines multiple arrays into a single array of tuples.
63
+ *
64
+ * This function takes multiple arrays and returns a new array where each element is a tuple
65
+ * containing the corresponding elements from the input arrays. If the input arrays are of
66
+ * different lengths, the resulting array will have the length of the longest input array,
67
+ * with undefined values for missing elements.
68
+ *
69
+ * @template T, U, V, W
70
+ * @param {T[]} arr1 - The first array to zip.
71
+ * @param {U[]} arr2 - The second array to zip.
72
+ * @param {V[]} arr3 - The third array to zip.
73
+ * @param {W[]} arr4 - The fourth array to zip.
74
+ * @returns {Array<[T, U, V, W]>} A new array of tuples containing the corresponding elements from the input arrays.
75
+ *
76
+ * @example
77
+ * const arr1 = [1, 2, 3];
78
+ * const arr2 = ['a', 'b', 'c'];
79
+ * const arr3 = [true, false];
80
+ * const arr4 = [null, null, null];
81
+ * const result = zip(arr1, arr2, arr3, arr4);
82
+ * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]
83
+ */
26
84
  declare function zip<T, U, V, W>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): Array<[T, U, V, W]>;
27
85
 
28
86
  export { zip };
@@ -6,23 +6,81 @@
6
6
  * different lengths, the resulting array will have the length of the longest input array,
7
7
  * with undefined values for missing elements.
8
8
  *
9
- * @param {...T[][]} arrs - The arrays to zip together.
10
- * @param arr1
11
- * @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.
9
+ * @template T
10
+ * @param {T[]} arr1 - The first array to zip.
11
+ * @returns {Array<[T]>} A new array of tuples containing the corresponding elements from the input arrays.
12
+ *
13
+ * @example
14
+ * const arr1 = [1, 2, 3];
15
+ * const result = zip(arr1);
16
+ * // result will be [[1], [2], [3]]
17
+ */
18
+ declare function zip<T>(arr1: readonly T[]): Array<[T]>;
19
+ /**
20
+ * Combines multiple arrays into a single array of tuples.
21
+ *
22
+ * This function takes multiple arrays and returns a new array where each element is a tuple
23
+ * containing the corresponding elements from the input arrays. If the input arrays are of
24
+ * different lengths, the resulting array will have the length of the longest input array,
25
+ * with undefined values for missing elements.
26
+ *
27
+ * @template T, U
28
+ * @param {T[]} arr1 - The first array to zip.
29
+ * @param {U[]} arr2 - The second array to zip.
30
+ * @returns {Array<[T, U]>} A new array of tuples containing the corresponding elements from the input arrays.
12
31
  *
13
32
  * @example
14
33
  * const arr1 = [1, 2, 3];
15
34
  * const arr2 = ['a', 'b', 'c'];
16
35
  * const result = zip(arr1, arr2);
17
36
  * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]
37
+ */
38
+ declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
39
+ /**
40
+ * Combines multiple arrays into a single array of tuples.
41
+ *
42
+ * This function takes multiple arrays and returns a new array where each element is a tuple
43
+ * containing the corresponding elements from the input arrays. If the input arrays are of
44
+ * different lengths, the resulting array will have the length of the longest input array,
45
+ * with undefined values for missing elements.
46
+ *
47
+ * @template T, U, V
48
+ * @param {T[]} arr1 - The first array to zip.
49
+ * @param {U[]} arr2 - The second array to zip.
50
+ * @param {V[]} arr3 - The third array to zip.
51
+ * @returns {Array<[T, U, V]>} A new array of tuples containing the corresponding elements from the input arrays.
18
52
  *
53
+ * @example
54
+ * const arr1 = [1, 2, 3];
55
+ * const arr2 = ['a', 'b', 'c'];
19
56
  * const arr3 = [true, false];
20
- * const result2 = zip(arr1, arr2, arr3);
21
- * // result2 will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
57
+ * const result = zip(arr1, arr2, arr3);
58
+ * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]
22
59
  */
23
- declare function zip<T>(arr1: readonly T[]): Array<[T]>;
24
- declare function zip<T, U>(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;
25
60
  declare function zip<T, U, V>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>;
61
+ /**
62
+ * Combines multiple arrays into a single array of tuples.
63
+ *
64
+ * This function takes multiple arrays and returns a new array where each element is a tuple
65
+ * containing the corresponding elements from the input arrays. If the input arrays are of
66
+ * different lengths, the resulting array will have the length of the longest input array,
67
+ * with undefined values for missing elements.
68
+ *
69
+ * @template T, U, V, W
70
+ * @param {T[]} arr1 - The first array to zip.
71
+ * @param {U[]} arr2 - The second array to zip.
72
+ * @param {V[]} arr3 - The third array to zip.
73
+ * @param {W[]} arr4 - The fourth array to zip.
74
+ * @returns {Array<[T, U, V, W]>} A new array of tuples containing the corresponding elements from the input arrays.
75
+ *
76
+ * @example
77
+ * const arr1 = [1, 2, 3];
78
+ * const arr2 = ['a', 'b', 'c'];
79
+ * const arr3 = [true, false];
80
+ * const arr4 = [null, null, null];
81
+ * const result = zip(arr1, arr2, arr3, arr4);
82
+ * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]
83
+ */
26
84
  declare function zip<T, U, V, W>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[]): Array<[T, U, V, W]>;
27
85
 
28
86
  export { zip };
@@ -10,7 +10,7 @@
10
10
  * @template V - The type of elements in the array.
11
11
  * @param {P[]} keys - An array of property names.
12
12
  * @param {V[]} values - An array of values corresponding to the property names.
13
- * @returns {{ [K in P]: V }} A new object composed of the given property names and values.
13
+ * @returns {Record<P, V>} - A new object composed of the given property names and values.
14
14
  *
15
15
  * @example
16
16
  * const keys = ['a', 'b', 'c'];
@@ -28,8 +28,6 @@
28
28
  * const result2 = zipObject(keys2, values2);
29
29
  * // result2 will be { a: 1, b: 2 }
30
30
  */
31
- declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]): {
32
- [K in P]: V;
33
- };
31
+ declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]): Record<P, V>;
34
32
 
35
33
  export { zipObject };
@@ -10,7 +10,7 @@
10
10
  * @template V - The type of elements in the array.
11
11
  * @param {P[]} keys - An array of property names.
12
12
  * @param {V[]} values - An array of values corresponding to the property names.
13
- * @returns {{ [K in P]: V }} A new object composed of the given property names and values.
13
+ * @returns {Record<P, V>} - A new object composed of the given property names and values.
14
14
  *
15
15
  * @example
16
16
  * const keys = ['a', 'b', 'c'];
@@ -28,8 +28,6 @@
28
28
  * const result2 = zipObject(keys2, values2);
29
29
  * // result2 will be { a: 1, b: 2 }
30
30
  */
31
- declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]): {
32
- [K in P]: V;
33
- };
31
+ declare function zipObject<P extends PropertyKey, V>(keys: P[], values: V[]): Record<P, V>;
34
32
 
35
33
  export { zipObject };
@@ -5,14 +5,8 @@
5
5
  * is the result of applying the combiner function to the corresponding elements of the input arrays.
6
6
  *
7
7
  * @template T - The type of elements in the first array.
8
- * @template U - The type of elements in the second array (optional).
9
- * @template V - The type of elements in the third array (optional).
10
- * @template W - The type of elements in the fourth array (optional).
11
8
  * @template R - The type of elements in the resulting array.
12
9
  * @param {T[]} arr1 - The first array to zip.
13
- * @param {U[]} [arr2] - The second array to zip (optional).
14
- * @param {V[]} [arr3] - The third array to zip (optional).
15
- * @param {W[]} [arr4] - The fourth array to zip (optional).
16
10
  * @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
17
11
  * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
18
12
  *
@@ -32,8 +26,47 @@
32
26
  * // result will be [`135`, `246`]
33
27
  */
34
28
  declare function zipWith<T, R>(arr1: readonly T[], combine: (item: T) => R): R[];
29
+ /**
30
+ * Combines two arrays into a single array using a custom combiner function.
31
+ *
32
+ * @template T - The type of elements in the first array.
33
+ * @template U - The type of elements in the second array.
34
+ * @template R - The type of elements in the resulting array.
35
+ * @param {T[]} arr1 - The first array to zip.
36
+ * @param {U[]} arr2 - The second array to zip.
37
+ * @param {(item1: T, item2: U) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
38
+ * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
39
+ */
35
40
  declare function zipWith<T, U, R>(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U) => R): R[];
41
+ /**
42
+ * Combines three arrays into a single array using a custom combiner function.
43
+ *
44
+ * @template T - The type of elements in the first array.
45
+ * @template U - The type of elements in the second array.
46
+ * @template V - The type of elements in the third array.
47
+ * @template R - The type of elements in the resulting array.
48
+ * @param {T[]} arr1 - The first array to zip.
49
+ * @param {U[]} arr2 - The second array to zip.
50
+ * @param {V[]} arr3 - The third array to zip.
51
+ * @param {(item1: T, item2: U, item3: V) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
52
+ * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
53
+ */
36
54
  declare function zipWith<T, U, V, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V) => R): R[];
55
+ /**
56
+ * Combines four arrays into a single array using a custom combiner function.
57
+ *
58
+ * @template T - The type of elements in the first array.
59
+ * @template U - The type of elements in the second array.
60
+ * @template V - The type of elements in the third array.
61
+ * @template W - The type of elements in the fourth array.
62
+ * @template R - The type of elements in the resulting array.
63
+ * @param {T[]} arr1 - The first array to zip.
64
+ * @param {U[]} arr2 - The second array to zip.
65
+ * @param {V[]} arr3 - The third array to zip.
66
+ * @param {W[]} arr4 - The fourth array to zip.
67
+ * @param {(item1: T, item2: U, item3: V, item4: W) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
68
+ * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
69
+ */
37
70
  declare function zipWith<T, U, V, W, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W) => R): R[];
38
71
 
39
72
  export { zipWith };
@@ -5,14 +5,8 @@
5
5
  * is the result of applying the combiner function to the corresponding elements of the input arrays.
6
6
  *
7
7
  * @template T - The type of elements in the first array.
8
- * @template U - The type of elements in the second array (optional).
9
- * @template V - The type of elements in the third array (optional).
10
- * @template W - The type of elements in the fourth array (optional).
11
8
  * @template R - The type of elements in the resulting array.
12
9
  * @param {T[]} arr1 - The first array to zip.
13
- * @param {U[]} [arr2] - The second array to zip (optional).
14
- * @param {V[]} [arr3] - The third array to zip (optional).
15
- * @param {W[]} [arr4] - The fourth array to zip (optional).
16
10
  * @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
17
11
  * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
18
12
  *
@@ -32,8 +26,47 @@
32
26
  * // result will be [`135`, `246`]
33
27
  */
34
28
  declare function zipWith<T, R>(arr1: readonly T[], combine: (item: T) => R): R[];
29
+ /**
30
+ * Combines two arrays into a single array using a custom combiner function.
31
+ *
32
+ * @template T - The type of elements in the first array.
33
+ * @template U - The type of elements in the second array.
34
+ * @template R - The type of elements in the resulting array.
35
+ * @param {T[]} arr1 - The first array to zip.
36
+ * @param {U[]} arr2 - The second array to zip.
37
+ * @param {(item1: T, item2: U) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
38
+ * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
39
+ */
35
40
  declare function zipWith<T, U, R>(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U) => R): R[];
41
+ /**
42
+ * Combines three arrays into a single array using a custom combiner function.
43
+ *
44
+ * @template T - The type of elements in the first array.
45
+ * @template U - The type of elements in the second array.
46
+ * @template V - The type of elements in the third array.
47
+ * @template R - The type of elements in the resulting array.
48
+ * @param {T[]} arr1 - The first array to zip.
49
+ * @param {U[]} arr2 - The second array to zip.
50
+ * @param {V[]} arr3 - The third array to zip.
51
+ * @param {(item1: T, item2: U, item3: V) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
52
+ * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
53
+ */
36
54
  declare function zipWith<T, U, V, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], combine: (item1: T, item2: U, item3: V) => R): R[];
55
+ /**
56
+ * Combines four arrays into a single array using a custom combiner function.
57
+ *
58
+ * @template T - The type of elements in the first array.
59
+ * @template U - The type of elements in the second array.
60
+ * @template V - The type of elements in the third array.
61
+ * @template W - The type of elements in the fourth array.
62
+ * @template R - The type of elements in the resulting array.
63
+ * @param {T[]} arr1 - The first array to zip.
64
+ * @param {U[]} arr2 - The second array to zip.
65
+ * @param {V[]} arr3 - The third array to zip.
66
+ * @param {W[]} arr4 - The fourth array to zip.
67
+ * @param {(item1: T, item2: U, item3: V, item4: W) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.
68
+ * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.
69
+ */
37
70
  declare function zipWith<T, U, V, W, R>(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[], arr4: readonly W[], combine: (item1: T, item2: U, item3: V, item4: W) => R): R[];
38
71
 
39
72
  export { zipWith };