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
@@ -0,0 +1,18 @@
1
+ import { ExtractNestedArrayType } from './flattenDeep.js';
2
+
3
+ /**
4
+ * Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.
5
+ *
6
+ * @template T - The type of elements within the array.
7
+ * @template U - The type of elements within the returned array from the iteratee function.
8
+ * @param {T[]} arr - The array to flatten.
9
+ * @param {(item: T) => U} iteratee - The function that produces the new array elements.
10
+ * @returns {Array<ExtractNestedArrayType<U>>} A new array that has been flattened.
11
+ *
12
+ * @example
13
+ * const result = flatMapDeep([1, 2, 3], n => [[n, n]]);
14
+ * // [1, 1, 2, 2, 3, 3]
15
+ */
16
+ declare function flatMapDeep<T, U>(arr: readonly T[], iteratee: (item: T) => U): Array<ExtractNestedArrayType<U>>;
17
+
18
+ export { flatMapDeep };
@@ -0,0 +1,7 @@
1
+ import { flattenDeep } from './flattenDeep.mjs';
2
+
3
+ function flatMapDeep(arr, iteratee) {
4
+ return flattenDeep(arr.map((item) => iteratee(item)));
5
+ }
6
+
7
+ export { flatMapDeep };
@@ -22,4 +22,4 @@ type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNeste
22
22
  */
23
23
  declare function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>>;
24
24
 
25
- export { flattenDeep };
25
+ export { type ExtractNestedArrayType, flattenDeep };
@@ -22,4 +22,4 @@ type ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNeste
22
22
  */
23
23
  declare function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>>;
24
24
 
25
- export { flattenDeep };
25
+ export { type ExtractNestedArrayType, flattenDeep };
@@ -5,19 +5,30 @@
5
5
  * If the array is empty, the function returns `undefined`.
6
6
  *
7
7
  * @template T - The type of elements in the array.
8
- * @param {T[]} arr - The array from which to get the first element.
9
- * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
8
+ * @param {[T, ...T[]]} arr - A non-empty array from which to get the first element.
9
+ * @returns {T} The first element of the array.
10
10
  *
11
11
  * @example
12
12
  * const arr = [1, 2, 3];
13
13
  * const firstElement = head(arr);
14
14
  * // firstElement will be 1
15
+ */
16
+ declare function head<T>(arr: readonly [T, ...T[]]): T;
17
+ /**
18
+ * Returns the first element of an array or `undefined` if the array is empty.
19
+ *
20
+ * This function takes an array and returns the first element of the array.
21
+ * If the array is empty, the function returns `undefined`.
15
22
  *
23
+ * @template T - The type of elements in the array.
24
+ * @param {T[]} arr - The array from which to get the first element.
25
+ * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
26
+ *
27
+ * @example
16
28
  * const emptyArr: number[] = [];
17
29
  * const noElement = head(emptyArr);
18
30
  * // noElement will be undefined
19
31
  */
20
- declare function head<T>(arr: readonly [T, ...T[]]): T;
21
32
  declare function head<T>(arr: readonly T[]): T | undefined;
22
33
 
23
34
  export { head };
@@ -5,19 +5,30 @@
5
5
  * If the array is empty, the function returns `undefined`.
6
6
  *
7
7
  * @template T - The type of elements in the array.
8
- * @param {T[]} arr - The array from which to get the first element.
9
- * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
8
+ * @param {[T, ...T[]]} arr - A non-empty array from which to get the first element.
9
+ * @returns {T} The first element of the array.
10
10
  *
11
11
  * @example
12
12
  * const arr = [1, 2, 3];
13
13
  * const firstElement = head(arr);
14
14
  * // firstElement will be 1
15
+ */
16
+ declare function head<T>(arr: readonly [T, ...T[]]): T;
17
+ /**
18
+ * Returns the first element of an array or `undefined` if the array is empty.
19
+ *
20
+ * This function takes an array and returns the first element of the array.
21
+ * If the array is empty, the function returns `undefined`.
15
22
  *
23
+ * @template T - The type of elements in the array.
24
+ * @param {T[]} arr - The array from which to get the first element.
25
+ * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
26
+ *
27
+ * @example
16
28
  * const emptyArr: number[] = [];
17
29
  * const noElement = head(emptyArr);
18
30
  * // noElement will be undefined
19
31
  */
20
- declare function head<T>(arr: readonly [T, ...T[]]): T;
21
32
  declare function head<T>(arr: readonly T[]): T | undefined;
22
33
 
23
34
  export { head };
@@ -11,27 +11,34 @@ export { dropRightWhile } from './dropRightWhile.mjs';
11
11
  export { dropWhile } from './dropWhile.mjs';
12
12
  export { fill } from './fill.mjs';
13
13
  export { flatMap } from './flatMap.mjs';
14
+ export { flatMapDeep } from './flatMapDeep.mjs';
14
15
  export { flatten } from './flatten.mjs';
15
16
  export { flattenDeep } from './flattenDeep.mjs';
16
17
  export { forEachRight } from './forEachRight.mjs';
17
18
  export { groupBy } from './groupBy.mjs';
19
+ export { head } from './head.mjs';
20
+ export { initial } from './initial.mjs';
18
21
  export { intersection } from './intersection.mjs';
19
22
  export { intersectionBy } from './intersectionBy.mjs';
20
23
  export { intersectionWith } from './intersectionWith.mjs';
24
+ export { isSubset } from './isSubset.mjs';
21
25
  export { keyBy } from './keyBy.mjs';
26
+ export { last } from './last.mjs';
22
27
  export { maxBy } from './maxBy.mjs';
23
28
  export { minBy } from './minBy.mjs';
24
29
  export { orderBy } from './orderBy.mjs';
25
30
  export { partition } from './partition.mjs';
26
31
  export { pullAt } from './pullAt.mjs';
27
- export { sortBy } from './sortBy.mjs';
28
32
  export { sample } from './sample.mjs';
29
33
  export { sampleSize } from './sampleSize.mjs';
30
34
  export { shuffle } from './shuffle.mjs';
35
+ export { sortBy } from './sortBy.mjs';
36
+ export { tail } from './tail.mjs';
31
37
  export { take } from './take.mjs';
32
38
  export { takeRight } from './takeRight.mjs';
33
39
  export { takeRightWhile } from './takeRightWhile.mjs';
34
40
  export { takeWhile } from './takeWhile.mjs';
41
+ export { toFilled } from './toFilled.mjs';
35
42
  export { union } from './union.mjs';
36
43
  export { unionBy } from './unionBy.mjs';
37
44
  export { unionWith } from './unionWith.mjs';
@@ -40,16 +47,10 @@ export { uniqBy } from './uniqBy.mjs';
40
47
  export { uniqWith } from './uniqWith.mjs';
41
48
  export { unzip } from './unzip.mjs';
42
49
  export { unzipWith } from './unzipWith.mjs';
50
+ export { without } from './without.mjs';
43
51
  export { xor } from './xor.mjs';
44
52
  export { xorBy } from './xorBy.mjs';
45
53
  export { xorWith } from './xorWith.mjs';
46
54
  export { zip } from './zip.mjs';
47
55
  export { zipObject } from './zipObject.mjs';
48
56
  export { zipWith } from './zipWith.mjs';
49
- export { without } from './without.mjs';
50
- export { head } from './head.mjs';
51
- export { isSubset } from './isSubset.mjs';
52
- export { tail } from './tail.mjs';
53
- export { toFilled } from './toFilled.mjs';
54
- export { last } from './last.mjs';
55
- export { initial } from './initial.mjs';
@@ -11,27 +11,34 @@ export { dropRightWhile } from './dropRightWhile.js';
11
11
  export { dropWhile } from './dropWhile.js';
12
12
  export { fill } from './fill.js';
13
13
  export { flatMap } from './flatMap.js';
14
+ export { flatMapDeep } from './flatMapDeep.js';
14
15
  export { flatten } from './flatten.js';
15
16
  export { flattenDeep } from './flattenDeep.js';
16
17
  export { forEachRight } from './forEachRight.js';
17
18
  export { groupBy } from './groupBy.js';
19
+ export { head } from './head.js';
20
+ export { initial } from './initial.js';
18
21
  export { intersection } from './intersection.js';
19
22
  export { intersectionBy } from './intersectionBy.js';
20
23
  export { intersectionWith } from './intersectionWith.js';
24
+ export { isSubset } from './isSubset.js';
21
25
  export { keyBy } from './keyBy.js';
26
+ export { last } from './last.js';
22
27
  export { maxBy } from './maxBy.js';
23
28
  export { minBy } from './minBy.js';
24
29
  export { orderBy } from './orderBy.js';
25
30
  export { partition } from './partition.js';
26
31
  export { pullAt } from './pullAt.js';
27
- export { sortBy } from './sortBy.js';
28
32
  export { sample } from './sample.js';
29
33
  export { sampleSize } from './sampleSize.js';
30
34
  export { shuffle } from './shuffle.js';
35
+ export { sortBy } from './sortBy.js';
36
+ export { tail } from './tail.js';
31
37
  export { take } from './take.js';
32
38
  export { takeRight } from './takeRight.js';
33
39
  export { takeRightWhile } from './takeRightWhile.js';
34
40
  export { takeWhile } from './takeWhile.js';
41
+ export { toFilled } from './toFilled.js';
35
42
  export { union } from './union.js';
36
43
  export { unionBy } from './unionBy.js';
37
44
  export { unionWith } from './unionWith.js';
@@ -40,16 +47,10 @@ export { uniqBy } from './uniqBy.js';
40
47
  export { uniqWith } from './uniqWith.js';
41
48
  export { unzip } from './unzip.js';
42
49
  export { unzipWith } from './unzipWith.js';
50
+ export { without } from './without.js';
43
51
  export { xor } from './xor.js';
44
52
  export { xorBy } from './xorBy.js';
45
53
  export { xorWith } from './xorWith.js';
46
54
  export { zip } from './zip.js';
47
55
  export { zipObject } from './zipObject.js';
48
56
  export { zipWith } from './zipWith.js';
49
- export { without } from './without.js';
50
- export { head } from './head.js';
51
- export { isSubset } from './isSubset.js';
52
- export { tail } from './tail.js';
53
- export { toFilled } from './toFilled.js';
54
- export { last } from './last.js';
55
- export { initial } from './initial.js';
@@ -2,64 +2,93 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const initial = require('../_chunk/initial-Ci2bn_.js');
5
+ const zipWith = require('../_chunk/zipWith-CYaH1Y.js');
6
6
 
7
- function flattenDeep(arr) {
8
- return initial.flatten(arr, Infinity);
7
+ function compareValues(a, b, order) {
8
+ if (a < b) {
9
+ return order === 'asc' ? -1 : 1;
10
+ }
11
+ if (a > b) {
12
+ return order === 'asc' ? 1 : -1;
13
+ }
14
+ return 0;
9
15
  }
10
16
 
11
- exports.at = initial.at;
12
- exports.chunk = initial.chunk;
13
- exports.compact = initial.compact;
14
- exports.countBy = initial.countBy;
15
- exports.difference = initial.difference;
16
- exports.differenceBy = initial.differenceBy;
17
- exports.differenceWith = initial.differenceWith;
18
- exports.drop = initial.drop;
19
- exports.dropRight = initial.dropRight;
20
- exports.dropRightWhile = initial.dropRightWhile;
21
- exports.dropWhile = initial.dropWhile;
22
- exports.fill = initial.fill;
23
- exports.flatMap = initial.flatMap;
24
- exports.flatten = initial.flatten;
25
- exports.forEachRight = initial.forEachRight;
26
- exports.groupBy = initial.groupBy;
27
- exports.head = initial.head;
28
- exports.initial = initial.initial;
29
- exports.intersection = initial.intersection;
30
- exports.intersectionBy = initial.intersectionBy;
31
- exports.intersectionWith = initial.intersectionWith;
32
- exports.isSubset = initial.isSubset;
33
- exports.keyBy = initial.keyBy;
34
- exports.last = initial.last;
35
- exports.maxBy = initial.maxBy;
36
- exports.minBy = initial.minBy;
37
- exports.orderBy = initial.orderBy;
38
- exports.partition = initial.partition;
39
- exports.pullAt = initial.pullAt;
40
- exports.sample = initial.sample;
41
- exports.sampleSize = initial.sampleSize;
42
- exports.shuffle = initial.shuffle;
43
- exports.sortBy = initial.sortBy;
44
- exports.tail = initial.tail;
45
- exports.take = initial.take;
46
- exports.takeRight = initial.takeRight;
47
- exports.takeRightWhile = initial.takeRightWhile;
48
- exports.takeWhile = initial.takeWhile;
49
- exports.toFilled = initial.toFilled;
50
- exports.union = initial.union;
51
- exports.unionBy = initial.unionBy;
52
- exports.unionWith = initial.unionWith;
53
- exports.uniq = initial.uniq;
54
- exports.uniqBy = initial.uniqBy;
55
- exports.uniqWith = initial.uniqWith;
56
- exports.unzip = initial.unzip;
57
- exports.unzipWith = initial.unzipWith;
58
- exports.without = initial.without;
59
- exports.xor = initial.xor;
60
- exports.xorBy = initial.xorBy;
61
- exports.xorWith = initial.xorWith;
62
- exports.zip = initial.zip;
63
- exports.zipObject = initial.zipObject;
64
- exports.zipWith = initial.zipWith;
65
- exports.flattenDeep = flattenDeep;
17
+ function orderBy(arr, criteria, orders) {
18
+ return arr.slice().sort((a, b) => {
19
+ const ordersLength = orders.length;
20
+ for (let i = 0; i < criteria.length; i++) {
21
+ const order = ordersLength > i ? orders[i] : orders[ordersLength - 1];
22
+ const criterion = criteria[i];
23
+ const criterionIsFunction = typeof criterion === 'function';
24
+ const valueA = criterionIsFunction ? criterion(a) : a[criterion];
25
+ const valueB = criterionIsFunction ? criterion(b) : b[criterion];
26
+ const result = compareValues(valueA, valueB, order);
27
+ if (result !== 0) {
28
+ return result;
29
+ }
30
+ }
31
+ return 0;
32
+ });
33
+ }
34
+
35
+ function sortBy(arr, criteria) {
36
+ return orderBy(arr, criteria, ['asc']);
37
+ }
38
+
39
+ exports.at = zipWith.at;
40
+ exports.chunk = zipWith.chunk;
41
+ exports.compact = zipWith.compact;
42
+ exports.countBy = zipWith.countBy;
43
+ exports.difference = zipWith.difference;
44
+ exports.differenceBy = zipWith.differenceBy;
45
+ exports.differenceWith = zipWith.differenceWith;
46
+ exports.drop = zipWith.drop;
47
+ exports.dropRight = zipWith.dropRight;
48
+ exports.dropRightWhile = zipWith.dropRightWhile;
49
+ exports.dropWhile = zipWith.dropWhile;
50
+ exports.fill = zipWith.fill;
51
+ exports.flatMap = zipWith.flatMap;
52
+ exports.flatMapDeep = zipWith.flatMapDeep;
53
+ exports.flatten = zipWith.flatten;
54
+ exports.flattenDeep = zipWith.flattenDeep;
55
+ exports.forEachRight = zipWith.forEachRight;
56
+ exports.groupBy = zipWith.groupBy;
57
+ exports.head = zipWith.head;
58
+ exports.initial = zipWith.initial;
59
+ exports.intersection = zipWith.intersection;
60
+ exports.intersectionBy = zipWith.intersectionBy;
61
+ exports.intersectionWith = zipWith.intersectionWith;
62
+ exports.isSubset = zipWith.isSubset;
63
+ exports.keyBy = zipWith.keyBy;
64
+ exports.last = zipWith.last;
65
+ exports.maxBy = zipWith.maxBy;
66
+ exports.minBy = zipWith.minBy;
67
+ exports.partition = zipWith.partition;
68
+ exports.pullAt = zipWith.pullAt;
69
+ exports.sample = zipWith.sample;
70
+ exports.sampleSize = zipWith.sampleSize;
71
+ exports.shuffle = zipWith.shuffle;
72
+ exports.tail = zipWith.tail;
73
+ exports.take = zipWith.take;
74
+ exports.takeRight = zipWith.takeRight;
75
+ exports.takeRightWhile = zipWith.takeRightWhile;
76
+ exports.takeWhile = zipWith.takeWhile;
77
+ exports.toFilled = zipWith.toFilled;
78
+ exports.union = zipWith.union;
79
+ exports.unionBy = zipWith.unionBy;
80
+ exports.unionWith = zipWith.unionWith;
81
+ exports.uniq = zipWith.uniq;
82
+ exports.uniqBy = zipWith.uniqBy;
83
+ exports.uniqWith = zipWith.uniqWith;
84
+ exports.unzip = zipWith.unzip;
85
+ exports.unzipWith = zipWith.unzipWith;
86
+ exports.without = zipWith.without;
87
+ exports.xor = zipWith.xor;
88
+ exports.xorBy = zipWith.xorBy;
89
+ exports.xorWith = zipWith.xorWith;
90
+ exports.zip = zipWith.zip;
91
+ exports.zipObject = zipWith.zipObject;
92
+ exports.zipWith = zipWith.zipWith;
93
+ exports.orderBy = orderBy;
94
+ exports.sortBy = sortBy;
@@ -11,27 +11,34 @@ export { dropRightWhile } from './dropRightWhile.mjs';
11
11
  export { dropWhile } from './dropWhile.mjs';
12
12
  export { fill } from './fill.mjs';
13
13
  export { flatMap } from './flatMap.mjs';
14
+ export { flatMapDeep } from './flatMapDeep.mjs';
14
15
  export { flatten } from './flatten.mjs';
15
16
  export { flattenDeep } from './flattenDeep.mjs';
16
17
  export { forEachRight } from './forEachRight.mjs';
17
18
  export { groupBy } from './groupBy.mjs';
19
+ export { head } from './head.mjs';
20
+ export { initial } from './initial.mjs';
18
21
  export { intersection } from './intersection.mjs';
19
22
  export { intersectionBy } from './intersectionBy.mjs';
20
23
  export { intersectionWith } from './intersectionWith.mjs';
24
+ export { isSubset } from './isSubset.mjs';
21
25
  export { keyBy } from './keyBy.mjs';
26
+ export { last } from './last.mjs';
22
27
  export { maxBy } from './maxBy.mjs';
23
28
  export { minBy } from './minBy.mjs';
24
29
  export { orderBy } from './orderBy.mjs';
25
30
  export { partition } from './partition.mjs';
26
31
  export { pullAt } from './pullAt.mjs';
27
- export { sortBy } from './sortBy.mjs';
28
32
  export { sample } from './sample.mjs';
29
33
  export { sampleSize } from './sampleSize.mjs';
30
34
  export { shuffle } from './shuffle.mjs';
35
+ export { sortBy } from './sortBy.mjs';
36
+ export { tail } from './tail.mjs';
31
37
  export { take } from './take.mjs';
32
38
  export { takeRight } from './takeRight.mjs';
33
39
  export { takeRightWhile } from './takeRightWhile.mjs';
34
40
  export { takeWhile } from './takeWhile.mjs';
41
+ export { toFilled } from './toFilled.mjs';
35
42
  export { union } from './union.mjs';
36
43
  export { unionBy } from './unionBy.mjs';
37
44
  export { unionWith } from './unionWith.mjs';
@@ -40,16 +47,10 @@ export { uniqBy } from './uniqBy.mjs';
40
47
  export { uniqWith } from './uniqWith.mjs';
41
48
  export { unzip } from './unzip.mjs';
42
49
  export { unzipWith } from './unzipWith.mjs';
50
+ export { without } from './without.mjs';
43
51
  export { xor } from './xor.mjs';
44
52
  export { xorBy } from './xorBy.mjs';
45
53
  export { xorWith } from './xorWith.mjs';
46
54
  export { zip } from './zip.mjs';
47
55
  export { zipObject } from './zipObject.mjs';
48
56
  export { zipWith } from './zipWith.mjs';
49
- export { without } from './without.mjs';
50
- export { head } from './head.mjs';
51
- export { isSubset } from './isSubset.mjs';
52
- export { tail } from './tail.mjs';
53
- export { toFilled } from './toFilled.mjs';
54
- export { last } from './last.mjs';
55
- export { initial } from './initial.mjs';
@@ -1,3 +1,26 @@
1
+ /**
2
+ * Returns the last element of an array.
3
+ *
4
+ * This function takes an array and returns the last element of the array.
5
+ * If the array is empty, the function returns `undefined`.
6
+ *
7
+ * Unlike some implementations, this function is optimized for performance
8
+ * by directly accessing the last index of the array.
9
+ *
10
+ * @template T - The type of elements in the array.
11
+ * @param {[...T[], T]} arr - The array from which to get the last element.
12
+ * @returns {T} The last element of the array, or `undefined` if the array is empty.
13
+ *
14
+ * @example
15
+ * const arr = [1, 2, 3];
16
+ * const lastElement = last(arr);
17
+ * // lastElement will be 3
18
+ *
19
+ * const emptyArr: number[] = [];
20
+ * const noElement = last(emptyArr);
21
+ * // noElement will be undefined
22
+ */
23
+ declare function last<T>(arr: readonly [...T[], T]): T;
1
24
  /**
2
25
  * Returns the last element of an array.
3
26
  *
@@ -20,7 +43,6 @@
20
43
  * const noElement = last(emptyArr);
21
44
  * // noElement will be undefined
22
45
  */
23
- declare function last<T>(arr: readonly [...T[], T]): T;
24
46
  declare function last<T>(arr: readonly T[]): T | undefined;
25
47
 
26
48
  export { last };
@@ -1,3 +1,26 @@
1
+ /**
2
+ * Returns the last element of an array.
3
+ *
4
+ * This function takes an array and returns the last element of the array.
5
+ * If the array is empty, the function returns `undefined`.
6
+ *
7
+ * Unlike some implementations, this function is optimized for performance
8
+ * by directly accessing the last index of the array.
9
+ *
10
+ * @template T - The type of elements in the array.
11
+ * @param {[...T[], T]} arr - The array from which to get the last element.
12
+ * @returns {T} The last element of the array, or `undefined` if the array is empty.
13
+ *
14
+ * @example
15
+ * const arr = [1, 2, 3];
16
+ * const lastElement = last(arr);
17
+ * // lastElement will be 3
18
+ *
19
+ * const emptyArr: number[] = [];
20
+ * const noElement = last(emptyArr);
21
+ * // noElement will be undefined
22
+ */
23
+ declare function last<T>(arr: readonly [...T[], T]): T;
1
24
  /**
2
25
  * Returns the last element of an array.
3
26
  *
@@ -20,7 +43,6 @@
20
43
  * const noElement = last(emptyArr);
21
44
  * // noElement will be undefined
22
45
  */
23
- declare function last<T>(arr: readonly [...T[], T]): T;
24
46
  declare function last<T>(arr: readonly T[]): T | undefined;
25
47
 
26
48
  export { last };
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Finds the element in an array that has the maximum value when applying
3
+ * the `getValue` function to each element.
4
+ *
5
+ * @template T - The type of elements in the array.
6
+ * @param {[T, ...T[]]} items The nonempty array of elements to search.
7
+ * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
+ * @returns {T} The element with the maximum value as determined by the `getValue` function.
9
+ * @example
10
+ * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
+ * maxBy([], x => x.a); // Returns: undefined
12
+ */
13
+ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
1
14
  /**
2
15
  * Finds the element in an array that has the maximum value when applying
3
16
  * the `getValue` function to each element.
@@ -10,7 +23,6 @@
10
23
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
24
  * maxBy([], x => x.a); // Returns: undefined
12
25
  */
13
- declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
26
  declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
15
27
 
16
28
  export { maxBy };
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Finds the element in an array that has the maximum value when applying
3
+ * the `getValue` function to each element.
4
+ *
5
+ * @template T - The type of elements in the array.
6
+ * @param {[T, ...T[]]} items The nonempty array of elements to search.
7
+ * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
+ * @returns {T} The element with the maximum value as determined by the `getValue` function.
9
+ * @example
10
+ * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
+ * maxBy([], x => x.a); // Returns: undefined
12
+ */
13
+ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
1
14
  /**
2
15
  * Finds the element in an array that has the maximum value when applying
3
16
  * the `getValue` function to each element.
@@ -10,7 +23,6 @@
10
23
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
24
  * maxBy([], x => x.a); // Returns: undefined
12
25
  */
13
- declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
26
  declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
15
27
 
16
28
  export { maxBy };
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Finds the element in an array that has the minimum value when applying
3
+ * the `getValue` function to each element.
4
+ *
5
+ * @template T - The type of elements in the array.
6
+ * @param {[T, ...T[]]} items The nonempty array of elements to search.
7
+ * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
+ * @returns {T} The element with the minimum value as determined by the `getValue` function.
9
+ * @example
10
+ * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
+ * minBy([], x => x.a); // Returns: undefined
12
+ */
13
+ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
1
14
  /**
2
15
  * Finds the element in an array that has the minimum value when applying
3
16
  * the `getValue` function to each element.
@@ -10,7 +23,6 @@
10
23
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
24
  * minBy([], x => x.a); // Returns: undefined
12
25
  */
13
- declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
26
  declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
15
27
 
16
28
  export { minBy };
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Finds the element in an array that has the minimum value when applying
3
+ * the `getValue` function to each element.
4
+ *
5
+ * @template T - The type of elements in the array.
6
+ * @param {[T, ...T[]]} items The nonempty array of elements to search.
7
+ * @param {(element: T) => number} getValue A function that selects a numeric value from each element.
8
+ * @returns {T} The element with the minimum value as determined by the `getValue` function.
9
+ * @example
10
+ * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
+ * minBy([], x => x.a); // Returns: undefined
12
+ */
13
+ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
1
14
  /**
2
15
  * Finds the element in an array that has the minimum value when applying
3
16
  * the `getValue` function to each element.
@@ -10,7 +23,6 @@
10
23
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
24
  * minBy([], x => x.a); // Returns: undefined
12
25
  */
13
- declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
26
  declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
15
27
 
16
28
  export { minBy };