es-toolkit 1.2.1 → 1.2.2-dev.67

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 (201) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/dist/array/chunk.d.mts +1 -1
  4. package/dist/array/chunk.d.ts +1 -1
  5. package/dist/array/chunk.js.map +1 -1
  6. package/dist/array/chunk.mjs +1 -1
  7. package/dist/array/difference.d.mts +1 -1
  8. package/dist/array/difference.d.ts +1 -1
  9. package/dist/array/difference.js.map +1 -1
  10. package/dist/array/difference.mjs +1 -1
  11. package/dist/array/differenceBy.d.mts +1 -1
  12. package/dist/array/differenceBy.d.ts +1 -1
  13. package/dist/array/differenceBy.js.map +1 -1
  14. package/dist/array/differenceBy.mjs +1 -1
  15. package/dist/array/differenceWith.d.mts +1 -1
  16. package/dist/array/differenceWith.d.ts +1 -1
  17. package/dist/array/differenceWith.js.map +1 -1
  18. package/dist/array/differenceWith.mjs +1 -1
  19. package/dist/array/drop.d.mts +1 -1
  20. package/dist/array/drop.d.ts +1 -1
  21. package/dist/array/drop.js.map +1 -1
  22. package/dist/array/drop.mjs +1 -1
  23. package/dist/array/dropRight.d.mts +1 -1
  24. package/dist/array/dropRight.d.ts +1 -1
  25. package/dist/array/dropRight.js.map +1 -1
  26. package/dist/array/dropRight.mjs +1 -1
  27. package/dist/array/dropRightWhile.d.mts +1 -1
  28. package/dist/array/dropRightWhile.d.ts +1 -1
  29. package/dist/array/dropRightWhile.js.map +1 -1
  30. package/dist/array/dropRightWhile.mjs +2 -2
  31. package/dist/array/dropWhile.d.mts +1 -1
  32. package/dist/array/dropWhile.d.ts +1 -1
  33. package/dist/array/dropWhile.js.map +1 -1
  34. package/dist/array/dropWhile.mjs +1 -1
  35. package/dist/array/groupBy.d.mts +1 -1
  36. package/dist/array/groupBy.d.ts +1 -1
  37. package/dist/array/groupBy.js.map +1 -1
  38. package/dist/array/groupBy.mjs +1 -1
  39. package/dist/array/index.js +3 -12
  40. package/dist/array/index.js.map +1 -1
  41. package/dist/array/index.mjs +40 -40
  42. package/dist/array/intersection.d.mts +1 -1
  43. package/dist/array/intersection.d.ts +1 -1
  44. package/dist/array/intersection.js.map +1 -1
  45. package/dist/array/intersection.mjs +1 -1
  46. package/dist/array/intersectionBy.d.mts +1 -1
  47. package/dist/array/intersectionBy.d.ts +1 -1
  48. package/dist/array/intersectionBy.js +2 -4
  49. package/dist/array/intersectionBy.js.map +1 -1
  50. package/dist/array/intersectionBy.mjs +1 -1
  51. package/dist/array/intersectionWith.d.mts +1 -1
  52. package/dist/array/intersectionWith.d.ts +1 -1
  53. package/dist/array/intersectionWith.js.map +1 -1
  54. package/dist/array/intersectionWith.mjs +1 -1
  55. package/dist/array/partition.d.mts +1 -1
  56. package/dist/array/partition.d.ts +1 -1
  57. package/dist/array/partition.js.map +1 -1
  58. package/dist/array/partition.mjs +1 -1
  59. package/dist/array/sample.d.mts +1 -1
  60. package/dist/array/sample.d.ts +1 -1
  61. package/dist/array/sample.js.map +1 -1
  62. package/dist/array/sample.mjs +1 -1
  63. package/dist/array/shuffle.d.mts +1 -1
  64. package/dist/array/shuffle.d.ts +1 -1
  65. package/dist/array/shuffle.js.map +1 -1
  66. package/dist/array/shuffle.mjs +1 -1
  67. package/dist/array/take.d.mts +1 -1
  68. package/dist/array/take.d.ts +1 -1
  69. package/dist/array/take.js.map +1 -1
  70. package/dist/array/take.mjs +1 -1
  71. package/dist/array/takeRight.d.mts +1 -1
  72. package/dist/array/takeRight.d.ts +1 -1
  73. package/dist/array/takeRight.js.map +1 -1
  74. package/dist/array/takeRight.mjs +1 -1
  75. package/dist/array/takeRightWhile.d.mts +1 -1
  76. package/dist/array/takeRightWhile.d.ts +1 -1
  77. package/dist/array/takeRightWhile.js.map +1 -1
  78. package/dist/array/takeRightWhile.mjs +1 -1
  79. package/dist/array/takeWhile.d.mts +1 -1
  80. package/dist/array/takeWhile.d.ts +1 -1
  81. package/dist/array/takeWhile.js.map +1 -1
  82. package/dist/array/takeWhile.mjs +1 -1
  83. package/dist/array/union.d.mts +1 -1
  84. package/dist/array/union.d.ts +1 -1
  85. package/dist/array/union.js +1 -8
  86. package/dist/array/union.js.map +1 -1
  87. package/dist/array/union.mjs +2 -2
  88. package/dist/array/unionBy.d.mts +1 -1
  89. package/dist/array/unionBy.d.ts +1 -1
  90. package/dist/array/unionBy.js.map +1 -1
  91. package/dist/array/unionBy.mjs +1 -1
  92. package/dist/array/unionWith.d.mts +1 -1
  93. package/dist/array/unionWith.d.ts +1 -1
  94. package/dist/array/unionWith.js.map +1 -1
  95. package/dist/array/unionWith.mjs +2 -2
  96. package/dist/array/uniq.d.mts +1 -1
  97. package/dist/array/uniq.d.ts +1 -1
  98. package/dist/array/uniq.js +1 -8
  99. package/dist/array/uniq.js.map +1 -1
  100. package/dist/array/uniq.mjs +1 -1
  101. package/dist/array/uniqBy.d.mts +1 -1
  102. package/dist/array/uniqBy.d.ts +1 -1
  103. package/dist/array/uniqBy.js.map +1 -1
  104. package/dist/array/uniqBy.mjs +2 -2
  105. package/dist/array/uniqWith.d.mts +1 -1
  106. package/dist/array/uniqWith.d.ts +1 -1
  107. package/dist/array/uniqWith.js.map +1 -1
  108. package/dist/array/uniqWith.mjs +1 -1
  109. package/dist/array/xor.d.mts +1 -1
  110. package/dist/array/xor.d.ts +1 -1
  111. package/dist/array/xor.js +1 -8
  112. package/dist/array/xor.js.map +1 -1
  113. package/dist/array/xor.mjs +5 -5
  114. package/dist/array/xorBy.d.mts +1 -1
  115. package/dist/array/xorBy.d.ts +1 -1
  116. package/dist/array/xorBy.js +2 -4
  117. package/dist/array/xorBy.js.map +1 -1
  118. package/dist/array/xorBy.mjs +4 -4
  119. package/dist/array/xorWith.d.mts +1 -1
  120. package/dist/array/xorWith.d.ts +1 -1
  121. package/dist/array/xorWith.js.map +1 -1
  122. package/dist/array/xorWith.mjs +5 -5
  123. package/dist/array/zip.d.mts +4 -4
  124. package/dist/array/zip.d.ts +4 -4
  125. package/dist/array/zip.js.map +1 -1
  126. package/dist/array/zip.mjs +1 -1
  127. package/dist/array/zipWith.d.mts +4 -4
  128. package/dist/array/zipWith.d.ts +4 -4
  129. package/dist/array/zipWith.js.map +1 -1
  130. package/dist/array/zipWith.mjs +1 -1
  131. package/dist/{chunk-LLOAPSQ6.mjs → chunk-2IXFGSUA.mjs} +1 -1
  132. package/dist/{chunk-LLOAPSQ6.mjs.map → chunk-2IXFGSUA.mjs.map} +1 -1
  133. package/dist/{chunk-TF6N37OE.mjs → chunk-5L2V7WD3.mjs} +1 -1
  134. package/dist/{chunk-TF6N37OE.mjs.map → chunk-5L2V7WD3.mjs.map} +1 -1
  135. package/dist/{chunk-AB3DGGY3.mjs → chunk-5P2QE2VI.mjs} +2 -2
  136. package/dist/{chunk-AB3DGGY3.mjs.map → chunk-5P2QE2VI.mjs.map} +1 -1
  137. package/dist/{chunk-3GMXDQQQ.mjs → chunk-62EFHAYX.mjs} +4 -4
  138. package/dist/{chunk-3GMXDQQQ.mjs.map → chunk-62EFHAYX.mjs.map} +1 -1
  139. package/dist/{chunk-YNRYG5OB.mjs → chunk-7XTQCUMW.mjs} +1 -1
  140. package/dist/{chunk-YNRYG5OB.mjs.map → chunk-7XTQCUMW.mjs.map} +1 -1
  141. package/dist/{chunk-25R2U4KM.mjs → chunk-ACFP3XMB.mjs} +1 -1
  142. package/dist/{chunk-25R2U4KM.mjs.map → chunk-ACFP3XMB.mjs.map} +1 -1
  143. package/dist/{chunk-I2NAKQIE.mjs → chunk-DAJZ3JCI.mjs} +2 -2
  144. package/dist/{chunk-I2NAKQIE.mjs.map → chunk-DAJZ3JCI.mjs.map} +1 -1
  145. package/dist/{chunk-L25VRQ54.mjs → chunk-DD73BULA.mjs} +1 -1
  146. package/dist/chunk-DD73BULA.mjs.map +1 -0
  147. package/dist/{chunk-PHG5JCSW.mjs → chunk-DOOIIHT3.mjs} +1 -1
  148. package/dist/{chunk-PHG5JCSW.mjs.map → chunk-DOOIIHT3.mjs.map} +1 -1
  149. package/dist/{chunk-KPG3XQEN.mjs → chunk-DPLJQQFX.mjs} +1 -1
  150. package/dist/chunk-DPLJQQFX.mjs.map +1 -0
  151. package/dist/{chunk-OS5PZ4B4.mjs → chunk-E6C5EZQA.mjs} +1 -1
  152. package/dist/{chunk-OS5PZ4B4.mjs.map → chunk-E6C5EZQA.mjs.map} +1 -1
  153. package/dist/{chunk-VOAKEOIM.mjs → chunk-E7BJSLIX.mjs} +2 -2
  154. package/dist/{chunk-VOAKEOIM.mjs.map → chunk-E7BJSLIX.mjs.map} +1 -1
  155. package/dist/{chunk-MTT7OPUK.mjs → chunk-EW3RT4QW.mjs} +4 -4
  156. package/dist/{chunk-MTT7OPUK.mjs.map → chunk-EW3RT4QW.mjs.map} +1 -1
  157. package/dist/{chunk-5NSVMWDQ.mjs → chunk-FQ4K36VD.mjs} +1 -1
  158. package/dist/{chunk-5NSVMWDQ.mjs.map → chunk-FQ4K36VD.mjs.map} +1 -1
  159. package/dist/chunk-GNSJP2AB.mjs +10 -0
  160. package/dist/{chunk-ANJSX6WH.mjs.map → chunk-GNSJP2AB.mjs.map} +1 -1
  161. package/dist/{chunk-LIXL7PEP.mjs → chunk-JBDGK6X4.mjs} +1 -1
  162. package/dist/{chunk-LIXL7PEP.mjs.map → chunk-JBDGK6X4.mjs.map} +1 -1
  163. package/dist/{chunk-6Z2YFKXQ.mjs → chunk-KLJRZJOR.mjs} +1 -1
  164. package/dist/{chunk-6Z2YFKXQ.mjs.map → chunk-KLJRZJOR.mjs.map} +1 -1
  165. package/dist/{chunk-JD42XAYW.mjs → chunk-LCYPY5SA.mjs} +2 -2
  166. package/dist/{chunk-JD42XAYW.mjs.map → chunk-LCYPY5SA.mjs.map} +1 -1
  167. package/dist/{chunk-S3ZF7ZPG.mjs → chunk-LVB7BYUY.mjs} +4 -4
  168. package/dist/{chunk-S3ZF7ZPG.mjs.map → chunk-LVB7BYUY.mjs.map} +1 -1
  169. package/dist/{chunk-HK5OJANS.mjs → chunk-LVWX5B43.mjs} +1 -1
  170. package/dist/{chunk-HK5OJANS.mjs.map → chunk-LVWX5B43.mjs.map} +1 -1
  171. package/dist/{chunk-V6LXSPMF.mjs → chunk-LWXZFXY5.mjs} +1 -1
  172. package/dist/{chunk-V6LXSPMF.mjs.map → chunk-LWXZFXY5.mjs.map} +1 -1
  173. package/dist/{chunk-SORNYLIU.mjs → chunk-M7UI5ETO.mjs} +1 -1
  174. package/dist/{chunk-SORNYLIU.mjs.map → chunk-M7UI5ETO.mjs.map} +1 -1
  175. package/dist/{chunk-4RRRH7OY.mjs → chunk-ME352XO7.mjs} +1 -1
  176. package/dist/{chunk-4RRRH7OY.mjs.map → chunk-ME352XO7.mjs.map} +1 -1
  177. package/dist/{chunk-IFCX35BI.mjs → chunk-NTLX2MPV.mjs} +1 -1
  178. package/dist/{chunk-IFCX35BI.mjs.map → chunk-NTLX2MPV.mjs.map} +1 -1
  179. package/dist/{chunk-DVRGUUQG.mjs → chunk-NXPEUTDI.mjs} +1 -1
  180. package/dist/{chunk-DVRGUUQG.mjs.map → chunk-NXPEUTDI.mjs.map} +1 -1
  181. package/dist/{chunk-EXU45QAF.mjs → chunk-Q75KEFW5.mjs} +1 -1
  182. package/dist/{chunk-EXU45QAF.mjs.map → chunk-Q75KEFW5.mjs.map} +1 -1
  183. package/dist/{chunk-C4IZ7TGA.mjs → chunk-T5FDOBCA.mjs} +1 -1
  184. package/dist/chunk-T5FDOBCA.mjs.map +1 -0
  185. package/dist/{chunk-3PFYAKOD.mjs → chunk-VNMVP3DL.mjs} +1 -1
  186. package/dist/{chunk-3PFYAKOD.mjs.map → chunk-VNMVP3DL.mjs.map} +1 -1
  187. package/dist/{chunk-L3C6TG2V.mjs → chunk-XDKEPIUV.mjs} +1 -1
  188. package/dist/{chunk-L3C6TG2V.mjs.map → chunk-XDKEPIUV.mjs.map} +1 -1
  189. package/dist/chunk-XFCW7XJ4.mjs +9 -0
  190. package/dist/{chunk-SWPLMJR7.mjs.map → chunk-XFCW7XJ4.mjs.map} +1 -1
  191. package/dist/function/index.mjs +3 -3
  192. package/dist/index.js +3 -12
  193. package/dist/index.js.map +1 -1
  194. package/dist/index.mjs +65 -65
  195. package/dist/object/index.mjs +6 -6
  196. package/package.json +1 -1
  197. package/dist/chunk-ANJSX6WH.mjs +0 -12
  198. package/dist/chunk-C4IZ7TGA.mjs.map +0 -1
  199. package/dist/chunk-KPG3XQEN.mjs.map +0 -1
  200. package/dist/chunk-L25VRQ54.mjs.map +0 -1
  201. package/dist/chunk-SWPLMJR7.mjs +0 -16
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  take
3
- } from "../chunk-4RRRH7OY.mjs";
3
+ } from "../chunk-ME352XO7.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  take
@@ -18,6 +18,6 @@
18
18
  * // Returns [1, 2, 3]
19
19
  * takeRight([1, 2, 3], 5);
20
20
  */
21
- declare function takeRight<T>(arr: T[], count: number): T[];
21
+ declare function takeRight<T>(arr: readonly T[], count: number): T[];
22
22
 
23
23
  export { takeRight };
@@ -18,6 +18,6 @@
18
18
  * // Returns [1, 2, 3]
19
19
  * takeRight([1, 2, 3], 5);
20
20
  */
21
- declare function takeRight<T>(arr: T[], count: number): T[];
21
+ declare function takeRight<T>(arr: readonly T[], count: number): T[];
22
22
 
23
23
  export { takeRight };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/takeRight.ts"],"sourcesContent":["/**\n * Returns a new array containing the last `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {number} count - The number of elements to take.\n * @returns {T[]} A new array containing the last `count` elements from `arr`.\n *\n * @example\n * // Returns [4, 5]\n * takeRight([1, 2, 3, 4, 5], 2);\n *\n * @example\n * // Returns ['b', 'c']\n * takeRight(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * takeRight([1, 2, 3], 5);\n */\nexport function takeRight<T>(arr: T[], count: number): T[] {\n if (count === 0) {\n return [];\n }\n\n return arr.slice(-count);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,UAAa,KAAU,OAAoB;AACzD,MAAI,UAAU,GAAG;AACf,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,IAAI,MAAM,CAAC,KAAK;AACzB;","names":[]}
1
+ {"version":3,"sources":["../../src/array/takeRight.ts"],"sourcesContent":["/**\n * Returns a new array containing the last `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {number} count - The number of elements to take.\n * @returns {T[]} A new array containing the last `count` elements from `arr`.\n *\n * @example\n * // Returns [4, 5]\n * takeRight([1, 2, 3, 4, 5], 2);\n *\n * @example\n * // Returns ['b', 'c']\n * takeRight(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * takeRight([1, 2, 3], 5);\n */\nexport function takeRight<T>(arr: readonly T[], count: number): T[] {\n if (count === 0) {\n return [];\n }\n\n return arr.slice(-count);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,UAAa,KAAmB,OAAoB;AAClE,MAAI,UAAU,GAAG;AACf,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,IAAI,MAAM,CAAC,KAAK;AACzB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  takeRight
3
- } from "../chunk-L3C6TG2V.mjs";
3
+ } from "../chunk-XDKEPIUV.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  takeRight
@@ -15,6 +15,6 @@
15
15
  * // Returns []
16
16
  * takeRightWhile([1, 2, 3], n => n > 3);
17
17
  */
18
- declare function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
18
+ declare function takeRightWhile<T>(arr: readonly T[], shouldContinueTaking: (item: T) => boolean): T[];
19
19
 
20
20
  export { takeRightWhile };
@@ -15,6 +15,6 @@
15
15
  * // Returns []
16
16
  * takeRightWhile([1, 2, 3], n => n > 3);
17
17
  */
18
- declare function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
18
+ declare function takeRightWhile<T>(arr: readonly T[], shouldContinueTaking: (item: T) => boolean): T[];
19
19
 
20
20
  export { takeRightWhile };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/takeRightWhile.ts"],"sourcesContent":["/**\n * Takes elements from the end of the array while the predicate function returns `true`.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {function(T): boolean} shouldContinueTaking - The function invoked per element.\n * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.\n *\n * @example\n * // Returns [3, 2, 1]\n * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);\n *\n * @example\n * // Returns []\n * takeRightWhile([1, 2, 3], n => n > 3);\n */\nexport function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!shouldContinueTaking(arr[i])) {\n return arr.slice(i + 1);\n }\n }\n\n return arr.slice();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,eAAkB,KAAU,sBAAiD;AAC3F,WAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;AACxC,QAAI,CAAC,qBAAqB,IAAI,CAAC,CAAC,GAAG;AACjC,aAAO,IAAI,MAAM,IAAI,CAAC;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,IAAI,MAAM;AACnB;","names":[]}
1
+ {"version":3,"sources":["../../src/array/takeRightWhile.ts"],"sourcesContent":["/**\n * Takes elements from the end of the array while the predicate function returns `true`.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {function(T): boolean} shouldContinueTaking - The function invoked per element.\n * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.\n *\n * @example\n * // Returns [3, 2, 1]\n * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);\n *\n * @example\n * // Returns []\n * takeRightWhile([1, 2, 3], n => n > 3);\n */\nexport function takeRightWhile<T>(arr: readonly T[], shouldContinueTaking: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!shouldContinueTaking(arr[i])) {\n return arr.slice(i + 1);\n }\n }\n\n return arr.slice();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,eAAkB,KAAmB,sBAAiD;AACpG,WAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;AACxC,QAAI,CAAC,qBAAqB,IAAI,CAAC,CAAC,GAAG;AACjC,aAAO,IAAI,MAAM,IAAI,CAAC;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,IAAI,MAAM;AACnB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  takeRightWhile
3
- } from "../chunk-IFCX35BI.mjs";
3
+ } from "../chunk-NTLX2MPV.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  takeRightWhile
@@ -16,6 +16,6 @@
16
16
  * // Returns []
17
17
  * takeWhile([1, 2, 3, 4], x => x > 3);
18
18
  */
19
- declare function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[];
19
+ declare function takeWhile<T>(arr: readonly T[], shouldContinueTaking: (element: T) => boolean): T[];
20
20
 
21
21
  export { takeWhile };
@@ -16,6 +16,6 @@
16
16
  * // Returns []
17
17
  * takeWhile([1, 2, 3, 4], x => x > 3);
18
18
  */
19
- declare function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[];
19
+ declare function takeWhile<T>(arr: readonly T[], shouldContinueTaking: (element: T) => boolean): T[];
20
20
 
21
21
  export { takeWhile };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/takeWhile.ts"],"sourcesContent":["/**\n * Returns a new array containing the leading elements of the provided array\n * that satisfy the provided predicate function. It stops taking elements as soon\n * as an element does not satisfy the predicate.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @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.\n * @returns {T[]} A new array containing the leading elements that satisfy the predicate.\n *\n * @example\n * // Returns [1, 2]\n * takeWhile([1, 2, 3, 4], x => x < 3);\n *\n * @example\n * // Returns []\n * takeWhile([1, 2, 3, 4], x => x > 3);\n */\nexport function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (!shouldContinueTaking(item)) {\n break;\n }\n\n result.push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,UAAa,KAAU,sBAAoD;AACzF,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,QAAI,CAAC,qBAAqB,IAAI,GAAG;AAC/B;AAAA,IACF;AAEA,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/array/takeWhile.ts"],"sourcesContent":["/**\n * Returns a new array containing the leading elements of the provided array\n * that satisfy the provided predicate function. It stops taking elements as soon\n * as an element does not satisfy the predicate.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @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.\n * @returns {T[]} A new array containing the leading elements that satisfy the predicate.\n *\n * @example\n * // Returns [1, 2]\n * takeWhile([1, 2, 3, 4], x => x < 3);\n *\n * @example\n * // Returns []\n * takeWhile([1, 2, 3, 4], x => x > 3);\n */\nexport function takeWhile<T>(arr: readonly T[], shouldContinueTaking: (element: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (!shouldContinueTaking(item)) {\n break;\n }\n\n result.push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,UAAa,KAAmB,sBAAoD;AAClG,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,QAAI,CAAC,qBAAqB,IAAI,GAAG;AAC/B;AAAA,IACF;AAEA,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  takeWhile
3
- } from "../chunk-LLOAPSQ6.mjs";
3
+ } from "../chunk-2IXFGSUA.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  takeWhile
@@ -14,6 +14,6 @@
14
14
  * const result = union(array1, array2);
15
15
  * // result will be [1, 2, 3, 4, 5]
16
16
  */
17
- declare function union<T>(arr1: T[], arr2: T[]): T[];
17
+ declare function union<T>(arr1: readonly T[], arr2: readonly T[]): T[];
18
18
 
19
19
  export { union };
@@ -14,6 +14,6 @@
14
14
  * const result = union(array1, array2);
15
15
  * // result will be [1, 2, 3, 4, 5]
16
16
  */
17
- declare function union<T>(arr1: T[], arr2: T[]): T[];
17
+ declare function union<T>(arr1: readonly T[], arr2: readonly T[]): T[];
18
18
 
19
19
  export { union };
@@ -26,14 +26,7 @@ module.exports = __toCommonJS(union_exports);
26
26
 
27
27
  // src/array/uniq.ts
28
28
  function uniq(arr) {
29
- const result = [];
30
- for (const item of arr) {
31
- if (result.includes(item)) {
32
- continue;
33
- }
34
- result.push(item);
35
- }
36
- return result;
29
+ return Array.from(new Set(arr));
37
30
  }
38
31
 
39
32
  // src/array/union.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/union.ts","../../src/array/uniq.ts"],"sourcesContent":["import { uniq } from './uniq';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: T[], arr2: T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: T[]): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (result.includes(item)) {\n continue;\n }\n\n result.push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,SAAS,KAAQ,KAAe;AACrC,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,QAAI,OAAO,SAAS,IAAI,GAAG;AACzB;AAAA,IACF;AAEA,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;;;ADRO,SAAS,MAAS,MAAW,MAAgB;AAClD,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../../src/array/union.ts","../../src/array/uniq.ts"],"sourcesContent":["import { uniq } from './uniq';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ADEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  union
3
- } from "../chunk-I2NAKQIE.mjs";
4
- import "../chunk-SWPLMJR7.mjs";
3
+ } from "../chunk-DAJZ3JCI.mjs";
4
+ import "../chunk-XFCW7XJ4.mjs";
5
5
  import "../chunk-2MM5EJJX.mjs";
6
6
  export {
7
7
  union
@@ -18,6 +18,6 @@
18
18
  * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
19
19
  * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
20
20
  */
21
- declare function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
21
+ declare function unionBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[];
22
22
 
23
23
  export { unionBy };
@@ -18,6 +18,6 @@
18
18
  * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
19
19
  * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
20
20
  */
21
- declare function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
21
+ declare function unionBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[];
22
22
 
23
23
  export { unionBy };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/unionBy.ts"],"sourcesContent":["/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of [...arr1, ...arr2]) {\n const key = mapper(item);\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,QAAc,MAAW,MAAW,QAA6B;AAC/E,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG;AACrC,UAAM,MAAM,OAAO,IAAI;AACvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,CAAC,GAAG,IAAI,OAAO,CAAC;AACzB;","names":[]}
1
+ {"version":3,"sources":["../../src/array/unionBy.ts"],"sourcesContent":["/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of [...arr1, ...arr2]) {\n const key = mapper(item);\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,QAAc,MAAoB,MAAoB,QAA6B;AACjG,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG;AACrC,UAAM,MAAM,OAAO,IAAI;AACvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,CAAC,GAAG,IAAI,OAAO,CAAC;AACzB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unionBy
3
- } from "../chunk-LIXL7PEP.mjs";
3
+ } from "../chunk-JBDGK6X4.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  unionBy
@@ -17,6 +17,6 @@
17
17
  * const result = unionWith(array1, array2, areItemsEqual);
18
18
  * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
19
19
  */
20
- declare function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
20
+ declare function unionWith<T>(arr1: readonly T[], arr2: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
21
21
 
22
22
  export { unionWith };
@@ -17,6 +17,6 @@
17
17
  * const result = unionWith(array1, array2, areItemsEqual);
18
18
  * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
19
19
  */
20
- declare function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
20
+ declare function unionWith<T>(arr1: readonly T[], arr2: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
21
21
 
22
22
  export { unionWith };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/unionWith.ts","../../src/array/uniqWith.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * Creates an array of unique values from two given arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function, merges the arrays, and returns\n * a new array containing only the unique values as determined by the custom equality function.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array of unique values based on the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }];\n * const array2 = [{ id: 2 }, { id: 3 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = unionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays\n */\nexport function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n return uniqWith(arr1.concat(arr2), areItemsEqual);\n}\n","/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,SAAY,KAAU,eAAqD;AACzF,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;;;ADNO,SAAS,UAAa,MAAW,MAAW,eAAqD;AACtG,SAAO,SAAS,KAAK,OAAO,IAAI,GAAG,aAAa;AAClD;","names":[]}
1
+ {"version":3,"sources":["../../src/array/unionWith.ts","../../src/array/uniqWith.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * Creates an array of unique values from two given arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function, merges the arrays, and returns\n * a new array containing only the unique values as determined by the custom equality function.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array of unique values based on the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }];\n * const array2 = [{ id: 2 }, { id: 3 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = unionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays\n */\nexport function unionWith<T>(arr1: readonly T[], arr2: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n return uniqWith(arr1.concat(arr2), areItemsEqual);\n}\n","/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,SAAY,KAAmB,eAAqD;AAClG,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;;;ADNO,SAAS,UAAa,MAAoB,MAAoB,eAAqD;AACxH,SAAO,SAAS,KAAK,OAAO,IAAI,GAAG,aAAa;AAClD;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  unionWith
3
- } from "../chunk-AB3DGGY3.mjs";
4
- import "../chunk-DVRGUUQG.mjs";
3
+ } from "../chunk-5P2QE2VI.mjs";
4
+ import "../chunk-NXPEUTDI.mjs";
5
5
  import "../chunk-2MM5EJJX.mjs";
6
6
  export {
7
7
  unionWith
@@ -12,6 +12,6 @@
12
12
  * const result = uniq(array);
13
13
  * // result will be [1, 2, 3, 4, 5]
14
14
  */
15
- declare function uniq<T>(arr: T[]): T[];
15
+ declare function uniq<T>(arr: readonly T[]): T[];
16
16
 
17
17
  export { uniq };
@@ -12,6 +12,6 @@
12
12
  * const result = uniq(array);
13
13
  * // result will be [1, 2, 3, 4, 5]
14
14
  */
15
- declare function uniq<T>(arr: T[]): T[];
15
+ declare function uniq<T>(arr: readonly T[]): T[];
16
16
 
17
17
  export { uniq };
@@ -24,14 +24,7 @@ __export(uniq_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(uniq_exports);
26
26
  function uniq(arr) {
27
- const result = [];
28
- for (const item of arr) {
29
- if (result.includes(item)) {
30
- continue;
31
- }
32
- result.push(item);
33
- }
34
- return result;
27
+ return Array.from(new Set(arr));
35
28
  }
36
29
  // Annotate the CommonJS export names for ESM import in node:
37
30
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/uniq.ts"],"sourcesContent":["/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: T[]): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (result.includes(item)) {\n continue;\n }\n\n result.push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,KAAQ,KAAe;AACrC,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,QAAI,OAAO,SAAS,IAAI,GAAG;AACzB;AAAA,IACF;AAEA,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/array/uniq.ts"],"sourcesContent":["/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  uniq
3
- } from "../chunk-SWPLMJR7.mjs";
3
+ } from "../chunk-XFCW7XJ4.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  uniq
@@ -13,6 +13,6 @@
13
13
  * // [1.2, 2.1, 3.3, 5.7, 7.19]
14
14
  * ```
15
15
  */
16
- declare function uniqBy<T, U>(arr: T[], converter: (item: T) => U): T[];
16
+ declare function uniqBy<T, U>(arr: readonly T[], converter: (item: T) => U): T[];
17
17
 
18
18
  export { uniqBy };
@@ -13,6 +13,6 @@
13
13
  * // [1.2, 2.1, 3.3, 5.7, 7.19]
14
14
  * ```
15
15
  */
16
- declare function uniqBy<T, U>(arr: T[], converter: (item: T) => U): T[];
16
+ declare function uniqBy<T, U>(arr: readonly T[], converter: (item: T) => U): T[];
17
17
 
18
18
  export { uniqBy };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/uniqBy.ts","../../src/array/uniqWith.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.\n *\n * It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} converter - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the converter function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.3, 5.7, 7.19]\n * ```\n */\nexport function uniqBy<T, U>(arr: T[], converter: (item: T) => U): T[] {\n return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));\n}\n","/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,SAAY,KAAU,eAAqD;AACzF,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;;;ADVO,SAAS,OAAa,KAAU,WAAgC;AACrE,SAAO,SAAS,KAAK,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM,UAAU,KAAK,CAAC;AAC9E;","names":[]}
1
+ {"version":3,"sources":["../../src/array/uniqBy.ts","../../src/array/uniqWith.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * The `uniqBy` function takes an array as its first argument and a 'converter' function as the second. It maps the array elements using the converter function, then removes any duplicates.\n *\n * It filters out elements with the same value, meaning it does not check for duplicates in data types like Objects.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} converter - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the converter function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.3, 5.7, 7.19]\n * ```\n */\nexport function uniqBy<T, U>(arr: readonly T[], converter: (item: T) => U): T[] {\n return uniqWith(arr, (item1, item2) => converter(item1) === converter(item2));\n}\n","/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,SAAY,KAAmB,eAAqD;AAClG,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;;;ADVO,SAAS,OAAa,KAAmB,WAAgC;AAC9E,SAAO,SAAS,KAAK,CAAC,OAAO,UAAU,UAAU,KAAK,MAAM,UAAU,KAAK,CAAC;AAC9E;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  uniqBy
3
- } from "../chunk-JD42XAYW.mjs";
4
- import "../chunk-DVRGUUQG.mjs";
3
+ } from "../chunk-LCYPY5SA.mjs";
4
+ import "../chunk-NXPEUTDI.mjs";
5
5
  import "../chunk-2MM5EJJX.mjs";
6
6
  export {
7
7
  uniqBy
@@ -13,6 +13,6 @@
13
13
  * // [1.2, 3.2, 5.7, 7.19]
14
14
  * ```
15
15
  */
16
- declare function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
16
+ declare function uniqWith<T>(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
17
17
 
18
18
  export { uniqWith };
@@ -13,6 +13,6 @@
13
13
  * // [1.2, 3.2, 5.7, 7.19]
14
14
  * ```
15
15
  */
16
- declare function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
16
+ declare function uniqWith<T>(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
17
17
 
18
18
  export { uniqWith };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/uniqWith.ts"],"sourcesContent":["/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,SAAY,KAAU,eAAqD;AACzF,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/array/uniqWith.ts"],"sourcesContent":["/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,SAAY,KAAmB,eAAqD;AAClG,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  uniqWith
3
- } from "../chunk-DVRGUUQG.mjs";
3
+ } from "../chunk-NXPEUTDI.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  uniqWith
@@ -14,6 +14,6 @@
14
14
  * // Returns ['a', 'c']
15
15
  * xor(['a', 'b'], ['b', 'c']);
16
16
  */
17
- declare function xor<T>(arr1: T[], arr2: T[]): T[];
17
+ declare function xor<T>(arr1: readonly T[], arr2: readonly T[]): T[];
18
18
 
19
19
  export { xor };
@@ -14,6 +14,6 @@
14
14
  * // Returns ['a', 'c']
15
15
  * xor(['a', 'b'], ['b', 'c']);
16
16
  */
17
- declare function xor<T>(arr1: T[], arr2: T[]): T[];
17
+ declare function xor<T>(arr1: readonly T[], arr2: readonly T[]): T[];
18
18
 
19
19
  export { xor };
package/dist/array/xor.js CHANGED
@@ -39,14 +39,7 @@ function intersection(firstArr, secondArr) {
39
39
 
40
40
  // src/array/uniq.ts
41
41
  function uniq(arr) {
42
- const result = [];
43
- for (const item of arr) {
44
- if (result.includes(item)) {
45
- continue;
46
- }
47
- result.push(item);
48
- }
49
- return result;
42
+ return Array.from(new Set(arr));
50
43
  }
51
44
 
52
45
  // src/array/union.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/xor.ts","../../src/array/difference.ts","../../src/array/intersection.ts","../../src/array/uniq.ts","../../src/array/union.ts"],"sourcesContent":["import { difference } from './difference';\nimport { intersection } from './intersection';\nimport { union } from './union';\n\n/**\n * Computes the symmetric difference between two arrays. The symmetric difference is the set of elements\n * which are in either of the arrays, but not in their intersection.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.\n *\n * @example\n * // Returns [1, 2, 5, 6]\n * xor([1, 2, 3, 4], [3, 4, 5, 6]);\n *\n * @example\n * // Returns ['a', 'c']\n * xor(['a', 'b'], ['b', 'c']);\n */\nexport function xor<T>(arr1: T[], arr2: T[]): T[] {\n return difference(union(arr1, arr2), intersection(arr1, arr2));\n}\n","/**\n * Computes the difference between two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements\n * that are present in the first array but not in the second array. It effectively\n * filters out any elements from the first array that also appear in the second array.\n *\n * @template T\n * @param {T[]} firstArr - The array from which to derive the difference. This is the primary array\n * from which elements will be compared and filtered.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * Each element in this array will be checked against the first array, and if a match is found,\n * that element will be excluded from the result.\n * @returns {T[]} A new array containing the elements that are present in the first array but not\n * in the second array.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [2, 4];\n * const result = difference(array1, array2);\n * // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.\n */\nexport function difference<T>(firstArr: T[], secondArr: T[]): T[] {\n const secondSet = new Set(secondArr);\n\n return firstArr.filter(item => !secondSet.has(item));\n}\n","/**\n * Returns the intersection of two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements that are\n * present in both arrays. It effectively filters out any elements from the first array that\n * are not found in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @returns {T[]} A new array containing the elements that are present in both arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection<T>(firstArr: T[], secondArr: T[]): T[] {\n return firstArr.filter(item => {\n return secondArr.includes(item);\n });\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: T[]): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (result.includes(item)) {\n continue;\n }\n\n result.push(item);\n }\n\n return result;\n}\n","import { uniq } from './uniq';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: T[], arr2: T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsBO,SAAS,WAAc,UAAe,WAAqB;AAChE,QAAM,YAAY,IAAI,IAAI,SAAS;AAEnC,SAAO,SAAS,OAAO,UAAQ,CAAC,UAAU,IAAI,IAAI,CAAC;AACrD;;;ACTO,SAAS,aAAgB,UAAe,WAAqB;AAClE,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,UAAU,SAAS,IAAI;AAAA,EAChC,CAAC;AACH;;;ACPO,SAAS,KAAQ,KAAe;AACrC,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,QAAI,OAAO,SAAS,IAAI,GAAG;AACzB;AAAA,IACF;AAEA,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;;;ACRO,SAAS,MAAS,MAAW,MAAgB;AAClD,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;;;AJAO,SAAS,IAAO,MAAW,MAAgB;AAChD,SAAO,WAAW,MAAM,MAAM,IAAI,GAAG,aAAa,MAAM,IAAI,CAAC;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../src/array/xor.ts","../../src/array/difference.ts","../../src/array/intersection.ts","../../src/array/uniq.ts","../../src/array/union.ts"],"sourcesContent":["import { difference } from './difference';\nimport { intersection } from './intersection';\nimport { union } from './union';\n\n/**\n * Computes the symmetric difference between two arrays. The symmetric difference is the set of elements\n * which are in either of the arrays, but not in their intersection.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.\n *\n * @example\n * // Returns [1, 2, 5, 6]\n * xor([1, 2, 3, 4], [3, 4, 5, 6]);\n *\n * @example\n * // Returns ['a', 'c']\n * xor(['a', 'b'], ['b', 'c']);\n */\nexport function xor<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return difference(union(arr1, arr2), intersection(arr1, arr2));\n}\n","/**\n * Computes the difference between two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements\n * that are present in the first array but not in the second array. It effectively\n * filters out any elements from the first array that also appear in the second array.\n *\n * @template T\n * @param {T[]} firstArr - The array from which to derive the difference. This is the primary array\n * from which elements will be compared and filtered.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * Each element in this array will be checked against the first array, and if a match is found,\n * that element will be excluded from the result.\n * @returns {T[]} A new array containing the elements that are present in the first array but not\n * in the second array.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [2, 4];\n * const result = difference(array1, array2);\n * // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.\n */\nexport function difference<T>(firstArr: readonly T[], secondArr: T[]): T[] {\n const secondSet = new Set(secondArr);\n\n return firstArr.filter(item => !secondSet.has(item));\n}\n","/**\n * Returns the intersection of two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements that are\n * present in both arrays. It effectively filters out any elements from the first array that\n * are not found in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @returns {T[]} A new array containing the elements that are present in both arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection<T>(firstArr: readonly T[], secondArr: readonly T[]): T[] {\n return firstArr.filter(item => {\n return secondArr.includes(item);\n });\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsBO,SAAS,WAAc,UAAwB,WAAqB;AACzE,QAAM,YAAY,IAAI,IAAI,SAAS;AAEnC,SAAO,SAAS,OAAO,UAAQ,CAAC,UAAU,IAAI,IAAI,CAAC;AACrD;;;ACTO,SAAS,aAAgB,UAAwB,WAA8B;AACpF,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,UAAU,SAAS,IAAI;AAAA,EAChC,CAAC;AACH;;;ACPO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ACEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;;;AJAO,SAAS,IAAO,MAAoB,MAAyB;AAClE,SAAO,WAAW,MAAM,MAAM,IAAI,GAAG,aAAa,MAAM,IAAI,CAAC;AAC/D;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  xor
3
- } from "../chunk-3GMXDQQQ.mjs";
4
- import "../chunk-I2NAKQIE.mjs";
5
- import "../chunk-SWPLMJR7.mjs";
6
- import "../chunk-YNRYG5OB.mjs";
7
- import "../chunk-SORNYLIU.mjs";
3
+ } from "../chunk-62EFHAYX.mjs";
4
+ import "../chunk-DAJZ3JCI.mjs";
5
+ import "../chunk-XFCW7XJ4.mjs";
6
+ import "../chunk-7XTQCUMW.mjs";
7
+ import "../chunk-M7UI5ETO.mjs";
8
8
  import "../chunk-2MM5EJJX.mjs";
9
9
  export {
10
10
  xor
@@ -17,6 +17,6 @@
17
17
  * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
18
18
  * // Returns [{ id: 1 }, { id: 3 }]
19
19
  */
20
- declare function xorBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
20
+ declare function xorBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[];
21
21
 
22
22
  export { xorBy };
@@ -17,6 +17,6 @@
17
17
  * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
18
18
  * // Returns [{ id: 1 }, { id: 3 }]
19
19
  */
20
- declare function xorBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
20
+ declare function xorBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[];
21
21
 
22
22
  export { xorBy };
@@ -34,10 +34,8 @@ function differenceBy(firstArr, secondArr, mapper) {
34
34
 
35
35
  // src/array/intersectionBy.ts
36
36
  function intersectionBy(firstArr, secondArr, mapper) {
37
- const mappedSecondArr = secondArr.map((x) => mapper(x));
38
- return firstArr.filter((item) => {
39
- return mappedSecondArr.includes(mapper(item));
40
- });
37
+ const mappedSecondSet = new Set(secondArr.map(mapper));
38
+ return firstArr.filter((item) => mappedSecondSet.has(mapper(item)));
41
39
  }
42
40
 
43
41
  // src/array/unionBy.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/array/xorBy.ts","../../src/array/differenceBy.ts","../../src/array/intersectionBy.ts","../../src/array/unionBy.ts"],"sourcesContent":["import { differenceBy } from './differenceBy';\nimport { intersectionBy } from './intersectionBy';\nimport { unionBy } from './unionBy';\n\n/**\n * Computes the symmetric difference between two arrays using a custom mapping function.\n * The symmetric difference is the set of elements which are in either of the arrays,\n * but not in their intersection, determined by the result of the mapping function.\n *\n * @template T - Type of elements in the input arrays.\n * @template U - Type of the values returned by the mapping function.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = obj => obj.id;\n * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 3 }]\n */\nexport function xorBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[] {\n const union = unionBy(arr1, arr2, mapper);\n const intersection = intersectionBy(arr1, arr2, mapper);\n\n return differenceBy(union, intersection, mapper);\n}\n","/**\n * Computes the difference between two arrays after mapping their elements through a provided function.\n *\n * This function takes two arrays and a mapper function. It returns a new array containing the elements\n * that are present in the first array but not in the second array, based on the identity calculated\n * by the mapper function.\n *\n * Essentially, it filters out any elements from the first array that, when\n * mapped, match an element in the mapped version of the second array.\n *\n * @template T, U\n * @param {T[]} firstArr - The primary array from which to derive the difference.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function\n * is applied to each element in both arrays, and the comparison is made based on the mapped values.\n * @returns {T[]} A new array containing the elements from the first array that do not have a corresponding\n * mapped identity in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = differenceBy(array1, array2, mapper);\n * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.\n */\nexport function differenceBy<T, U>(firstArr: T[], secondArr: T[], mapper: (value: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(item => mapper(item)));\n\n return firstArr.filter(item => {\n return !mappedSecondSet.has(mapper(item));\n });\n}\n","/**\n * Returns the intersection of two arrays based on a mapping function.\n *\n * This function takes two arrays and a mapping function. It returns a new array containing\n * the elements from the first array that, when mapped using the provided function, have matching\n * mapped elements in the second array. It effectively filters out any elements from the first array\n * that do not have corresponding mapped values in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = intersectionBy(array1, array2, mapper);\n * // result will be [{ id: 2 }] since only this element has a matching id in both arrays.\n */\nexport function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) => U): T[] {\n const mappedSecondArr = secondArr.map(x => mapper(x));\n\n return firstArr.filter(item => {\n return mappedSecondArr.includes(mapper(item));\n });\n}\n","/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of [...arr1, ...arr2]) {\n const key = mapper(item);\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBO,SAAS,aAAmB,UAAe,WAAgB,QAA8B;AAC9F,QAAM,kBAAkB,IAAI,IAAI,UAAU,IAAI,UAAQ,OAAO,IAAI,CAAC,CAAC;AAEnE,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,CAAC,gBAAgB,IAAI,OAAO,IAAI,CAAC;AAAA,EAC1C,CAAC;AACH;;;ACXO,SAAS,eAAqB,UAAe,WAAgB,QAA6B;AAC/F,QAAM,kBAAkB,UAAU,IAAI,OAAK,OAAO,CAAC,CAAC;AAEpD,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,gBAAgB,SAAS,OAAO,IAAI,CAAC;AAAA,EAC9C,CAAC;AACH;;;ACNO,SAAS,QAAc,MAAW,MAAW,QAA6B;AAC/E,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG;AACrC,UAAM,MAAM,OAAO,IAAI;AACvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,CAAC,GAAG,IAAI,OAAO,CAAC;AACzB;;;AHRO,SAAS,MAAY,MAAW,MAAW,QAA6B;AAC7E,QAAM,QAAQ,QAAQ,MAAM,MAAM,MAAM;AACxC,QAAM,eAAe,eAAe,MAAM,MAAM,MAAM;AAEtD,SAAO,aAAa,OAAO,cAAc,MAAM;AACjD;","names":[]}
1
+ {"version":3,"sources":["../../src/array/xorBy.ts","../../src/array/differenceBy.ts","../../src/array/intersectionBy.ts","../../src/array/unionBy.ts"],"sourcesContent":["import { differenceBy } from './differenceBy';\nimport { intersectionBy } from './intersectionBy';\nimport { unionBy } from './unionBy';\n\n/**\n * Computes the symmetric difference between two arrays using a custom mapping function.\n * The symmetric difference is the set of elements which are in either of the arrays,\n * but not in their intersection, determined by the result of the mapping function.\n *\n * @template T - Type of elements in the input arrays.\n * @template U - Type of the values returned by the mapping function.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = obj => obj.id;\n * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 3 }]\n */\nexport function xorBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[] {\n const union = unionBy(arr1, arr2, mapper);\n const intersection = intersectionBy(arr1, arr2, mapper);\n\n return differenceBy(union, intersection, mapper);\n}\n","/**\n * Computes the difference between two arrays after mapping their elements through a provided function.\n *\n * This function takes two arrays and a mapper function. It returns a new array containing the elements\n * that are present in the first array but not in the second array, based on the identity calculated\n * by the mapper function.\n *\n * Essentially, it filters out any elements from the first array that, when\n * mapped, match an element in the mapped version of the second array.\n *\n * @template T, U\n * @param {T[]} firstArr - The primary array from which to derive the difference.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function\n * is applied to each element in both arrays, and the comparison is made based on the mapped values.\n * @returns {T[]} A new array containing the elements from the first array that do not have a corresponding\n * mapped identity in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = differenceBy(array1, array2, mapper);\n * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.\n */\nexport function differenceBy<T, U>(firstArr: readonly T[], secondArr: readonly T[], mapper: (value: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(item => mapper(item)));\n\n return firstArr.filter(item => {\n return !mappedSecondSet.has(mapper(item));\n });\n}\n","/**\n * Returns the intersection of two arrays based on a mapping function.\n *\n * This function takes two arrays and a mapping function. It returns a new array containing\n * the elements from the first array that, when mapped using the provided function, have matching\n * mapped elements in the second array. It effectively filters out any elements from the first array\n * that do not have corresponding mapped values in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = intersectionBy(array1, array2, mapper);\n * // result will be [{ id: 2 }] since only this element has a matching id in both arrays.\n */\nexport function intersectionBy<T, U>(firstArr: readonly T[], secondArr: readonly T[], mapper: (item: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(mapper));\n return firstArr.filter(item => mappedSecondSet.has(mapper(item)));\n}\n","/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of [...arr1, ...arr2]) {\n const key = mapper(item);\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBO,SAAS,aAAmB,UAAwB,WAAyB,QAA8B;AAChH,QAAM,kBAAkB,IAAI,IAAI,UAAU,IAAI,UAAQ,OAAO,IAAI,CAAC,CAAC;AAEnE,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,CAAC,gBAAgB,IAAI,OAAO,IAAI,CAAC;AAAA,EAC1C,CAAC;AACH;;;ACXO,SAAS,eAAqB,UAAwB,WAAyB,QAA6B;AACjH,QAAM,kBAAkB,IAAI,IAAI,UAAU,IAAI,MAAM,CAAC;AACrD,SAAO,SAAS,OAAO,UAAQ,gBAAgB,IAAI,OAAO,IAAI,CAAC,CAAC;AAClE;;;ACHO,SAAS,QAAc,MAAoB,MAAoB,QAA6B;AACjG,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG;AACrC,UAAM,MAAM,OAAO,IAAI;AACvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,CAAC,GAAG,IAAI,OAAO,CAAC;AACzB;;;AHRO,SAAS,MAAY,MAAoB,MAAoB,QAA6B;AAC/F,QAAM,QAAQ,QAAQ,MAAM,MAAM,MAAM;AACxC,QAAM,eAAe,eAAe,MAAM,MAAM,MAAM;AAEtD,SAAO,aAAa,OAAO,cAAc,MAAM;AACjD;","names":[]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  xorBy
3
- } from "../chunk-MTT7OPUK.mjs";
4
- import "../chunk-LIXL7PEP.mjs";
5
- import "../chunk-ANJSX6WH.mjs";
6
- import "../chunk-HK5OJANS.mjs";
3
+ } from "../chunk-EW3RT4QW.mjs";
4
+ import "../chunk-JBDGK6X4.mjs";
5
+ import "../chunk-GNSJP2AB.mjs";
6
+ import "../chunk-LVWX5B43.mjs";
7
7
  import "../chunk-2MM5EJJX.mjs";
8
8
  export {
9
9
  xorBy
@@ -16,6 +16,6 @@
16
16
  * xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
17
17
  * // Returns [{ id: 1 }, { id: 3 }]
18
18
  */
19
- declare function xorWith<T>(arr1: T[], arr2: T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
19
+ declare function xorWith<T>(arr1: readonly T[], arr2: readonly T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
20
20
 
21
21
  export { xorWith };
@@ -16,6 +16,6 @@
16
16
  * xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);
17
17
  * // Returns [{ id: 1 }, { id: 3 }]
18
18
  */
19
- declare function xorWith<T>(arr1: T[], arr2: T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
19
+ declare function xorWith<T>(arr1: readonly T[], arr2: readonly T[], areElementsEqual: (item1: T, item2: T) => boolean): T[];
20
20
 
21
21
  export { xorWith };