es-toolkit 1.0.0-dev.24 → 1.0.2-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/array.d.ts +1 -0
  3. package/dist/array/index.js +1 -1
  4. package/dist/array/uniqWith.d.ts +1 -1
  5. package/dist/index.js +1 -1
  6. package/esm/array/chunk.d.ts +24 -0
  7. package/esm/array/chunk.spec.d.ts +1 -0
  8. package/esm/array/difference.d.ts +23 -0
  9. package/esm/array/difference.spec.d.ts +1 -0
  10. package/esm/array/differenceBy.d.ts +26 -0
  11. package/esm/array/differenceBy.spec.d.ts +1 -0
  12. package/esm/array/differenceWith.d.ts +22 -0
  13. package/esm/array/differenceWith.spec.d.ts +1 -0
  14. package/esm/array/drop.d.ts +16 -0
  15. package/esm/array/drop.spec.d.ts +1 -0
  16. package/esm/array/dropRight.d.ts +16 -0
  17. package/esm/array/dropRight.spec.d.ts +1 -0
  18. package/esm/array/dropRightWhile.d.ts +18 -0
  19. package/esm/array/{dropRightWhile.mjs → dropRightWhile.js} +1 -1
  20. package/esm/array/dropRightWhile.spec.d.ts +1 -0
  21. package/esm/array/dropWhile.d.ts +18 -0
  22. package/esm/array/dropWhile.spec.d.ts +1 -0
  23. package/esm/array/groupBy.d.ts +31 -0
  24. package/esm/array/{groupBy.mjs → groupBy.js} +1 -1
  25. package/esm/array/groupBy.spec.d.ts +1 -0
  26. package/esm/array/index.d.ts +30 -0
  27. package/esm/array/index.js +30 -0
  28. package/esm/array/intersection.d.ts +18 -0
  29. package/esm/array/intersection.spec.d.ts +1 -0
  30. package/esm/array/intersectionBy.d.ts +21 -0
  31. package/esm/array/intersectionBy.spec.d.ts +1 -0
  32. package/esm/array/intersectionWith.d.ts +22 -0
  33. package/esm/array/intersectionWith.spec.d.ts +1 -0
  34. package/esm/array/partition.d.ts +22 -0
  35. package/esm/array/{partition.mjs → partition.js} +1 -1
  36. package/esm/array/partition.spec.d.ts +1 -0
  37. package/esm/array/sample.d.ts +14 -0
  38. package/esm/array/sample.spec.d.ts +1 -0
  39. package/esm/array/shuffle.d.ts +14 -0
  40. package/esm/array/shuffle.spec.d.ts +1 -0
  41. package/esm/array/take.d.ts +23 -0
  42. package/esm/array/take.spec.d.ts +1 -0
  43. package/esm/array/takeRight.d.ts +21 -0
  44. package/esm/array/takeRight.spec.d.ts +1 -0
  45. package/esm/array/takeRightWhile.d.ts +18 -0
  46. package/esm/array/takeRightWhile.spec.d.ts +1 -0
  47. package/esm/array/takeWhile.d.ts +19 -0
  48. package/esm/array/{takeWhile.mjs → takeWhile.js} +1 -1
  49. package/esm/array/takeWhile.spec.d.ts +1 -0
  50. package/esm/array/union.d.ts +17 -0
  51. package/esm/array/{union.mjs → union.js} +1 -1
  52. package/esm/array/union.spec.d.ts +1 -0
  53. package/esm/array/unionBy.d.ts +21 -0
  54. package/esm/array/{unionBy.mjs → unionBy.js} +1 -1
  55. package/esm/array/unionBy.spec.d.ts +1 -0
  56. package/esm/array/unionWith.d.ts +20 -0
  57. package/esm/array/{unionWith.mjs → unionWith.js} +1 -1
  58. package/esm/array/unionWith.spec.d.ts +1 -0
  59. package/esm/array/uniq.d.ts +15 -0
  60. package/esm/array/{uniq.mjs → uniq.js} +1 -1
  61. package/esm/array/uniq.spec.d.ts +1 -0
  62. package/esm/array/uniqBy.d.ts +12 -0
  63. package/esm/array/{uniqBy.mjs → uniqBy.js} +1 -1
  64. package/esm/array/uniqBy.spec.d.ts +1 -0
  65. package/esm/array/uniqWith.d.ts +12 -0
  66. package/esm/array/{uniqWith.mjs → uniqWith.js} +2 -2
  67. package/esm/array/uniqWith.spec.d.ts +1 -0
  68. package/esm/array/xor.d.ts +17 -0
  69. package/esm/array/{xor.mjs → xor.js} +3 -3
  70. package/esm/array/xor.spec.d.ts +1 -0
  71. package/esm/array/xorBy.d.ts +20 -0
  72. package/esm/array/{xorBy.mjs → xorBy.js} +3 -3
  73. package/esm/array/xorBy.spec.d.ts +1 -0
  74. package/esm/array/xorWith.d.ts +19 -0
  75. package/esm/array/{xorWith.mjs → xorWith.js} +3 -3
  76. package/esm/array/xorWith.spec.d.ts +1 -0
  77. package/esm/array/zip.d.ts +25 -0
  78. package/esm/array/{zip.mjs → zip.js} +1 -1
  79. package/esm/array/zip.spec.d.ts +1 -0
  80. package/esm/array/zipWith.d.ts +32 -0
  81. package/esm/array/{zipWith.mjs → zipWith.js} +1 -1
  82. package/esm/array/zipWith.spec.d.ts +1 -0
  83. package/esm/function/debounce.d.ts +24 -0
  84. package/esm/function/debounce.spec.d.ts +1 -0
  85. package/esm/function/index.d.ts +3 -0
  86. package/esm/function/index.js +3 -0
  87. package/esm/function/once.d.ts +17 -0
  88. package/esm/function/once.spec.d.ts +1 -0
  89. package/esm/function/throttle.d.ts +26 -0
  90. package/esm/function/throttle.spec.d.ts +1 -0
  91. package/esm/index.d.ts +6 -0
  92. package/esm/index.js +45 -0
  93. package/esm/math/clamp.d.ts +19 -0
  94. package/esm/math/clamp.spec.d.ts +1 -0
  95. package/esm/math/index.d.ts +3 -0
  96. package/esm/math/index.js +3 -0
  97. package/esm/math/round.d.ts +16 -0
  98. package/esm/math/round.spec.d.ts +1 -0
  99. package/esm/math/sum.d.ts +14 -0
  100. package/esm/math/{sum.mjs → sum.js} +1 -1
  101. package/esm/math/sum.spec.d.ts +1 -0
  102. package/esm/object/index.d.ts +4 -0
  103. package/esm/object/index.js +4 -0
  104. package/esm/object/omit.d.ts +16 -0
  105. package/esm/object/{omit.mjs → omit.js} +1 -1
  106. package/esm/object/omit.spec.d.ts +1 -0
  107. package/esm/object/omitBy.d.ts +19 -0
  108. package/esm/object/{omitBy.mjs → omitBy.js} +1 -1
  109. package/esm/object/omitBy.spec.d.ts +1 -0
  110. package/esm/object/pick.d.ts +16 -0
  111. package/esm/object/{pick.mjs → pick.js} +1 -1
  112. package/esm/object/pick.spec.d.ts +1 -0
  113. package/esm/object/pickBy.d.ts +19 -0
  114. package/esm/object/{pickBy.mjs → pickBy.js} +1 -1
  115. package/esm/object/pickBy.spec.d.ts +1 -0
  116. package/esm/package.json +1 -0
  117. package/esm/predicate/index.d.ts +4 -0
  118. package/esm/predicate/index.js +4 -0
  119. package/esm/predicate/isNil.d.ts +20 -0
  120. package/esm/predicate/isNil.spec.d.ts +1 -0
  121. package/esm/predicate/isNotNil.d.ts +16 -0
  122. package/esm/predicate/isNotNil.spec.d.ts +1 -0
  123. package/esm/predicate/isNull.d.ts +21 -0
  124. package/esm/predicate/isNull.spec.d.ts +1 -0
  125. package/esm/predicate/isUndefined.d.ts +21 -0
  126. package/esm/predicate/isUndefined.spec.d.ts +1 -0
  127. package/esm/promise/delay.d.ts +19 -0
  128. package/esm/promise/delay.spec.d.ts +1 -0
  129. package/esm/promise/index.d.ts +1 -0
  130. package/esm/promise/index.js +1 -0
  131. package/function.d.ts +1 -0
  132. package/math.d.ts +1 -0
  133. package/object.d.ts +1 -0
  134. package/package.json +18 -17
  135. package/predicate.d.ts +1 -0
  136. package/promise.d.ts +1 -0
  137. package/esm/array/index.mjs +0 -30
  138. package/esm/function/index.mjs +0 -3
  139. package/esm/index.mjs +0 -45
  140. package/esm/math/index.mjs +0 -3
  141. package/esm/object/index.mjs +0 -4
  142. package/esm/predicate/index.mjs +0 -4
  143. package/esm/promise/index.mjs +0 -1
  144. /package/esm/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
  145. /package/esm/array/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
  146. /package/esm/array/{chunk.mjs → chunk.js} +0 -0
  147. /package/esm/array/{difference.mjs → difference.js} +0 -0
  148. /package/esm/array/{differenceBy.mjs → differenceBy.js} +0 -0
  149. /package/esm/array/{differenceWith.mjs → differenceWith.js} +0 -0
  150. /package/esm/array/{drop.mjs → drop.js} +0 -0
  151. /package/esm/array/{dropRight.mjs → dropRight.js} +0 -0
  152. /package/esm/array/{dropWhile.mjs → dropWhile.js} +0 -0
  153. /package/esm/array/{intersection.mjs → intersection.js} +0 -0
  154. /package/esm/array/{intersectionBy.mjs → intersectionBy.js} +0 -0
  155. /package/esm/array/{intersectionWith.mjs → intersectionWith.js} +0 -0
  156. /package/esm/array/{sample.mjs → sample.js} +0 -0
  157. /package/esm/array/{shuffle.mjs → shuffle.js} +0 -0
  158. /package/esm/array/{take.mjs → take.js} +0 -0
  159. /package/esm/array/{takeRight.mjs → takeRight.js} +0 -0
  160. /package/esm/array/{takeRightWhile.mjs → takeRightWhile.js} +0 -0
  161. /package/esm/function/{debounce.mjs → debounce.js} +0 -0
  162. /package/esm/function/{once.mjs → once.js} +0 -0
  163. /package/esm/function/{throttle.mjs → throttle.js} +0 -0
  164. /package/esm/math/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
  165. /package/esm/math/{clamp.mjs → clamp.js} +0 -0
  166. /package/esm/math/{round.mjs → round.js} +0 -0
  167. /package/esm/object/_virtual/{_rollupPluginBabelHelpers.mjs → _rollupPluginBabelHelpers.js} +0 -0
  168. /package/esm/predicate/{isNil.mjs → isNil.js} +0 -0
  169. /package/esm/predicate/{isNotNil.mjs → isNotNil.js} +0 -0
  170. /package/esm/predicate/{isNull.mjs → isNull.js} +0 -0
  171. /package/esm/predicate/{isUndefined.mjs → isUndefined.js} +0 -0
  172. /package/esm/promise/{delay.mjs → delay.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # es-toolkit Changelog
2
2
 
3
- ## Version v1.0.0
3
+ ## Version v1.0.2
4
4
 
5
- Initial release. Released on May 31th, 2024.
5
+ Initial release. Released on May 31th, 2024.
package/array.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/array';
@@ -721,7 +721,7 @@ function unionBy(arr1, arr2, mapper) {
721
721
  *
722
722
  * @example
723
723
  * ```ts
724
- * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => );
724
+ * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
725
725
  * // [1, 2, 3, 5, 7]
726
726
  * ```
727
727
  */
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @example
7
7
  * ```ts
8
- * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => );
8
+ * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
9
9
  * // [1, 2, 3, 5, 7]
10
10
  * ```
11
11
  */
package/dist/index.js CHANGED
@@ -806,7 +806,7 @@ function unionBy(arr1, arr2, mapper) {
806
806
  *
807
807
  * @example
808
808
  * ```ts
809
- * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => );
809
+ * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);
810
810
  * // [1, 2, 3, 5, 7]
811
811
  * ```
812
812
  */
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Splits an array into smaller arrays of a specified length.
3
+ *
4
+ * This function takes an input array and divides it into multiple smaller arrays,
5
+ * each of a specified length. If the input array cannot be evenly divided,
6
+ * the final sub-array will contain the remaining elements.
7
+ *
8
+ * @template T The type of elements in the array.
9
+ * @param {T[]} arr - The array to be chunked into smaller arrays.
10
+ * @param {number} size - The size of each smaller array. Must be a positive integer.
11
+ * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
12
+ * @throws {Error} Throws an error if `size` is not a positive integer.
13
+ *
14
+ * @example
15
+ * // Splits an array of numbers into sub-arrays of length 2
16
+ * chunk([1, 2, 3, 4, 5], 2);
17
+ * // Returns: [[1, 2], [3, 4], [5]]
18
+ *
19
+ * @example
20
+ * // Splits an array of strings into sub-arrays of length 3
21
+ * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
22
+ * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
23
+ */
24
+ export declare function chunk<T>(arr: T[], size: number): T[][];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Computes the difference between two arrays.
3
+ *
4
+ * This function takes two arrays and returns a new array containing the elements
5
+ * that are present in the first array but not in the second array. It effectively
6
+ * filters out any elements from the first array that also appear in the second array.
7
+ *
8
+ * @template T
9
+ * @param {T[]} firstArr - The array from which to derive the difference. This is the primary array
10
+ * from which elements will be compared and filtered.
11
+ * @param {T[]} secondArr - The array containing elements to be excluded from the first array.
12
+ * Each element in this array will be checked against the first array, and if a match is found,
13
+ * that element will be excluded from the result.
14
+ * @returns {T[]} A new array containing the elements that are present in the first array but not
15
+ * in the second array.
16
+ *
17
+ * @example
18
+ * * const array1 = [1, 2, 3, 4, 5];
19
+ * const array2 = [2, 4];
20
+ * const result = difference(array1, array2);
21
+ * // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.
22
+ */
23
+ export declare function difference<T>(firstArr: T[], secondArr: T[]): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Computes the difference between two arrays after mapping their elements through a provided function.
3
+ *
4
+ * This function takes two arrays and a mapper function. It returns a new array containing the elements
5
+ * that are present in the first array but not in the second array, based on the identity calculated
6
+ * by the mapper function.
7
+ *
8
+ * Essentially, it filters out any elements from the first array that, when
9
+ * mapped, match an element in the mapped version of the second array.
10
+ *
11
+ * @template T, U
12
+ * @param {T[]} firstArr - The primary array from which to derive the difference.
13
+ * @param {T[]} secondArr - The array containing elements to be excluded from the first array.
14
+ * @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function
15
+ * is applied to each element in both arrays, and the comparison is made based on the mapped values.
16
+ * @returns {T[]} A new array containing the elements from the first array that do not have a corresponding
17
+ * mapped identity in the second array.
18
+ *
19
+ * @example
20
+ * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
21
+ * const array2 = [{ id: 2 }, { id: 4 }];
22
+ * const mapper = item => item.id;
23
+ * const result = differenceBy(array1, array2, mapper);
24
+ * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
25
+ */
26
+ export declare function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Computes the difference between two arrays based on a custom equality function.
3
+ *
4
+ * This function takes two arrays and a custom comparison function. It returns a new array containing
5
+ * the elements that are present in the first array but not in the second array. The comparison to determine
6
+ * if elements are equal is made using the provided custom function.
7
+ *
8
+ * @template T
9
+ * @param {T[]} firstArr - The array from which to get the difference.
10
+ * @param {T[]} secondArr - The array containing elements to exclude from the first array.
11
+ * @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.
12
+ * @returns {T[]} A new array containing the elements from the first array that do not match any elements in the second array
13
+ * according to the custom equality function.
14
+ *
15
+ * @example
16
+ * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
17
+ * const array2 = [{ id: 2 }, { id: 4 }];
18
+ * const areItemsEqual = (a, b) => a.id === b.id;
19
+ * const result = differenceWith(array1, array2, areItemsEqual);
20
+ * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
21
+ */
22
+ export declare function differenceWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Removes a specified number of elements from the beginning of an array and returns the rest.
3
+ *
4
+ * This function takes an array and a number, and returns a new array with the specified number
5
+ * of elements removed from the start.
6
+ *
7
+ * @param {T[]} arr - The array from which to drop elements.
8
+ * @param {number} itemsCount - The number of elements to drop from the beginning of the array.
9
+ * @returns {T[]} A new array with the specified number of elements removed from the start.
10
+ *
11
+ * @example
12
+ * * const array = [1, 2, 3, 4, 5];
13
+ * const result = drop(array, 2);
14
+ * // result will be [3, 4, 5] since the first two elements are dropped.
15
+ */
16
+ export declare function drop<T>(arr: T[], itemsCount: number): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Removes a specified number of elements from the end of an array and returns the rest.
3
+ *
4
+ * This function takes an array and a number, and returns a new array with the specified number
5
+ * of elements removed from the end.
6
+ *
7
+ * @param {T[]} arr - The array from which to drop elements.
8
+ * @param {number} itemsCount - The number of elements to drop from the end of the array.
9
+ * @returns {T[]} A new array with the specified number of elements removed from the end.
10
+ *
11
+ * @example
12
+ * * const array = [1, 2, 3, 4, 5];
13
+ * const result = dropRight(array, 2);
14
+ * // result will be [1, 2, 3] since the last two elements are dropped.
15
+ */
16
+ export declare function dropRight<T>(arr: T[], itemsCount: number): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Removes elements from the end of an array until the predicate returns false.
3
+ *
4
+ * This function iterates over an array from the end and drops elements until the provided
5
+ * predicate function returns false. It then returns a new array with the remaining elements.
6
+ *
7
+ * @param {T[]} arr - The array from which to drop elements.
8
+ * @param {function(item: T): boolean} canContinueDropping - A predicate function that determines
9
+ * whether to continue dropping elements. The function is called with each element from the end,
10
+ * and dropping continues as long as it returns true.
11
+ * @returns {T[]} A new array with the elements remaining after the predicate returns false.
12
+ *
13
+ * @example
14
+ * const array = [1, 2, 3, 4, 5];
15
+ * const result = dropRightWhile(array, x => x > 3);
16
+ * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.
17
+ */
18
+ export declare function dropRightWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
@@ -1,4 +1,4 @@
1
- import { dropWhile } from './dropWhile.mjs';
1
+ import { dropWhile } from './dropWhile.js';
2
2
 
3
3
  /**
4
4
  * Removes elements from the end of an array until the predicate returns false.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Removes elements from the beginning of an array until the predicate returns false.
3
+ *
4
+ * This function iterates over an array and drops elements from the start until the provided
5
+ * predicate function returns false. It then returns a new array with the remaining elements.
6
+ *
7
+ * @param {T[]} arr - The array from which to drop elements.
8
+ * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
9
+ * whether to continue dropping elements. The function is called with each element, and dropping
10
+ * continues as long as it returns true.
11
+ * @returns {T[]} A new array with the elements remaining after the predicate returns false.
12
+ *
13
+ * @example
14
+ * const array = [1, 2, 3, 4, 5];
15
+ * const result = dropWhile(array, x => x < 3);
16
+ * // result will be [3, 4, 5] since elements less than 3 are dropped.
17
+ */
18
+ export declare function dropWhile<T>(arr: T[], canContinueDropping: (item: T) => boolean): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Groups the elements of an array based on a provided key-generating function.
3
+ *
4
+ * This function takes an array and a function that generates a key from each element. It returns
5
+ * an object where the keys are the generated keys and the values are arrays of elements that share
6
+ * the same key.
7
+ *
8
+ * @param {T[]} arr - The array to group.
9
+ * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
10
+ * @returns {Record<K, T[]>} An object where each key is associated with an array of elements that
11
+ * share that key.
12
+ *
13
+ * @example
14
+ * const array = [
15
+ * { category: 'fruit', name: 'apple' },
16
+ * { category: 'fruit', name: 'banana' },
17
+ * { category: 'vegetable', name: 'carrot' }
18
+ * ];
19
+ * const result = groupBy(array, item => item.category);
20
+ * // result will be:
21
+ * // {
22
+ * // fruit: [
23
+ * // { category: 'fruit', name: 'apple' },
24
+ * // { category: 'fruit', name: 'banana' }
25
+ * // ],
26
+ * // vegetable: [
27
+ * // { category: 'vegetable', name: 'carrot' }
28
+ * // ]
29
+ * // }
30
+ */
31
+ export declare function groupBy<T, K extends string>(arr: T[], getKeyFromItem: (item: T) => K): Record<K, T[]>;
@@ -1,4 +1,4 @@
1
- import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
1
+ import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
2
2
 
3
3
  /**
4
4
  * Groups the elements of an array based on a provided key-generating function.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ export { chunk } from './chunk';
2
+ export { difference } from './difference';
3
+ export { differenceBy } from './differenceBy';
4
+ export { differenceWith } from './differenceWith';
5
+ export { drop } from './drop';
6
+ export { dropRight } from './dropRight';
7
+ export { dropRightWhile } from './dropRightWhile';
8
+ export { dropWhile } from './dropWhile';
9
+ export { groupBy } from './groupBy';
10
+ export { intersection } from './intersection';
11
+ export { intersectionBy } from './intersectionBy';
12
+ export { intersectionWith } from './intersectionWith';
13
+ export { partition } from './partition';
14
+ export { sample } from './sample';
15
+ export { shuffle } from './shuffle';
16
+ export { take } from './take';
17
+ export { takeRight } from './takeRight';
18
+ export { takeRightWhile } from './takeRightWhile';
19
+ export { takeWhile } from './takeWhile';
20
+ export { union } from './union';
21
+ export { unionBy } from './unionBy';
22
+ export { unionWith } from './unionWith';
23
+ export { uniq } from './uniq';
24
+ export { uniqBy } from './uniqBy';
25
+ export { uniqWith } from './uniqWith';
26
+ export { xor } from './xor';
27
+ export { xorBy } from './xorBy';
28
+ export { xorWith } from './xorWith';
29
+ export { zip } from './zip';
30
+ export { zipWith } from './zipWith';
@@ -0,0 +1,30 @@
1
+ export { chunk } from './chunk.js';
2
+ export { difference } from './difference.js';
3
+ export { differenceBy } from './differenceBy.js';
4
+ export { differenceWith } from './differenceWith.js';
5
+ export { drop } from './drop.js';
6
+ export { dropRight } from './dropRight.js';
7
+ export { dropRightWhile } from './dropRightWhile.js';
8
+ export { dropWhile } from './dropWhile.js';
9
+ export { groupBy } from './groupBy.js';
10
+ export { intersection } from './intersection.js';
11
+ export { intersectionBy } from './intersectionBy.js';
12
+ export { intersectionWith } from './intersectionWith.js';
13
+ export { partition } from './partition.js';
14
+ export { sample } from './sample.js';
15
+ export { shuffle } from './shuffle.js';
16
+ export { take } from './take.js';
17
+ export { takeRight } from './takeRight.js';
18
+ export { takeRightWhile } from './takeRightWhile.js';
19
+ export { takeWhile } from './takeWhile.js';
20
+ export { union } from './union.js';
21
+ export { unionBy } from './unionBy.js';
22
+ export { unionWith } from './unionWith.js';
23
+ export { uniq } from './uniq.js';
24
+ export { uniqBy } from './uniqBy.js';
25
+ export { uniqWith } from './uniqWith.js';
26
+ export { xor } from './xor.js';
27
+ export { xorBy } from './xorBy.js';
28
+ export { xorWith } from './xorWith.js';
29
+ export { zip } from './zip.js';
30
+ export { zipWith } from './zipWith.js';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns the intersection of two arrays.
3
+ *
4
+ * This function takes two arrays and returns a new array containing the elements that are
5
+ * present in both arrays. It effectively filters out any elements from the first array that
6
+ * are not found in the second array.
7
+ *
8
+ * @param {T[]} firstArr - The first array to compare.
9
+ * @param {T[]} secondArr - The second array to compare.
10
+ * @returns {T[]} A new array containing the elements that are present in both arrays.
11
+ *
12
+ * @example
13
+ * const array1 = [1, 2, 3, 4, 5];
14
+ * const array2 = [3, 4, 5, 6, 7];
15
+ * const result = intersection(array1, array2);
16
+ * // result will be [3, 4, 5] since these elements are in both arrays.
17
+ */
18
+ export declare function intersection<T>(firstArr: T[], secondArr: T[]): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns the intersection of two arrays based on a mapping function.
3
+ *
4
+ * This function takes two arrays and a mapping function. It returns a new array containing
5
+ * the elements from the first array that, when mapped using the provided function, have matching
6
+ * mapped elements in the second array. It effectively filters out any elements from the first array
7
+ * that do not have corresponding mapped values in the second array.
8
+ *
9
+ * @param {T[]} firstArr - The first array to compare.
10
+ * @param {T[]} secondArr - The second array to compare.
11
+ * @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.
12
+ * @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.
13
+ *
14
+ * @example
15
+ * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
16
+ * const array2 = [{ id: 2 }, { id: 4 }];
17
+ * const mapper = item => item.id;
18
+ * const result = intersectionBy(array1, array2, mapper);
19
+ * // result will be [{ id: 2 }] since only this element has a matching id in both arrays.
20
+ */
21
+ export declare function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) => U): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Returns the intersection of two arrays based on a custom equality function.
3
+ *
4
+ * This function takes two arrays and a custom equality function. It returns a new array containing
5
+ * the elements from the first array that have matching elements in the second array, as determined
6
+ * by the custom equality function. It effectively filters out any elements from the first array that
7
+ * do not have corresponding matches in the second array according to the equality function.
8
+ *
9
+ * @param {T[]} firstArr - The first array to compare.
10
+ * @param {T[]} secondArr - The second array to compare.
11
+ * @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
12
+ * This function takes two arguments, one from each array, and returns `true` if the elements are considered equal, and `false` otherwise.
13
+ * @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.
14
+ *
15
+ * @example
16
+ * * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
17
+ * const array2 = [{ id: 2 }, { id: 4 }];
18
+ * const areItemsEqual = (a, b) => a.id === b.id;
19
+ * const result = intersectionWith(array1, array2, areItemsEqual);
20
+ * // result will be [{ id: 2 }] since this element has a matching id in both arrays.
21
+ */
22
+ export declare function intersectionWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Splits an array into two groups based on a predicate function.
3
+ *
4
+ * This function takes an array and a predicate function. It returns a tuple of two arrays:
5
+ * the first array contains elements for which the predicate function returns true, and
6
+ * the second array contains elements for which the predicate function returns false.
7
+ *
8
+ * @param {T[]} arr - The array to partition.
9
+ * @param {(value: T) => boolean} isInTruthy - A predicate function that determines
10
+ * whether an element should be placed in the truthy array. The function is called with each
11
+ * element of the array.
12
+ * @returns {[T[], T[]]} A tuple containing two arrays: the first array contains elements for
13
+ * which the predicate returned true, and the second array contains elements for which the
14
+ * predicate returned false.
15
+ *
16
+ * @example
17
+ * const array = [1, 2, 3, 4, 5];
18
+ * const isEven = x => x % 2 === 0;
19
+ * const [even, odd] = partition(array, isEven);
20
+ * // even will be [2, 4], and odd will be [1, 3, 5]
21
+ */
22
+ export declare function partition<T>(arr: T[], isInTruthy: (value: T) => boolean): [truthy: T[], falsy: T[]];
@@ -1,4 +1,4 @@
1
- import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
1
+ import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
2
2
 
3
3
  /**
4
4
  * Splits an array into two groups based on a predicate function.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns a random element from an array.
3
+ *
4
+ * This function takes an array and returns a single element selected randomly from the array.
5
+ *
6
+ * @param {T[]} arr - The array to sample from.
7
+ * @returns {T} A random element from the array.
8
+ *
9
+ * @example
10
+ * const array = [1, 2, 3, 4, 5];
11
+ * const randomElement = sample(array);
12
+ * // randomElement will be one of the elements from the array, selected randomly.
13
+ */
14
+ export declare function sample<T>(arr: T[]): T;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Randomizes the order of elements in an array using the Fisher-Yates algorithm.
3
+ *
4
+ * This function takes an array and returns a new array with its elements shuffled in a random order.
5
+ *
6
+ * @param {T[]} arr - The array to shuffle.
7
+ * @returns {T[]} A new array with its elements shuffled in random order.
8
+ *
9
+ * @example
10
+ * const array = [1, 2, 3, 4, 5];
11
+ * const shuffledArray = shuffle(array);
12
+ * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
13
+ */
14
+ export declare function shuffle<T>(arr: T[]): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Returns a new array containing the first `count` elements from the input array `arr`.
3
+ * If `count` is greater than the length of `arr`, the entire array is returned.
4
+ *
5
+ * @template T - Type of elements in the input array.
6
+ *
7
+ * @param {T[]} arr - The array to take elements from.
8
+ * @param {number} count - The number of elements to take.
9
+ * @returns {T[]} A new array containing the first `count` elements from `arr`.
10
+ *
11
+ * @example
12
+ * // Returns [1, 2, 3]
13
+ * take([1, 2, 3, 4, 5], 3);
14
+ *
15
+ * @example
16
+ * // Returns ['a', 'b']
17
+ * take(['a', 'b', 'c'], 2);
18
+ *
19
+ * @example
20
+ * // Returns [1, 2, 3]
21
+ * take([1, 2, 3], 5);
22
+ */
23
+ export declare function take<T>(arr: T[], count: number): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns a new array containing the last `count` elements from the input array `arr`.
3
+ * If `count` is greater than the length of `arr`, the entire array is returned.
4
+ *
5
+ * @param {T[]} arr - The array to take elements from.
6
+ * @param {number} count - The number of elements to take.
7
+ * @returns {T[]} A new array containing the last `count` elements from `arr`.
8
+ *
9
+ * @example
10
+ * // Returns [4, 5]
11
+ * takeRight([1, 2, 3, 4, 5], 2);
12
+ *
13
+ * @example
14
+ * // Returns ['b', 'c']
15
+ * takeRight(['a', 'b', 'c'], 2);
16
+ *
17
+ * @example
18
+ * // Returns [1, 2, 3]
19
+ * takeRight([1, 2, 3], 5);
20
+ */
21
+ export declare function takeRight<T>(arr: T[], count: number): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Takes elements from the end of the array while the predicate function returns `true`.
3
+ *
4
+ * @template T - Type of elements in the input array.
5
+ *
6
+ * @param {T[]} arr - The array to take elements from.
7
+ * @param {function(T): boolean} shouldContinueTaking - The function invoked per element.
8
+ * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.
9
+ *
10
+ * @example
11
+ * // Returns [3, 2, 1]
12
+ * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);
13
+ *
14
+ * @example
15
+ * // Returns []
16
+ * takeRightWhile([1, 2, 3], n => n > 3);
17
+ */
18
+ export declare function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Returns a new array containing the leading elements of the provided array
3
+ * that satisfy the provided predicate function. It stops taking elements as soon
4
+ * as an element does not satisfy the predicate.
5
+ *
6
+ * @template T - The type of elements in the array.
7
+ * @param {T[]} arr - The array to process.
8
+ * @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.
9
+ * @returns {T[]} A new array containing the leading elements that satisfy the predicate.
10
+ *
11
+ * @example
12
+ * // Returns [1, 2]
13
+ * takeWhile([1, 2, 3, 4], x => x < 3);
14
+ *
15
+ * @example
16
+ * // Returns []
17
+ * takeWhile([1, 2, 3, 4], x => x > 3);
18
+ */
19
+ export declare function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[];
@@ -1,4 +1,4 @@
1
- import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.mjs';
1
+ import { createForOfIteratorHelper as _createForOfIteratorHelper } from './_virtual/_rollupPluginBabelHelpers.js';
2
2
 
3
3
  /**
4
4
  * Returns a new array containing the leading elements of the provided array
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Creates an array of unique values from all given arrays.
3
+ *
4
+ * This function takes two arrays, merges them into a single array, and returns a new array
5
+ * containing only the unique values from the merged array.
6
+ *
7
+ * @param {T[]} arr1 - The first array to merge and filter for unique values.
8
+ * @param {T[]} arr2 - The second array to merge and filter for unique values.
9
+ * @returns {T[]} A new array of unique values.
10
+ *
11
+ * @example
12
+ * const array1 = [1, 2, 3];
13
+ * const array2 = [3, 4, 5];
14
+ * const result = union(array1, array2);
15
+ * // result will be [1, 2, 3, 4, 5]
16
+ */
17
+ export declare function union<T>(arr1: T[], arr2: T[]): T[];
@@ -1,4 +1,4 @@
1
- import { uniq } from './uniq.mjs';
1
+ import { uniq } from './uniq.js';
2
2
 
3
3
  /**
4
4
  * Creates an array of unique values from all given arrays.