@vielzeug/arsenal 2.1.0 → 3.0.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 (240) hide show
  1. package/README.md +5 -18
  2. package/dist/array/chunk.cjs.map +1 -1
  3. package/dist/array/chunk.d.ts +1 -1
  4. package/dist/array/chunk.d.ts.map +1 -1
  5. package/dist/array/chunk.js.map +1 -1
  6. package/dist/array/compact.cjs.map +1 -1
  7. package/dist/array/compact.d.ts +1 -1
  8. package/dist/array/compact.d.ts.map +1 -1
  9. package/dist/array/compact.js.map +1 -1
  10. package/dist/array/contains.cjs.map +1 -1
  11. package/dist/array/contains.d.ts +1 -1
  12. package/dist/array/contains.d.ts.map +1 -1
  13. package/dist/array/contains.js.map +1 -1
  14. package/dist/array/countBy.cjs.map +1 -1
  15. package/dist/array/countBy.d.ts +1 -1
  16. package/dist/array/countBy.d.ts.map +1 -1
  17. package/dist/array/countBy.js.map +1 -1
  18. package/dist/array/difference.cjs.map +1 -1
  19. package/dist/array/difference.d.ts +4 -2
  20. package/dist/array/difference.d.ts.map +1 -1
  21. package/dist/array/difference.js.map +1 -1
  22. package/dist/array/drop.cjs.map +1 -1
  23. package/dist/array/drop.d.ts +1 -1
  24. package/dist/array/drop.d.ts.map +1 -1
  25. package/dist/array/drop.js.map +1 -1
  26. package/dist/array/dropLast.cjs.map +1 -1
  27. package/dist/array/dropLast.d.ts +1 -1
  28. package/dist/array/dropLast.d.ts.map +1 -1
  29. package/dist/array/dropLast.js.map +1 -1
  30. package/dist/array/filterMap.cjs.map +1 -1
  31. package/dist/array/filterMap.d.ts +3 -1
  32. package/dist/array/filterMap.d.ts.map +1 -1
  33. package/dist/array/filterMap.js.map +1 -1
  34. package/dist/array/first.cjs.map +1 -1
  35. package/dist/array/first.d.ts +1 -1
  36. package/dist/array/first.d.ts.map +1 -1
  37. package/dist/array/first.js.map +1 -1
  38. package/dist/array/groupBy.cjs.map +1 -1
  39. package/dist/array/groupBy.d.ts +1 -1
  40. package/dist/array/groupBy.d.ts.map +1 -1
  41. package/dist/array/groupBy.js.map +1 -1
  42. package/dist/array/index.cjs +1 -1
  43. package/dist/array/index.d.ts +0 -1
  44. package/dist/array/index.d.ts.map +1 -1
  45. package/dist/array/index.js +17 -18
  46. package/dist/array/indexBy.cjs.map +1 -1
  47. package/dist/array/indexBy.d.ts +1 -1
  48. package/dist/array/indexBy.d.ts.map +1 -1
  49. package/dist/array/indexBy.js.map +1 -1
  50. package/dist/array/intersection.cjs.map +1 -1
  51. package/dist/array/intersection.d.ts +4 -2
  52. package/dist/array/intersection.d.ts.map +1 -1
  53. package/dist/array/intersection.js.map +1 -1
  54. package/dist/array/last.cjs.map +1 -1
  55. package/dist/array/last.d.ts +1 -1
  56. package/dist/array/last.d.ts.map +1 -1
  57. package/dist/array/last.js.map +1 -1
  58. package/dist/array/partition.cjs.map +1 -1
  59. package/dist/array/partition.d.ts +3 -1
  60. package/dist/array/partition.d.ts.map +1 -1
  61. package/dist/array/partition.js.map +1 -1
  62. package/dist/array/replace.cjs.map +1 -1
  63. package/dist/array/replace.d.ts +2 -15
  64. package/dist/array/replace.d.ts.map +1 -1
  65. package/dist/array/replace.js.map +1 -1
  66. package/dist/array/rotate.cjs.map +1 -1
  67. package/dist/array/rotate.d.ts +5 -17
  68. package/dist/array/rotate.d.ts.map +1 -1
  69. package/dist/array/rotate.js.map +1 -1
  70. package/dist/array/sort.cjs.map +1 -1
  71. package/dist/array/sort.d.ts +2 -2
  72. package/dist/array/sort.d.ts.map +1 -1
  73. package/dist/array/sort.js.map +1 -1
  74. package/dist/array/take.cjs.map +1 -1
  75. package/dist/array/take.d.ts +1 -1
  76. package/dist/array/take.d.ts.map +1 -1
  77. package/dist/array/take.js.map +1 -1
  78. package/dist/array/takeLast.cjs.map +1 -1
  79. package/dist/array/takeLast.d.ts +1 -1
  80. package/dist/array/takeLast.d.ts.map +1 -1
  81. package/dist/array/takeLast.js.map +1 -1
  82. package/dist/array/toggle.cjs.map +1 -1
  83. package/dist/array/toggle.d.ts +1 -1
  84. package/dist/array/toggle.d.ts.map +1 -1
  85. package/dist/array/toggle.js.map +1 -1
  86. package/dist/array/union.cjs.map +1 -1
  87. package/dist/array/union.d.ts +4 -2
  88. package/dist/array/union.d.ts.map +1 -1
  89. package/dist/array/union.js.map +1 -1
  90. package/dist/array/uniq.cjs.map +1 -1
  91. package/dist/array/uniq.d.ts +1 -1
  92. package/dist/array/uniq.d.ts.map +1 -1
  93. package/dist/array/uniq.js.map +1 -1
  94. package/dist/array/zip.cjs.map +1 -1
  95. package/dist/array/zip.d.ts +1 -1
  96. package/dist/array/zip.d.ts.map +1 -1
  97. package/dist/array/zip.js.map +1 -1
  98. package/dist/arsenal.cjs +1 -1
  99. package/dist/arsenal.cjs.map +1 -1
  100. package/dist/arsenal.iife.js +1 -1
  101. package/dist/arsenal.iife.js.map +1 -1
  102. package/dist/arsenal.js +1 -1
  103. package/dist/arsenal.js.map +1 -1
  104. package/dist/async/abortError.cjs +1 -1
  105. package/dist/async/abortError.cjs.map +1 -1
  106. package/dist/async/abortError.d.ts +3 -2
  107. package/dist/async/abortError.d.ts.map +1 -1
  108. package/dist/async/abortError.js +2 -2
  109. package/dist/async/abortError.js.map +1 -1
  110. package/dist/cache/cache.cjs +1 -1
  111. package/dist/cache/cache.cjs.map +1 -1
  112. package/dist/cache/cache.d.ts +1 -0
  113. package/dist/cache/cache.d.ts.map +1 -1
  114. package/dist/cache/cache.js +1 -0
  115. package/dist/cache/cache.js.map +1 -1
  116. package/dist/function/assert.cjs.map +1 -1
  117. package/dist/function/assert.d.ts +1 -1
  118. package/dist/function/assert.js.map +1 -1
  119. package/dist/guards/index.cjs +1 -1
  120. package/dist/guards/index.js +7 -7
  121. package/dist/guards/isEmpty.cjs +1 -1
  122. package/dist/guards/isEmpty.cjs.map +1 -1
  123. package/dist/guards/isEmpty.d.ts.map +1 -1
  124. package/dist/guards/isEmpty.js +4 -5
  125. package/dist/guards/isEmpty.js.map +1 -1
  126. package/dist/guards/isFunction.cjs.map +1 -1
  127. package/dist/guards/isFunction.d.ts +1 -1
  128. package/dist/guards/isFunction.d.ts.map +1 -1
  129. package/dist/guards/isFunction.js.map +1 -1
  130. package/dist/guards/isPrimitive.cjs +1 -1
  131. package/dist/guards/isPrimitive.cjs.map +1 -1
  132. package/dist/guards/isPrimitive.d.ts +4 -17
  133. package/dist/guards/isPrimitive.d.ts.map +1 -1
  134. package/dist/guards/isPrimitive.js +1 -2
  135. package/dist/guards/isPrimitive.js.map +1 -1
  136. package/dist/index.cjs +1 -1
  137. package/dist/index.d.ts +6 -1
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +27 -22
  140. package/dist/math/average.cjs +1 -1
  141. package/dist/math/average.cjs.map +1 -1
  142. package/dist/math/average.d.ts +3 -2
  143. package/dist/math/average.d.ts.map +1 -1
  144. package/dist/math/average.js +1 -6
  145. package/dist/math/average.js.map +1 -1
  146. package/dist/math/gcd.cjs +1 -1
  147. package/dist/math/gcd.cjs.map +1 -1
  148. package/dist/math/gcd.d.ts.map +1 -1
  149. package/dist/math/gcd.js +1 -0
  150. package/dist/math/gcd.js.map +1 -1
  151. package/dist/math/index.cjs +1 -1
  152. package/dist/math/index.d.ts +0 -1
  153. package/dist/math/index.d.ts.map +1 -1
  154. package/dist/math/index.js +7 -8
  155. package/dist/math/lcm.cjs +1 -1
  156. package/dist/math/lcm.cjs.map +1 -1
  157. package/dist/math/lcm.d.ts.map +1 -1
  158. package/dist/math/lcm.js +5 -1
  159. package/dist/math/lcm.js.map +1 -1
  160. package/dist/math/linspace.cjs +1 -1
  161. package/dist/math/linspace.cjs.map +1 -1
  162. package/dist/math/linspace.d.ts.map +1 -1
  163. package/dist/math/linspace.js +2 -1
  164. package/dist/math/linspace.js.map +1 -1
  165. package/dist/math/median.cjs.map +1 -1
  166. package/dist/math/median.d.ts +1 -1
  167. package/dist/math/median.d.ts.map +1 -1
  168. package/dist/math/median.js.map +1 -1
  169. package/dist/math/standardDeviation.cjs.map +1 -1
  170. package/dist/math/standardDeviation.d.ts +1 -1
  171. package/dist/math/standardDeviation.d.ts.map +1 -1
  172. package/dist/math/standardDeviation.js.map +1 -1
  173. package/dist/math/sum.cjs +1 -1
  174. package/dist/math/sum.cjs.map +1 -1
  175. package/dist/math/sum.d.ts +1 -1
  176. package/dist/math/sum.d.ts.map +1 -1
  177. package/dist/math/sum.js +1 -1
  178. package/dist/math/sum.js.map +1 -1
  179. package/dist/math/variance.cjs.map +1 -1
  180. package/dist/math/variance.d.ts +1 -1
  181. package/dist/math/variance.d.ts.map +1 -1
  182. package/dist/math/variance.js.map +1 -1
  183. package/dist/object/diff.cjs.map +1 -1
  184. package/dist/object/diff.d.ts +1 -1
  185. package/dist/object/diff.d.ts.map +1 -1
  186. package/dist/object/diff.js.map +1 -1
  187. package/dist/object/prune.cjs +1 -1
  188. package/dist/object/prune.cjs.map +1 -1
  189. package/dist/object/prune.d.ts.map +1 -1
  190. package/dist/object/prune.js +16 -17
  191. package/dist/object/prune.js.map +1 -1
  192. package/dist/random/_index.cjs +1 -1
  193. package/dist/random/_index.cjs.map +1 -1
  194. package/dist/random/_index.d.ts +1 -1
  195. package/dist/random/_index.d.ts.map +1 -1
  196. package/dist/random/_index.js +4 -5
  197. package/dist/random/_index.js.map +1 -1
  198. package/dist/random/index.cjs +1 -1
  199. package/dist/random/index.d.ts +0 -1
  200. package/dist/random/index.d.ts.map +1 -1
  201. package/dist/random/index.js +2 -2
  202. package/dist/random/source.cjs +2 -0
  203. package/dist/random/source.cjs.map +1 -0
  204. package/dist/random/source.d.ts +2 -0
  205. package/dist/random/source.d.ts.map +1 -1
  206. package/dist/random/source.js +10 -0
  207. package/dist/random/source.js.map +1 -0
  208. package/dist/string/index.cjs +1 -1
  209. package/dist/string/index.d.ts +1 -1
  210. package/dist/string/index.d.ts.map +1 -1
  211. package/dist/string/index.js +2 -2
  212. package/dist/string/{pad.cjs → padCenter.cjs} +2 -2
  213. package/dist/string/padCenter.cjs.map +1 -0
  214. package/dist/string/padCenter.d.ts +3 -0
  215. package/dist/string/padCenter.d.ts.map +1 -0
  216. package/dist/string/{pad.js → padCenter.js} +3 -3
  217. package/dist/string/padCenter.js.map +1 -0
  218. package/package.json +7 -7
  219. package/dist/array/flatten.cjs +0 -2
  220. package/dist/array/flatten.cjs.map +0 -1
  221. package/dist/array/flatten.d.ts +0 -5
  222. package/dist/array/flatten.d.ts.map +0 -1
  223. package/dist/array/flatten.js +0 -11
  224. package/dist/array/flatten.js.map +0 -1
  225. package/dist/math/percent.cjs +0 -2
  226. package/dist/math/percent.cjs.map +0 -1
  227. package/dist/math/percent.d.ts +0 -19
  228. package/dist/math/percent.d.ts.map +0 -1
  229. package/dist/math/percent.js +0 -8
  230. package/dist/math/percent.js.map +0 -1
  231. package/dist/random/uuid.cjs +0 -2
  232. package/dist/random/uuid.cjs.map +0 -1
  233. package/dist/random/uuid.d.ts +0 -12
  234. package/dist/random/uuid.d.ts.map +0 -1
  235. package/dist/random/uuid.js +0 -8
  236. package/dist/random/uuid.js.map +0 -1
  237. package/dist/string/pad.cjs.map +0 -1
  238. package/dist/string/pad.d.ts +0 -5
  239. package/dist/string/pad.d.ts.map +0 -1
  240. package/dist/string/pad.js.map +0 -1
@@ -1,18 +1,5 @@
1
1
  import type { Predicate } from '../types';
2
- /**
3
- * Replaces the first element in an array that satisfies the provided predicate
4
- * function with a new value.
5
- *
6
- * @example
7
- * ```ts
8
- * replace([1, 2, 3], (n) => n === 2, 4) // [1, 4, 3]
9
- * ```
10
- *
11
- * @param array - The array to search.
12
- * @param predicate - A function to test each element of the array.
13
- * @param value - The new value to replace the found element.
14
- *
15
- * @return A new array with the replaced value.
16
- */
2
+ /** Replaces the first matching item without mutating the input. */
17
3
  export declare function replace<T>(array: T[], predicate: Predicate<T>, value: T): T[];
4
+ export declare function replace<T>(array: readonly T[], predicate: Predicate<T>, value: T): readonly T[];
18
5
  //# sourceMappingURL=replace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/array/replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAM7E"}
1
+ {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/array/replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;AAC/E,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"replace.js","names":[],"sources":["../../src/array/replace.ts"],"sourcesContent":["import type { Predicate } from '../types';\n\n/**\n * Replaces the first element in an array that satisfies the provided predicate\n * function with a new value.\n *\n * @example\n * ```ts\n * replace([1, 2, 3], (n) => n === 2, 4) // [1, 4, 3]\n * ```\n *\n * @param array - The array to search.\n * @param predicate - A function to test each element of the array.\n * @param value - The new value to replace the found element.\n *\n * @return A new array with the replaced value.\n */\nexport function replace<T>(array: T[], predicate: Predicate<T>, value: T): T[] {\n const index = array.findIndex(predicate);\n\n if (index === -1) return array;\n\n return [...array.slice(0, index), value, ...array.slice(index + 1)];\n}\n"],"mappings":";AAiBA,SAAgB,EAAW,GAAY,GAAyB,GAAe;CAC7E,IAAM,IAAQ,EAAM,UAAU,CAAS;CAIvC,OAFI,MAAU,KAAW,IAElB;EAAC,GAAG,EAAM,MAAM,GAAG,CAAK;EAAG;EAAO,GAAG,EAAM,MAAM,IAAQ,CAAC;CAAC;AACpE"}
1
+ {"version":3,"file":"replace.js","names":[],"sources":["../../src/array/replace.ts"],"sourcesContent":["import type { Predicate } from '../types';\n\n/** Replaces the first matching item without mutating the input. */\nexport function replace<T>(array: T[], predicate: Predicate<T>, value: T): T[];\nexport function replace<T>(array: readonly T[], predicate: Predicate<T>, value: T): readonly T[];\nexport function replace<T>(array: readonly T[], predicate: Predicate<T>, value: T): readonly T[] {\n const index = array.findIndex(predicate);\n\n if (index === -1) return array;\n\n return [...array.slice(0, index), value, ...array.slice(index + 1)];\n}\n"],"mappings":";AAKA,SAAgB,EAAW,GAAqB,GAAyB,GAAwB;CAC/F,IAAM,IAAQ,EAAM,UAAU,CAAS;CAIvC,OAFI,MAAU,KAAW,IAElB;EAAC,GAAG,EAAM,MAAM,GAAG,CAAK;EAAG;EAAO,GAAG,EAAM,MAAM,IAAQ,CAAC;CAAC;AACpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"rotate.cjs","names":[],"sources":["../../src/array/rotate.ts"],"sourcesContent":["/**\n * Rotates the elements of an array by a specified number of positions.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * rotate(arr, 2); // [3, 4, 5]\n * rotate(arr, 2, { wrap: true }); // [3, 4, 5, 1, 2]\n * ```\n * @param array - The array to rotate.\n * @param positions - The number of positions to rotate the array.\n * @param [options] - Options for the rotate operation.\n * @param [options.wrap] - If `true`, the rotated-out elements are appended to the end.\n *\n * @returns A new array with the elements rotated.\n */\nexport function rotate<T>(array: T[], positions: number, { wrap = false }: { wrap?: boolean } = {}): T[] {\n if (array.length === 0) return array;\n\n const normalizedPos = ((positions % array.length) + array.length) % array.length;\n const rotated = array.slice(normalizedPos);\n\n return wrap ? [...rotated, ...array.slice(0, normalizedPos)] : rotated;\n}\n"],"mappings":"AAgBA,SAAgB,EAAU,EAAY,EAAmB,CAAE,OAAO,IAA8B,CAAC,EAAQ,CACvG,GAAI,EAAM,SAAW,EAAG,OAAO,EAE/B,IAAM,GAAkB,EAAY,EAAM,OAAU,EAAM,QAAU,EAAM,OACpE,EAAU,EAAM,MAAM,CAAa,EAEzC,OAAO,EAAO,CAAC,GAAG,EAAS,GAAG,EAAM,MAAM,EAAG,CAAa,CAAC,EAAI,CACjE"}
1
+ {"version":3,"file":"rotate.cjs","names":[],"sources":["../../src/array/rotate.ts"],"sourcesContent":["/** Rotates or drops leading items without mutating the input. */\nexport function rotate<T>(array: T[], positions: number, options?: { wrap?: boolean }): T[];\nexport function rotate<T>(array: readonly T[], positions: number, options?: { wrap?: boolean }): readonly T[];\nexport function rotate<T>(\n array: readonly T[],\n positions: number,\n { wrap = false }: { wrap?: boolean } = {},\n): readonly T[] {\n if (array.length === 0) return array;\n\n const normalizedPosition = ((positions % array.length) + array.length) % array.length;\n const rotated = array.slice(normalizedPosition);\n\n return wrap ? [...rotated, ...array.slice(0, normalizedPosition)] : rotated;\n}\n"],"mappings":"AAGA,SAAgB,EACd,EACA,EACA,CAAE,OAAO,IAA8B,CAAC,EAC1B,CACd,GAAI,EAAM,SAAW,EAAG,OAAO,EAE/B,IAAM,GAAuB,EAAY,EAAM,OAAU,EAAM,QAAU,EAAM,OACzE,EAAU,EAAM,MAAM,CAAkB,EAE9C,OAAO,EAAO,CAAC,GAAG,EAAS,GAAG,EAAM,MAAM,EAAG,CAAkB,CAAC,EAAI,CACtE"}
@@ -1,20 +1,8 @@
1
- /**
2
- * Rotates the elements of an array by a specified number of positions.
3
- *
4
- * @example
5
- * ```ts
6
- * const arr = [1, 2, 3, 4, 5];
7
- * rotate(arr, 2); // [3, 4, 5]
8
- * rotate(arr, 2, { wrap: true }); // [3, 4, 5, 1, 2]
9
- * ```
10
- * @param array - The array to rotate.
11
- * @param positions - The number of positions to rotate the array.
12
- * @param [options] - Options for the rotate operation.
13
- * @param [options.wrap] - If `true`, the rotated-out elements are appended to the end.
14
- *
15
- * @returns A new array with the elements rotated.
16
- */
17
- export declare function rotate<T>(array: T[], positions: number, { wrap }?: {
1
+ /** Rotates or drops leading items without mutating the input. */
2
+ export declare function rotate<T>(array: T[], positions: number, options?: {
18
3
  wrap?: boolean;
19
4
  }): T[];
5
+ export declare function rotate<T>(array: readonly T[], positions: number, options?: {
6
+ wrap?: boolean;
7
+ }): readonly T[];
20
8
  //# sourceMappingURL=rotate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/array/rotate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,IAAY,EAAE,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,CAAC,EAAE,CAOvG"}
1
+ {"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/array/rotate.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,CAAC,EAAE,CAAC;AAC5F,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rotate.js","names":[],"sources":["../../src/array/rotate.ts"],"sourcesContent":["/**\n * Rotates the elements of an array by a specified number of positions.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * rotate(arr, 2); // [3, 4, 5]\n * rotate(arr, 2, { wrap: true }); // [3, 4, 5, 1, 2]\n * ```\n * @param array - The array to rotate.\n * @param positions - The number of positions to rotate the array.\n * @param [options] - Options for the rotate operation.\n * @param [options.wrap] - If `true`, the rotated-out elements are appended to the end.\n *\n * @returns A new array with the elements rotated.\n */\nexport function rotate<T>(array: T[], positions: number, { wrap = false }: { wrap?: boolean } = {}): T[] {\n if (array.length === 0) return array;\n\n const normalizedPos = ((positions % array.length) + array.length) % array.length;\n const rotated = array.slice(normalizedPos);\n\n return wrap ? [...rotated, ...array.slice(0, normalizedPos)] : rotated;\n}\n"],"mappings":";AAgBA,SAAgB,EAAU,GAAY,GAAmB,EAAE,UAAO,OAA8B,CAAC,GAAQ;CACvG,IAAI,EAAM,WAAW,GAAG,OAAO;CAE/B,IAAM,KAAkB,IAAY,EAAM,SAAU,EAAM,UAAU,EAAM,QACpE,IAAU,EAAM,MAAM,CAAa;CAEzC,OAAO,IAAO,CAAC,GAAG,GAAS,GAAG,EAAM,MAAM,GAAG,CAAa,CAAC,IAAI;AACjE"}
1
+ {"version":3,"file":"rotate.js","names":[],"sources":["../../src/array/rotate.ts"],"sourcesContent":["/** Rotates or drops leading items without mutating the input. */\nexport function rotate<T>(array: T[], positions: number, options?: { wrap?: boolean }): T[];\nexport function rotate<T>(array: readonly T[], positions: number, options?: { wrap?: boolean }): readonly T[];\nexport function rotate<T>(\n array: readonly T[],\n positions: number,\n { wrap = false }: { wrap?: boolean } = {},\n): readonly T[] {\n if (array.length === 0) return array;\n\n const normalizedPosition = ((positions % array.length) + array.length) % array.length;\n const rotated = array.slice(normalizedPosition);\n\n return wrap ? [...rotated, ...array.slice(0, normalizedPosition)] : rotated;\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACA,GACA,EAAE,UAAO,OAA8B,CAAC,GAC1B;CACd,IAAI,EAAM,WAAW,GAAG,OAAO;CAE/B,IAAM,KAAuB,IAAY,EAAM,SAAU,EAAM,UAAU,EAAM,QACzE,IAAU,EAAM,MAAM,CAAkB;CAE9C,OAAO,IAAO,CAAC,GAAG,GAAS,GAAG,EAAM,MAAM,GAAG,CAAkB,CAAC,IAAI;AACtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"sort.cjs","names":[],"sources":["../../src/array/sort.ts"],"sourcesContent":["import { compare } from './compare';\nimport { compareBy } from './compareBy';\n\nexport type SortDirection = 'asc' | 'desc';\nexport type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;\n\n/**\n * Sorts an array by a selector function (single-field) or by a multi-field\n * object of `{ key: 'asc' | 'desc' }` entries.\n *\n * @example\n * ```ts\n * // Single field\n * sort([{ a: 2 }, { a: 1 }], item => item.a); // [{ a:1 }, { a:2 }]\n * sort([{ a: 2 }, { a: 1 }], item => item.a, 'desc'); // [{ a:2 }, { a:1 }]\n *\n * // Multi-field\n * sort(users, { name: 'asc', age: 'desc' });\n * ```\n *\n * @param array - The array to sort.\n * @param selector - A function extracting the sort key, or a multi-field object.\n * @param direction - `'asc'` (default) or `'desc'` — only applies to single-field mode.\n * @returns A new sorted array.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function sort<T>(array: T[], selector: (item: T) => unknown, direction?: SortDirection): T[];\nexport function sort<T>(array: T[], selectors: SortSelectors<T>): T[];\nexport function sort<T>(\n array: T[],\n selectorOrSelectors: ((item: T) => unknown) | SortSelectors<T>,\n direction: SortDirection = 'asc',\n): T[] {\n if (!Array.isArray(array)) throw new TypeError('sort: first argument must be an array');\n\n if (typeof selectorOrSelectors === 'function') {\n const multiplier = direction === 'desc' ? -1 : 1;\n\n return [...array].sort((a, b) => compare(selectorOrSelectors(a), selectorOrSelectors(b)) * multiplier);\n }\n\n return [...array].sort(compareBy(selectorOrSelectors));\n}\n"],"mappings":"8DA6BA,SAAgB,EACd,EACA,EACA,EAA2B,MACtB,CACL,GAAI,CAAC,MAAM,QAAQ,CAAK,EAAG,MAAU,UAAU,uCAAuC,EAEtF,GAAI,OAAO,GAAwB,WAAY,CAC7C,IAAM,EAAa,IAAc,OAAS,GAAK,EAE/C,MAAO,CAAC,GAAG,CAAK,CAAC,CAAC,MAAM,EAAG,IAAM,EAAA,QAAQ,EAAoB,CAAC,EAAG,EAAoB,CAAC,CAAC,EAAI,CAAU,CACvG,CAEA,MAAO,CAAC,GAAG,CAAK,CAAC,CAAC,KAAK,EAAA,UAAU,CAAmB,CAAC,CACvD"}
1
+ {"version":3,"file":"sort.cjs","names":[],"sources":["../../src/array/sort.ts"],"sourcesContent":["import { compare } from './compare';\nimport { compareBy } from './compareBy';\n\nexport type SortDirection = 'asc' | 'desc';\nexport type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;\n\n/**\n * Sorts an array by a selector function (single-field) or by a multi-field\n * object of `{ key: 'asc' | 'desc' }` entries.\n *\n * @example\n * ```ts\n * // Single field\n * sort([{ a: 2 }, { a: 1 }], item => item.a); // [{ a:1 }, { a:2 }]\n * sort([{ a: 2 }, { a: 1 }], item => item.a, 'desc'); // [{ a:2 }, { a:1 }]\n *\n * // Multi-field\n * sort(users, { name: 'asc', age: 'desc' });\n * ```\n *\n * @param array - The array to sort.\n * @param selector - A function extracting the sort key, or a multi-field object.\n * @param direction - `'asc'` (default) or `'desc'` — only applies to single-field mode.\n * @returns A new sorted array.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function sort<T>(array: readonly T[], selector: (item: T) => unknown, direction?: SortDirection): T[];\nexport function sort<T>(array: readonly T[], selectors: SortSelectors<T>): T[];\nexport function sort<T>(\n array: readonly T[],\n selectorOrSelectors: ((item: T) => unknown) | SortSelectors<T>,\n direction: SortDirection = 'asc',\n): T[] {\n if (!Array.isArray(array)) throw new TypeError('sort: first argument must be an array');\n\n if (typeof selectorOrSelectors === 'function') {\n const multiplier = direction === 'desc' ? -1 : 1;\n\n return [...array].sort((a, b) => compare(selectorOrSelectors(a), selectorOrSelectors(b)) * multiplier);\n }\n\n return [...array].sort(compareBy(selectorOrSelectors));\n}\n"],"mappings":"8DA6BA,SAAgB,EACd,EACA,EACA,EAA2B,MACtB,CACL,GAAI,CAAC,MAAM,QAAQ,CAAK,EAAG,MAAU,UAAU,uCAAuC,EAEtF,GAAI,OAAO,GAAwB,WAAY,CAC7C,IAAM,EAAa,IAAc,OAAS,GAAK,EAE/C,MAAO,CAAC,GAAG,CAAK,CAAC,CAAC,MAAM,EAAG,IAAM,EAAA,QAAQ,EAAoB,CAAC,EAAG,EAAoB,CAAC,CAAC,EAAI,CAAU,CACvG,CAEA,MAAO,CAAC,GAAG,CAAK,CAAC,CAAC,KAAK,EAAA,UAAU,CAAmB,CAAC,CACvD"}
@@ -21,6 +21,6 @@ export type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;
21
21
  *
22
22
  * @throws {TypeError} If the first argument is not an array.
23
23
  */
24
- export declare function sort<T>(array: T[], selector: (item: T) => unknown, direction?: SortDirection): T[];
25
- export declare function sort<T>(array: T[], selectors: SortSelectors<T>): T[];
24
+ export declare function sort<T>(array: readonly T[], selector: (item: T) => unknown, direction?: SortDirection): T[];
25
+ export declare function sort<T>(array: readonly T[], selectors: SortSelectors<T>): T[];
26
26
  //# sourceMappingURL=sort.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/array/sort.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,CAAC,EAAE,CAAC;AACpG,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/array/sort.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,CAAC,EAAE,CAAC;AAC7G,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sort.js","names":[],"sources":["../../src/array/sort.ts"],"sourcesContent":["import { compare } from './compare';\nimport { compareBy } from './compareBy';\n\nexport type SortDirection = 'asc' | 'desc';\nexport type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;\n\n/**\n * Sorts an array by a selector function (single-field) or by a multi-field\n * object of `{ key: 'asc' | 'desc' }` entries.\n *\n * @example\n * ```ts\n * // Single field\n * sort([{ a: 2 }, { a: 1 }], item => item.a); // [{ a:1 }, { a:2 }]\n * sort([{ a: 2 }, { a: 1 }], item => item.a, 'desc'); // [{ a:2 }, { a:1 }]\n *\n * // Multi-field\n * sort(users, { name: 'asc', age: 'desc' });\n * ```\n *\n * @param array - The array to sort.\n * @param selector - A function extracting the sort key, or a multi-field object.\n * @param direction - `'asc'` (default) or `'desc'` — only applies to single-field mode.\n * @returns A new sorted array.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function sort<T>(array: T[], selector: (item: T) => unknown, direction?: SortDirection): T[];\nexport function sort<T>(array: T[], selectors: SortSelectors<T>): T[];\nexport function sort<T>(\n array: T[],\n selectorOrSelectors: ((item: T) => unknown) | SortSelectors<T>,\n direction: SortDirection = 'asc',\n): T[] {\n if (!Array.isArray(array)) throw new TypeError('sort: first argument must be an array');\n\n if (typeof selectorOrSelectors === 'function') {\n const multiplier = direction === 'desc' ? -1 : 1;\n\n return [...array].sort((a, b) => compare(selectorOrSelectors(a), selectorOrSelectors(b)) * multiplier);\n }\n\n return [...array].sort(compareBy(selectorOrSelectors));\n}\n"],"mappings":";;;AA6BA,SAAgB,EACd,GACA,GACA,IAA2B,OACtB;CACL,IAAI,CAAC,MAAM,QAAQ,CAAK,GAAG,MAAU,UAAU,uCAAuC;CAEtF,IAAI,OAAO,KAAwB,YAAY;EAC7C,IAAM,IAAa,MAAc,SAAS,KAAK;EAE/C,OAAO,CAAC,GAAG,CAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAQ,EAAoB,CAAC,GAAG,EAAoB,CAAC,CAAC,IAAI,CAAU;CACvG;CAEA,OAAO,CAAC,GAAG,CAAK,CAAC,CAAC,KAAK,EAAU,CAAmB,CAAC;AACvD"}
1
+ {"version":3,"file":"sort.js","names":[],"sources":["../../src/array/sort.ts"],"sourcesContent":["import { compare } from './compare';\nimport { compareBy } from './compareBy';\n\nexport type SortDirection = 'asc' | 'desc';\nexport type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;\n\n/**\n * Sorts an array by a selector function (single-field) or by a multi-field\n * object of `{ key: 'asc' | 'desc' }` entries.\n *\n * @example\n * ```ts\n * // Single field\n * sort([{ a: 2 }, { a: 1 }], item => item.a); // [{ a:1 }, { a:2 }]\n * sort([{ a: 2 }, { a: 1 }], item => item.a, 'desc'); // [{ a:2 }, { a:1 }]\n *\n * // Multi-field\n * sort(users, { name: 'asc', age: 'desc' });\n * ```\n *\n * @param array - The array to sort.\n * @param selector - A function extracting the sort key, or a multi-field object.\n * @param direction - `'asc'` (default) or `'desc'` — only applies to single-field mode.\n * @returns A new sorted array.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function sort<T>(array: readonly T[], selector: (item: T) => unknown, direction?: SortDirection): T[];\nexport function sort<T>(array: readonly T[], selectors: SortSelectors<T>): T[];\nexport function sort<T>(\n array: readonly T[],\n selectorOrSelectors: ((item: T) => unknown) | SortSelectors<T>,\n direction: SortDirection = 'asc',\n): T[] {\n if (!Array.isArray(array)) throw new TypeError('sort: first argument must be an array');\n\n if (typeof selectorOrSelectors === 'function') {\n const multiplier = direction === 'desc' ? -1 : 1;\n\n return [...array].sort((a, b) => compare(selectorOrSelectors(a), selectorOrSelectors(b)) * multiplier);\n }\n\n return [...array].sort(compareBy(selectorOrSelectors));\n}\n"],"mappings":";;;AA6BA,SAAgB,EACd,GACA,GACA,IAA2B,OACtB;CACL,IAAI,CAAC,MAAM,QAAQ,CAAK,GAAG,MAAU,UAAU,uCAAuC;CAEtF,IAAI,OAAO,KAAwB,YAAY;EAC7C,IAAM,IAAa,MAAc,SAAS,KAAK;EAE/C,OAAO,CAAC,GAAG,CAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAQ,EAAoB,CAAC,GAAG,EAAoB,CAAC,CAAC,IAAI,CAAU;CACvG;CAEA,OAAO,CAAC,GAAG,CAAK,CAAC,CAAC,KAAK,EAAU,CAAmB,CAAC;AACvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"take.cjs","names":[],"sources":["../../src/array/take.ts"],"sourcesContent":["/**\n * Takes the first n elements from an array.\n */\nexport function take<T>(array: T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(0, count);\n}\n"],"mappings":"AAGA,SAAgB,EAAQ,EAAY,EAAI,EAAQ,CAC9C,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,MAAM,CAAC,CAAC,EAEvC,OAAO,EAAM,MAAM,EAAG,CAAK,CAC7B"}
1
+ {"version":3,"file":"take.cjs","names":[],"sources":["../../src/array/take.ts"],"sourcesContent":["/**\n * Takes the first n elements from an array.\n */\nexport function take<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(0, count);\n}\n"],"mappings":"AAGA,SAAgB,EAAQ,EAAqB,EAAI,EAAQ,CACvD,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,MAAM,CAAC,CAAC,EAEvC,OAAO,EAAM,MAAM,EAAG,CAAK,CAC7B"}
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Takes the first n elements from an array.
3
3
  */
4
- export declare function take<T>(array: T[], n?: number): T[];
4
+ export declare function take<T>(array: readonly T[], n?: number): T[];
5
5
  //# sourceMappingURL=take.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../../src/array/take.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,SAAI,GAAG,CAAC,EAAE,CAI9C"}
1
+ {"version":3,"file":"take.d.ts","sourceRoot":"","sources":["../../src/array/take.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,SAAI,GAAG,CAAC,EAAE,CAIvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"take.js","names":[],"sources":["../../src/array/take.ts"],"sourcesContent":["/**\n * Takes the first n elements from an array.\n */\nexport function take<T>(array: T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(0, count);\n}\n"],"mappings":";AAGA,SAAgB,EAAQ,GAAY,IAAI,GAAQ;CAC9C,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,CAAC,CAAC;CAEvC,OAAO,EAAM,MAAM,GAAG,CAAK;AAC7B"}
1
+ {"version":3,"file":"take.js","names":[],"sources":["../../src/array/take.ts"],"sourcesContent":["/**\n * Takes the first n elements from an array.\n */\nexport function take<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(0, count);\n}\n"],"mappings":";AAGA,SAAgB,EAAQ,GAAqB,IAAI,GAAQ;CACvD,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,CAAC,CAAC;CAEvC,OAAO,EAAM,MAAM,GAAG,CAAK;AAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"takeLast.cjs","names":[],"sources":["../../src/array/takeLast.ts"],"sourcesContent":["/**\n * Takes the last n elements from an array.\n */\nexport function takeLast<T>(array: T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [];\n\n return array.slice(Math.max(0, array.length - count));\n}\n"],"mappings":"AAGA,SAAgB,EAAY,EAAY,EAAI,EAAQ,CAClD,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,MAAM,CAAC,CAAC,EAIvC,OAFI,IAAU,EAAU,CAAC,EAElB,EAAM,MAAM,KAAK,IAAI,EAAG,EAAM,OAAS,CAAK,CAAC,CACtD"}
1
+ {"version":3,"file":"takeLast.cjs","names":[],"sources":["../../src/array/takeLast.ts"],"sourcesContent":["/**\n * Takes the last n elements from an array.\n */\nexport function takeLast<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [];\n\n return array.slice(Math.max(0, array.length - count));\n}\n"],"mappings":"AAGA,SAAgB,EAAY,EAAqB,EAAI,EAAQ,CAC3D,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,MAAM,CAAC,CAAC,EAIvC,OAFI,IAAU,EAAU,CAAC,EAElB,EAAM,MAAM,KAAK,IAAI,EAAG,EAAM,OAAS,CAAK,CAAC,CACtD"}
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Takes the last n elements from an array.
3
3
  */
4
- export declare function takeLast<T>(array: T[], n?: number): T[];
4
+ export declare function takeLast<T>(array: readonly T[], n?: number): T[];
5
5
  //# sourceMappingURL=takeLast.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"takeLast.d.ts","sourceRoot":"","sources":["../../src/array/takeLast.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,SAAI,GAAG,CAAC,EAAE,CAMlD"}
1
+ {"version":3,"file":"takeLast.d.ts","sourceRoot":"","sources":["../../src/array/takeLast.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,SAAI,GAAG,CAAC,EAAE,CAM3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"takeLast.js","names":[],"sources":["../../src/array/takeLast.ts"],"sourcesContent":["/**\n * Takes the last n elements from an array.\n */\nexport function takeLast<T>(array: T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [];\n\n return array.slice(Math.max(0, array.length - count));\n}\n"],"mappings":";AAGA,SAAgB,EAAY,GAAY,IAAI,GAAQ;CAClD,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,CAAC,CAAC;CAIvC,OAFI,MAAU,IAAU,CAAC,IAElB,EAAM,MAAM,KAAK,IAAI,GAAG,EAAM,SAAS,CAAK,CAAC;AACtD"}
1
+ {"version":3,"file":"takeLast.js","names":[],"sources":["../../src/array/takeLast.ts"],"sourcesContent":["/**\n * Takes the last n elements from an array.\n */\nexport function takeLast<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [];\n\n return array.slice(Math.max(0, array.length - count));\n}\n"],"mappings":";AAGA,SAAgB,EAAY,GAAqB,IAAI,GAAQ;CAC3D,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,CAAC,CAAC;CAIvC,OAFI,MAAU,IAAU,CAAC,IAElB,EAAM,MAAM,KAAK,IAAI,GAAG,EAAM,SAAS,CAAK,CAAC;AACtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"toggle.cjs","names":[],"sources":["../../src/array/toggle.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already\n * exists in the array (toggle behaviour).\n *\n * @example\n * ```ts\n * toggle([1, 2, 3], 4) // [1, 2, 3, 4]\n * toggle([1, 2, 3], 2) // [1, 3]\n *\n * toggle(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine item identity.\n * @param [options] - Options for the toggle operation.\n * @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).\n * @returns A new array with the item toggled.\n */\nexport function toggle<T>(\n array: T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n"],"mappings":"AA0BA,SAAgB,EACd,EACA,EACA,EACA,EAA+C,CAAC,EAC3C,CACL,GAAM,CAAE,WAAW,UAAa,EAC1B,EAAY,EAAY,GAAU,EAAS,CAAE,IAAM,EAAS,CAAI,EAAK,GAAU,IAAO,EAEtF,EAAQ,EAAM,UAAU,CAAS,EAMvC,OAJI,IAAU,GAIP,IAAa,UAAY,CAAC,EAAM,GAAG,CAAK,EAAI,CAAC,GAAG,EAAO,CAAI,EAHzD,CAAC,GAAG,EAAM,MAAM,EAAG,CAAK,EAAG,GAAG,EAAM,MAAM,EAAQ,CAAC,CAAC,CAI/D"}
1
+ {"version":3,"file":"toggle.cjs","names":[],"sources":["../../src/array/toggle.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already\n * exists in the array (toggle behaviour).\n *\n * @example\n * ```ts\n * toggle([1, 2, 3], 4) // [1, 2, 3, 4]\n * toggle([1, 2, 3], 2) // [1, 3]\n *\n * toggle(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine item identity.\n * @param [options] - Options for the toggle operation.\n * @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).\n * @returns A new array with the item toggled.\n */\nexport function toggle<T>(\n array: readonly T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n"],"mappings":"AA0BA,SAAgB,EACd,EACA,EACA,EACA,EAA+C,CAAC,EAC3C,CACL,GAAM,CAAE,WAAW,UAAa,EAC1B,EAAY,EAAY,GAAU,EAAS,CAAE,IAAM,EAAS,CAAI,EAAK,GAAU,IAAO,EAEtF,EAAQ,EAAM,UAAU,CAAS,EAMvC,OAJI,IAAU,GAIP,IAAa,UAAY,CAAC,EAAM,GAAG,CAAK,EAAI,CAAC,GAAG,EAAO,CAAI,EAHzD,CAAC,GAAG,EAAM,MAAM,EAAG,CAAK,EAAG,GAAG,EAAM,MAAM,EAAQ,CAAC,CAAC,CAI/D"}
@@ -23,7 +23,7 @@ import type { Primitive } from '../types';
23
23
  * @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).
24
24
  * @returns A new array with the item toggled.
25
25
  */
26
- export declare function toggle<T>(array: T[], item: T, selector?: (item: T) => Primitive, options?: {
26
+ export declare function toggle<T>(array: readonly T[], item: T, selector?: (item: T) => Primitive, options?: {
27
27
  strategy?: 'prepend' | 'append';
28
28
  }): T[];
29
29
  //# sourceMappingURL=toggle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/array/toggle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,EAAE,CAAC,EACP,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,EACjC,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAO,GAChD,CAAC,EAAE,CAWL"}
1
+ {"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/array/toggle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,IAAI,EAAE,CAAC,EACP,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,EACjC,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAO,GAChD,CAAC,EAAE,CAWL"}
@@ -1 +1 @@
1
- {"version":3,"file":"toggle.js","names":[],"sources":["../../src/array/toggle.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already\n * exists in the array (toggle behaviour).\n *\n * @example\n * ```ts\n * toggle([1, 2, 3], 4) // [1, 2, 3, 4]\n * toggle([1, 2, 3], 2) // [1, 3]\n *\n * toggle(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine item identity.\n * @param [options] - Options for the toggle operation.\n * @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).\n * @returns A new array with the item toggled.\n */\nexport function toggle<T>(\n array: T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n"],"mappings":";AA0BA,SAAgB,EACd,GACA,GACA,GACA,IAA+C,CAAC,GAC3C;CACL,IAAM,EAAE,cAAW,aAAa,GAC1B,IAAY,KAAY,MAAU,EAAS,CAAE,MAAM,EAAS,CAAI,KAAK,MAAU,MAAO,GAEtF,IAAQ,EAAM,UAAU,CAAS;CAMvC,OAJI,MAAU,KAIP,MAAa,YAAY,CAAC,GAAM,GAAG,CAAK,IAAI,CAAC,GAAG,GAAO,CAAI,IAHzD,CAAC,GAAG,EAAM,MAAM,GAAG,CAAK,GAAG,GAAG,EAAM,MAAM,IAAQ,CAAC,CAAC;AAI/D"}
1
+ {"version":3,"file":"toggle.js","names":[],"sources":["../../src/array/toggle.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already\n * exists in the array (toggle behaviour).\n *\n * @example\n * ```ts\n * toggle([1, 2, 3], 4) // [1, 2, 3, 4]\n * toggle([1, 2, 3], 2) // [1, 3]\n *\n * toggle(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine item identity.\n * @param [options] - Options for the toggle operation.\n * @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).\n * @returns A new array with the item toggled.\n */\nexport function toggle<T>(\n array: readonly T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n"],"mappings":";AA0BA,SAAgB,EACd,GACA,GACA,GACA,IAA+C,CAAC,GAC3C;CACL,IAAM,EAAE,cAAW,aAAa,GAC1B,IAAY,KAAY,MAAU,EAAS,CAAE,MAAM,EAAS,CAAI,KAAK,MAAU,MAAO,GAEtF,IAAQ,EAAM,UAAU,CAAS;CAMvC,OAJI,MAAU,KAIP,MAAa,YAAY,CAAC,GAAM,GAAG,CAAK,IAAI,CAAC,GAAG,GAAO,CAAI,IAHzD,CAAC,GAAG,EAAM,MAAM,GAAG,CAAK,GAAG,GAAG,EAAM,MAAM,IAAQ,CAAC,CAAC;AAI/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"union.cjs","names":[],"sources":["../../src/array/union.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns a deduplicated union of both arrays.\n */\nexport function union<T>(source: T[], other: T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n return [...new Set([...source, ...other])];\n }\n\n return dedupeBySelector([...source, ...other], selector);\n}\n"],"mappings":"+CAMA,SAAgB,EAAS,EAAa,EAAY,EAAwC,CAKxF,OAJK,EAIE,EAAA,iBAAiB,CAAC,GAAG,EAAQ,GAAG,CAAK,EAAG,CAAQ,EAH9C,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAQ,GAAG,CAAK,CAAC,CAAC,CAI7C"}
1
+ {"version":3,"file":"union.cjs","names":[],"sources":["../../src/array/union.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns a deduplicated union of `source` and `other`.\n *\n * Allocates a new `Set` (or selector-keyed dedup structure) and a new result array.\n */\nexport function union<T>(source: readonly T[], other: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n return [...new Set([...source, ...other])];\n }\n\n return dedupeBySelector([...source, ...other], selector);\n}\n"],"mappings":"+CAQA,SAAgB,EAAS,EAAsB,EAAqB,EAAwC,CAK1G,OAJK,EAIE,EAAA,iBAAiB,CAAC,GAAG,EAAQ,GAAG,CAAK,EAAG,CAAQ,EAH9C,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAQ,GAAG,CAAK,CAAC,CAAC,CAI7C"}
@@ -1,6 +1,8 @@
1
1
  import type { Primitive } from '../types';
2
2
  /**
3
- * Returns a deduplicated union of both arrays.
3
+ * Returns a deduplicated union of `source` and `other`.
4
+ *
5
+ * Allocates a new `Set` (or selector-keyed dedup structure) and a new result array.
4
6
  */
5
- export declare function union<T>(source: T[], other: T[], selector?: (item: T) => Primitive): T[];
7
+ export declare function union<T>(source: readonly T[], other: readonly T[], selector?: (item: T) => Primitive): T[];
6
8
  //# sourceMappingURL=union.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/array/union.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,GAAG,CAAC,EAAE,CAMxF"}
1
+ {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../src/array/union.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,GAAG,CAAC,EAAE,CAM1G"}
@@ -1 +1 @@
1
- {"version":3,"file":"union.js","names":[],"sources":["../../src/array/union.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns a deduplicated union of both arrays.\n */\nexport function union<T>(source: T[], other: T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n return [...new Set([...source, ...other])];\n }\n\n return dedupeBySelector([...source, ...other], selector);\n}\n"],"mappings":";;AAMA,SAAgB,EAAS,GAAa,GAAY,GAAwC;CAKxF,OAJK,IAIE,EAAiB,CAAC,GAAG,GAAQ,GAAG,CAAK,GAAG,CAAQ,IAH9C,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,GAAQ,GAAG,CAAK,CAAC,CAAC;AAI7C"}
1
+ {"version":3,"file":"union.js","names":[],"sources":["../../src/array/union.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns a deduplicated union of `source` and `other`.\n *\n * Allocates a new `Set` (or selector-keyed dedup structure) and a new result array.\n */\nexport function union<T>(source: readonly T[], other: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n return [...new Set([...source, ...other])];\n }\n\n return dedupeBySelector([...source, ...other], selector);\n}\n"],"mappings":";;AAQA,SAAgB,EAAS,GAAsB,GAAqB,GAAwC;CAK1G,OAJK,IAIE,EAAiB,CAAC,GAAG,GAAQ,GAAG,CAAK,GAAG,CAAQ,IAH9C,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,GAAQ,GAAG,CAAK,CAAC,CAAC;AAI7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"uniq.cjs","names":[],"sources":["../../src/array/uniq.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Creates a new array with duplicate values removed.\n *\n * @example\n * ```ts\n * uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]\n * const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];\n * uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * ```\n *\n * @param array - The array to process.\n * @param [selector] - Function used to generate comparison values for each item.\n\n * @returns A new duplicate-free array.\n */\nexport function uniq<T>(array: T[], selector?: (item: T) => Primitive): T[] {\n if (array.length <= 1) {\n return [...array];\n }\n\n if (!selector) {\n return [...new Set(array)];\n }\n\n return dedupeBySelector(array, selector);\n}\n"],"mappings":"+CAkBA,SAAgB,EAAQ,EAAY,EAAwC,CAS1E,OARI,EAAM,QAAU,EACX,CAAC,GAAG,CAAK,EAGb,EAIE,EAAA,iBAAiB,EAAO,CAAQ,EAH9B,CAAC,GAAG,IAAI,IAAI,CAAK,CAAC,CAI7B"}
1
+ {"version":3,"file":"uniq.cjs","names":[],"sources":["../../src/array/uniq.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Creates a new array with duplicate values removed.\n *\n * @example\n * ```ts\n * uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]\n * const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];\n * uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * ```\n *\n * @param array - The array to process.\n * @param [selector] - Function used to generate comparison values for each item.\n\n * @returns A new duplicate-free array.\n */\nexport function uniq<T>(array: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (array.length <= 1) {\n return [...array];\n }\n\n if (!selector) {\n return [...new Set(array)];\n }\n\n return dedupeBySelector(array, selector);\n}\n"],"mappings":"+CAkBA,SAAgB,EAAQ,EAAqB,EAAwC,CASnF,OARI,EAAM,QAAU,EACX,CAAC,GAAG,CAAK,EAGb,EAIE,EAAA,iBAAiB,EAAO,CAAQ,EAH9B,CAAC,GAAG,IAAI,IAAI,CAAK,CAAC,CAI7B"}
@@ -14,5 +14,5 @@ import type { Primitive } from '../types';
14
14
 
15
15
  * @returns A new duplicate-free array.
16
16
  */
17
- export declare function uniq<T>(array: T[], selector?: (item: T) => Primitive): T[];
17
+ export declare function uniq<T>(array: readonly T[], selector?: (item: T) => Primitive): T[];
18
18
  //# sourceMappingURL=uniq.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"uniq.d.ts","sourceRoot":"","sources":["../../src/array/uniq.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,GAAG,CAAC,EAAE,CAU1E"}
1
+ {"version":3,"file":"uniq.d.ts","sourceRoot":"","sources":["../../src/array/uniq.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,GAAG,CAAC,EAAE,CAUnF"}
@@ -1 +1 @@
1
- {"version":3,"file":"uniq.js","names":[],"sources":["../../src/array/uniq.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Creates a new array with duplicate values removed.\n *\n * @example\n * ```ts\n * uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]\n * const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];\n * uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * ```\n *\n * @param array - The array to process.\n * @param [selector] - Function used to generate comparison values for each item.\n\n * @returns A new duplicate-free array.\n */\nexport function uniq<T>(array: T[], selector?: (item: T) => Primitive): T[] {\n if (array.length <= 1) {\n return [...array];\n }\n\n if (!selector) {\n return [...new Set(array)];\n }\n\n return dedupeBySelector(array, selector);\n}\n"],"mappings":";;AAkBA,SAAgB,EAAQ,GAAY,GAAwC;CAS1E,OARI,EAAM,UAAU,IACX,CAAC,GAAG,CAAK,IAGb,IAIE,EAAiB,GAAO,CAAQ,IAH9B,CAAC,GAAG,IAAI,IAAI,CAAK,CAAC;AAI7B"}
1
+ {"version":3,"file":"uniq.js","names":[],"sources":["../../src/array/uniq.ts"],"sourcesContent":["import { dedupeBySelector } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Creates a new array with duplicate values removed.\n *\n * @example\n * ```ts\n * uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]\n * const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];\n * uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * ```\n *\n * @param array - The array to process.\n * @param [selector] - Function used to generate comparison values for each item.\n\n * @returns A new duplicate-free array.\n */\nexport function uniq<T>(array: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (array.length <= 1) {\n return [...array];\n }\n\n if (!selector) {\n return [...new Set(array)];\n }\n\n return dedupeBySelector(array, selector);\n}\n"],"mappings":";;AAkBA,SAAgB,EAAQ,GAAqB,GAAwC;CASnF,OARI,EAAM,UAAU,IACX,CAAC,GAAG,CAAK,IAGb,IAIE,EAAiB,GAAO,CAAQ,IAH9B,CAAC,GAAG,IAAI,IAAI,CAAK,CAAC;AAI7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"zip.cjs","names":[],"sources":["../../src/array/zip.ts"],"sourcesContent":["/**\n * Zips multiple arrays by index.\n */\nexport function zip<T extends readonly unknown[][]>(\n ...arrays: T\n): Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }> {\n if (arrays.length === 0) return [];\n\n const length = Math.max(...arrays.map((arr) => arr.length));\n const out = new Array(length);\n\n for (let index = 0; index < length; index++) {\n out[index] = arrays.map((array) => array[index]);\n }\n\n return out as Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }>;\n}\n"],"mappings":"AAGA,SAAgB,EACd,GAAG,EACmF,CACtF,GAAI,EAAO,SAAW,EAAG,MAAO,CAAC,EAEjC,IAAM,EAAS,KAAK,IAAI,GAAG,EAAO,IAAK,GAAQ,EAAI,MAAM,CAAC,EACpD,EAAU,MAAM,CAAM,EAE5B,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAQ,IAClC,EAAI,GAAS,EAAO,IAAK,GAAU,EAAM,EAAM,EAGjD,OAAO,CACT"}
1
+ {"version":3,"file":"zip.cjs","names":[],"sources":["../../src/array/zip.ts"],"sourcesContent":["/**\n * Zips multiple arrays by index.\n */\nexport function zip<T extends readonly (readonly unknown[])[]>(\n ...arrays: T\n): Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }> {\n if (arrays.length === 0) return [];\n\n const length = Math.max(...arrays.map((arr) => arr.length));\n const out = new Array(length);\n\n for (let index = 0; index < length; index++) {\n out[index] = arrays.map((array) => array[index]);\n }\n\n return out as Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }>;\n}\n"],"mappings":"AAGA,SAAgB,EACd,GAAG,EACmF,CACtF,GAAI,EAAO,SAAW,EAAG,MAAO,CAAC,EAEjC,IAAM,EAAS,KAAK,IAAI,GAAG,EAAO,IAAK,GAAQ,EAAI,MAAM,CAAC,EACpD,EAAU,MAAM,CAAM,EAE5B,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAQ,IAClC,EAAI,GAAS,EAAO,IAAK,GAAU,EAAM,EAAM,EAGjD,OAAO,CACT"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Zips multiple arrays by index.
3
3
  */
4
- export declare function zip<T extends readonly unknown[][]>(...arrays: T): Array<{
4
+ export declare function zip<T extends readonly (readonly unknown[])[]>(...arrays: T): Array<{
5
5
  [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never;
6
6
  }>;
7
7
  //# sourceMappingURL=zip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/array/zip.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,EAChD,GAAG,MAAM,EAAE,CAAC,GACX,KAAK,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,GAAG,KAAK;CAAE,CAAC,CAWtF"}
1
+ {"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/array/zip.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,SAAS,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,EAC3D,GAAG,MAAM,EAAE,CAAC,GACX,KAAK,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,GAAG,KAAK;CAAE,CAAC,CAWtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"zip.js","names":[],"sources":["../../src/array/zip.ts"],"sourcesContent":["/**\n * Zips multiple arrays by index.\n */\nexport function zip<T extends readonly unknown[][]>(\n ...arrays: T\n): Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }> {\n if (arrays.length === 0) return [];\n\n const length = Math.max(...arrays.map((arr) => arr.length));\n const out = new Array(length);\n\n for (let index = 0; index < length; index++) {\n out[index] = arrays.map((array) => array[index]);\n }\n\n return out as Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }>;\n}\n"],"mappings":";AAGA,SAAgB,EACd,GAAG,GACmF;CACtF,IAAI,EAAO,WAAW,GAAG,OAAO,CAAC;CAEjC,IAAM,IAAS,KAAK,IAAI,GAAG,EAAO,KAAK,MAAQ,EAAI,MAAM,CAAC,GACpD,IAAU,MAAM,CAAM;CAE5B,KAAK,IAAI,IAAQ,GAAG,IAAQ,GAAQ,KAClC,EAAI,KAAS,EAAO,KAAK,MAAU,EAAM,EAAM;CAGjD,OAAO;AACT"}
1
+ {"version":3,"file":"zip.js","names":[],"sources":["../../src/array/zip.ts"],"sourcesContent":["/**\n * Zips multiple arrays by index.\n */\nexport function zip<T extends readonly (readonly unknown[])[]>(\n ...arrays: T\n): Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }> {\n if (arrays.length === 0) return [];\n\n const length = Math.max(...arrays.map((arr) => arr.length));\n const out = new Array(length);\n\n for (let index = 0; index < length; index++) {\n out[index] = arrays.map((array) => array[index]);\n }\n\n return out as Array<{ [K in keyof T]: T[K] extends readonly (infer U)[] ? U | undefined : never }>;\n}\n"],"mappings":";AAGA,SAAgB,EACd,GAAG,GACmF;CACtF,IAAI,EAAO,WAAW,GAAG,OAAO,CAAC;CAEjC,IAAM,IAAS,KAAK,IAAI,GAAG,EAAO,KAAK,MAAQ,EAAI,MAAM,CAAC,GACpD,IAAU,MAAM,CAAM;CAE5B,KAAK,IAAI,IAAQ,GAAG,IAAQ,GAAQ,KAClC,EAAI,KAAS,EAAO,KAAK,MAAU,EAAM,EAAM;CAGjD,OAAO;AACT"}
package/dist/arsenal.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t=2){if(!Array.isArray(e)&&typeof e!=`string`)throw TypeError(`chunk: argument must be an array or string`);if(!Number.isInteger(t)||t<1)throw RangeError(`chunk: size must be a positive integer`);return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,r*t+t))}function t(e,t){let n=[];for(let r=0;r<e.length;r++){let i=t(e[r],r,e);i!==void 0&&n.push(i)}return n}var n=new Set([`__proto__`,`constructor`,`prototype`]);function r(e){return typeof e==`string`&&n.has(e)}function i(e,t){let n={};for(let i of e){let e=t(i),a=e==null?`_`:String(e);r(a)||(n[a]||(n[a]=[]),n[a].push(i))}return n}function a(e,t){let n={};for(let i of e){let e=String(t(i));r(e)||(n[e]=i)}return n}function o(e,t){let n=[],r=[];for(let i=0;i<e.length;i++)t(e[i],i,e)?n.push(e[i]):r.push(e[i]);return[n,r]}var s=(e,t)=>{if(e===t)return 0;if(e===void 0)return 1;if(t===void 0)return-1;if(e===null)return t===null?0:-1;if(t===null)return 1;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);if(typeof e==`number`&&typeof t==`number`)return e===t?0:e>t?1:-1;if(e instanceof Date&&t instanceof Date){let n=e.getTime(),r=t.getTime();return n===r?0:n>r?1:-1}throw TypeError(`compare: unsupported types "${typeof e}" and "${typeof t}". Supported: number, string, Date, null, undefined.`)},c=e=>{let t=Object.entries(e);return(e,n)=>{for(let[r,i]of t){let t=e[r],a=n[r],o=i===`desc`?-1:1,c=s(t,a);if(c!==0)return c*o}return 0}};function l(e,t,n=`asc`){if(!Array.isArray(e))throw TypeError(`sort: first argument must be an array`);if(typeof t==`function`){let r=n===`desc`?-1:1;return[...e].sort((e,n)=>s(t(e),t(n))*r)}return[...e].sort(c(t))}function u(e,t){let n=new Set,r=[];for(let i of e){let e=t(i);n.has(e)||(n.add(e),r.push(i))}return r}function d(e,t){return e.length<=1?[...e]:t?u(e,t):[...new Set(e)]}function f(e){return e.ok===!0}function p(e){return e.ok===!1}async function m(e){try{return{ok:!0,value:await e()}}catch(e){return{error:e,ok:!1}}}function h(e){return e?.reason??new DOMException(`Aborted`,`AbortError`)}async function g(e,t,n={}){let{abortOnError:r=!1,limit:i=1/0,signal:a}=n;if(i<1)throw RangeError(`parallel: limit must be at least 1, got ${i}`);if(a?.aborted)throw h(a);if(e.length===0)return[];let o=Array(e.length),s=0,c=r?new AbortController:void 0,l=async()=>{for(;;){if(a?.aborted)throw h(a);if(c?.signal.aborted||s>=e.length)return;let n=s++;try{o[n]=await t(e[n],n,e)}catch(e){throw c?.abort(),e}}},u=Math.min(i,e.length),d=Array.from({length:u},()=>l());return await Promise.all(d),o}async function _(e,t){return t?t.aborted?Promise.reject(h(t)):new Promise((n,r)=>{let i=setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),t.removeEventListener(`abort`,a),r(h(t))};t.addEventListener(`abort`,a)}):new Promise(t=>setTimeout(t,e))}function v(e,t){let n=[e===void 0?void 0:AbortSignal.timeout(e),t].filter(e=>e!=null);if(n.length!==0)return n.length===1?n[0]:AbortSignal.any(n)}async function y(e,{delay:t=250,onError:n,shouldRetry:r,signal:i,timeout:a,times:o=3}={}){if(!Number.isInteger(o)||o<1)throw RangeError(`retry: times must be a positive integer, got ${o}`);for(let s=1;s<=o;s++){if(i?.aborted)throw h(i);let c=v(a,i);try{return await e(c)}catch(e){if(s===o||r&&!r(e,s-1))throw n?.(e),e;let a=typeof t==`function`?t(s-1):t;a>0&&await _(a,i)}}}var b=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},x=class extends b{};function S(e,t=300,n={leading:!1,trailing:!0}){let r=n.leading??!1,i=n.trailing??!0,a,o,s,c=!1,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},u=()=>{if(l(),c=!1,!o)return;let t=o;return o=void 0,s=e(...t),s};return Object.assign((...n)=>(o=n,r&&!c&&(c=!0,s=e(...n),o=void 0,!i)?(a=setTimeout(()=>{a=void 0,c=!1},t),s):r&&!i&&c?s:(l(),a=setTimeout(u,t),s)),{cancel:()=>{l(),o=void 0,c=!1},flush:()=>u(),pending:()=>a!==void 0})}var C=e=>{let t,n=!1,r=((...r)=>(n||=(t=e(...r),!0),t));return r.reset=()=>{t=void 0,n=!1},r};function w(...e){if(e.length===0)return e=>e;let[t,...n]=e;return(...e)=>n.reduce((e,t)=>t(e),t(...e))}function T(e,t=700,n={leading:!0,trailing:!1}){let r=n.leading??!0,i=n.trailing??!1,a,o=-1/0,s,c,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},u=e=>{a=setTimeout(p,e)},d=t=>{if(o=t,l(),!s)return;let n=s;return s=void 0,c=e(...n),c},f=e=>t-(e-o),p=()=>{let e=Date.now();s&&f(e)<=0?d(e):s?u(f(e)):l()};return Object.assign((...e)=>{let t=Date.now();o===-1/0&&!r&&(o=t),s=e;let n=f(t);return n<=0?d(t):(i&&!a&&u(n),c)},{cancel:()=>{l(),s=void 0,o=-1/0},flush:()=>{if(s)return d(Date.now())},pending:()=>s!==void 0||a!==void 0})}function E(...e){return t=>e.every(e=>e(t))}function D(...e){return t=>e.some(e=>e(t))}function O(...e){return t=>e.every(e=>!e(t))}function k(e){return t=>!e(t)}function A(e){return e!==void 0}function j(e,t){return M(e,t,new WeakMap)}function M(e,t,n){if(e===t)return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`||typeof t!=`object`)return!1;if(n.has(e))return n.get(e)===t;if(n.set(e,t),Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>M(e,t[r],n));if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[r,i]of e)if(!t.has(r)||!M(i,t.get(r),n))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;let r=[...t];for(let i of e)if(typeof i==`string`||typeof i==`number`||typeof i==`boolean`||i==null){if(!t.has(i))return!1}else if(!r.some(e=>M(i,e,n)))return!1;return!0}if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.source===t.source&&e.flags===t.flags;if(e instanceof Map||t instanceof Map||e instanceof Set||t instanceof Set)return!1;let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!Object.hasOwn(t,i)||!M(e[i],t[i],n))return!1;return!0}function N(e){return e==null}function P(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function F(e,t,n){return t!=null&&e<t?t:n!=null&&e>n?n:e}function I(e,t,n){let[r,i,a]=t===void 0?[0,e,1]:n===void 0?[e,t,1]:[e,t,n];if(!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a))throw RangeError(`range: start, stop, and step must be finite numbers`);if(a===0)throw RangeError(`range: step cannot be 0`);if(r===i)return[];let o=(i-r)/a,s=Math.max(0,Number.isInteger(o)?o:Math.ceil(o+2**-52));if(s>1e7)throw RangeError(`range: exceeds maximum allowed size of 10,000,000`);return Array.from({length:s},(e,t)=>r+t*a)}function L(e){return e.replace(/\[(\d+)\]/g,`.$1`).replace(/^\.|\.$/g,``).split(`.`).filter(Boolean)}function R(e,t){let r=e;for(let e of L(t))if(n.has(e)||typeof r!=`object`||!r||(r=r[e],r===void 0))return;return r}function z(e,t){return R(e,t)}function B(e,t,n){let r=R(e,t);return r===void 0?n:r}function V(e,t){let n=R(e,t);if(n===void 0)throw TypeError(`Path does not exist: '${t}'`);return n}function H(e,t,n){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`bigint`)return`${e}n`;if(typeof e!=`object`)return JSON.stringify(e);if(n.has(e))return`[Circular]`;if(n.add(e),e instanceof Date)return`[Date:${Number.isNaN(e.getTime())?`Invalid`:e.toISOString()}]`;if(e instanceof RegExp)return`[RegExp:${e.source}/${e.flags}]`;if(e instanceof Set)return`[Set:${[...e].map(e=>H(e,t,n)).sort().join(`,`)}]`;if(e instanceof Map)return`[Map:${[...e.entries()].map(([e,r])=>[H(e,t,n),H(r,t,n)]).sort(([e,t],[n,r])=>e===n?t.localeCompare(r):e.localeCompare(n)).map(([e,t])=>`${e}=>${t}`).join(`,`)}]`;if(Array.isArray(e))return`[${e.map(e=>H(e,t,n)).join(`,`)}]`;let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null){if(t?.onClassInstance===`throw`)throw new x(`hash: unsupported type ${e.constructor?.name??`unknown`}`);return String(e)}let i=e;return`{${Object.keys(i).filter(e=>i[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${H(i[e],t,n)}`).join(`,`)}}`}function U(e,t){return H(e,t,new Set)}function W(e,t){let n=new Set(t),i={};for(let t of Object.keys(e))r(t)||n.has(t)||(i[t]=e[t]);return i}function G(e,t){let n={};for(let i of t)r(i)||Object.hasOwn(e,i)&&(n[i]=e[i]);return n}function K(){return crypto.randomUUID()}var q=/(\p{Ll})(\p{Lu}|\p{N})|(\p{Lu}|\p{N})(\p{Lu}\p{Ll})|(\p{N})(\p{L})/gu;function J(e){return e.replace(/[.*+?^${}()|[\]\\/-]/g,`\\$&`)}function Y(e,t=` `){let n=J(t);return e.trim().replace(q,`$1$3$5${t}$2$4$6`).replace(/[^\p{L}\p{N}]+/gu,t).replace(RegExp(`^(?:${n})+|(?:${n})+$`,`g`),``)}function X(e){return Y(e,` `).replace(/[^\p{L}\p{N}]+(.)/gu,(e,t)=>t.toUpperCase()).replace(/^./,e=>e.toLowerCase())}exports.ArsenalError=b,exports.ArsenalSerializationError=x,exports.allOf=E,exports.anyOf=D,exports.attempt=m,exports.camelCase=X,exports.chunk=e,exports.clamp=F,exports.debounce=S,exports.filterMap=t,exports.getPath=z,exports.getPathOr=B,exports.groupBy=i,exports.hash=U,exports.indexBy=a,exports.isDefined=A,exports.isEqual=j,exports.isFail=p,exports.isNil=N,exports.isOk=f,exports.isPlainObject=P,exports.noneOf=O,exports.not=k,exports.omit=W,exports.once=C,exports.parallel=g,exports.partition=o,exports.pick=G,exports.pipe=w,exports.range=I,exports.requirePath=V,exports.retry=y,exports.sleep=_,exports.sort=l,exports.throttle=T,exports.uniq=d,exports.uuid=K;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t=2){if(!Array.isArray(e)&&typeof e!=`string`)throw TypeError(`chunk: argument must be an array or string`);if(!Number.isInteger(t)||t<1)throw RangeError(`chunk: size must be a positive integer`);return Array.from({length:Math.ceil(e.length/t)},(n,r)=>e.slice(r*t,r*t+t))}function t(e,t){let n=[];for(let r=0;r<e.length;r++){let i=t(e[r],r,e);i!==void 0&&n.push(i)}return n}var n=new Set([`__proto__`,`constructor`,`prototype`]);function r(e){return typeof e==`string`&&n.has(e)}function i(e,t){let n={};for(let i of e){let e=t(i),a=e==null?`_`:String(e);r(a)||(n[a]||(n[a]=[]),n[a].push(i))}return n}function a(e,t){let n={};for(let i of e){let e=String(t(i));r(e)||(n[e]=i)}return n}function o(e,t){let n=[],r=[];for(let i=0;i<e.length;i++)t(e[i],i,e)?n.push(e[i]):r.push(e[i]);return[n,r]}var s=(e,t)=>{if(e===t)return 0;if(e===void 0)return 1;if(t===void 0)return-1;if(e===null)return t===null?0:-1;if(t===null)return 1;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);if(typeof e==`number`&&typeof t==`number`)return e===t?0:e>t?1:-1;if(e instanceof Date&&t instanceof Date){let n=e.getTime(),r=t.getTime();return n===r?0:n>r?1:-1}throw TypeError(`compare: unsupported types "${typeof e}" and "${typeof t}". Supported: number, string, Date, null, undefined.`)},c=e=>{let t=Object.entries(e);return(e,n)=>{for(let[r,i]of t){let t=e[r],a=n[r],o=i===`desc`?-1:1,c=s(t,a);if(c!==0)return c*o}return 0}};function l(e,t,n=`asc`){if(!Array.isArray(e))throw TypeError(`sort: first argument must be an array`);if(typeof t==`function`){let r=n===`desc`?-1:1;return[...e].sort((e,n)=>s(t(e),t(n))*r)}return[...e].sort(c(t))}function u(e,t){let n=new Set,r=[];for(let i of e){let e=t(i);n.has(e)||(n.add(e),r.push(i))}return r}function d(e,t){return e.length<=1?[...e]:t?u(e,t):[...new Set(e)]}function f(e,t=`Aborted`){return e?.reason??new DOMException(t,`AbortError`)}function p(e,t){return t.aborted?Promise.reject(f(t)):new Promise((n,r)=>{let i=()=>r(f(t));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>n(e)).catch(e=>r(e)).finally(()=>t.removeEventListener(`abort`,i))})}function m(e){return e.ok===!0}function h(e){return e.ok===!1}async function g(e){try{return{ok:!0,value:await e()}}catch(e){return{error:e,ok:!1}}}function _(e,t=3e4){return Math.min(1e3*2**Math.max(0,Number.isNaN(e)?0:Math.floor(e)),t)}async function v(e,t,n={}){let{abortOnError:r=!1,limit:i=1/0,signal:a}=n;if(i<1)throw RangeError(`parallel: limit must be at least 1, got ${i}`);if(a?.aborted)throw f(a);if(e.length===0)return[];let o=Array(e.length),s=0,c=r?new AbortController:void 0,l=async()=>{for(;;){if(a?.aborted)throw f(a);if(c?.signal.aborted||s>=e.length)return;let n=s++;try{o[n]=await t(e[n],n,e)}catch(e){throw c?.abort(),e}}},u=Math.min(i,e.length),d=Array.from({length:u},()=>l());return await Promise.all(d),o}async function y(e,t){return t?t.aborted?Promise.reject(f(t)):new Promise((n,r)=>{let i=setTimeout(()=>{t.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),t.removeEventListener(`abort`,a),r(f(t))};t.addEventListener(`abort`,a)}):new Promise(t=>setTimeout(t,e))}function b(e,t){let n=[e===void 0?void 0:AbortSignal.timeout(e),t].filter(e=>e!=null);if(n.length!==0)return n.length===1?n[0]:AbortSignal.any(n)}async function x(e,{delay:t=250,onError:n,shouldRetry:r,signal:i,timeout:a,times:o=3}={}){if(!Number.isInteger(o)||o<1)throw RangeError(`retry: times must be a positive integer, got ${o}`);for(let s=1;s<=o;s++){if(i?.aborted)throw f(i);let c=b(a,i);try{return await e(c)}catch(e){if(s===o||r&&!r(e,s-1))throw n?.(e),e;let a=typeof t==`function`?t(s-1):t;a>0&&await y(a,i)}}}var S=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},C=class extends S{};function w(e,t=300,n={leading:!1,trailing:!0}){let r=n.leading??!1,i=n.trailing??!0,a,o,s,c=!1,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},u=()=>{if(l(),c=!1,!o)return;let t=o;return o=void 0,s=e(...t),s};return Object.assign((...n)=>(o=n,r&&!c&&(c=!0,s=e(...n),o=void 0,!i)?(a=setTimeout(()=>{a=void 0,c=!1},t),s):r&&!i&&c?s:(l(),a=setTimeout(u,t),s)),{cancel:()=>{l(),o=void 0,c=!1},flush:()=>u(),pending:()=>a!==void 0})}var T=e=>{let t,n=!1,r=((...r)=>(n||=(t=e(...r),!0),t));return r.reset=()=>{t=void 0,n=!1},r};function E(...e){if(e.length===0)return e=>e;let[t,...n]=e;return(...e)=>n.reduce((e,t)=>t(e),t(...e))}function D(e,t=700,n={leading:!0,trailing:!1}){let r=n.leading??!0,i=n.trailing??!1,a,o=-1/0,s,c,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},u=e=>{a=setTimeout(p,e)},d=t=>{if(o=t,l(),!s)return;let n=s;return s=void 0,c=e(...n),c},f=e=>t-(e-o),p=()=>{let e=Date.now();s&&f(e)<=0?d(e):s?u(f(e)):l()};return Object.assign((...e)=>{let t=Date.now();o===-1/0&&!r&&(o=t),s=e;let n=f(t);return n<=0?d(t):(i&&!a&&u(n),c)},{cancel:()=>{l(),s=void 0,o=-1/0},flush:()=>{if(s)return d(Date.now())},pending:()=>s!==void 0||a!==void 0})}function O(...e){return t=>e.every(e=>e(t))}function k(...e){return t=>e.some(e=>e(t))}function A(...e){return t=>e.every(e=>!e(t))}function j(e){return t=>!e(t)}function M(e){return e!==void 0}function N(e,t){return P(e,t,new WeakMap)}function P(e,t,n){if(e===t)return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!=`object`||typeof t!=`object`)return!1;if(n.has(e))return n.get(e)===t;if(n.set(e,t),Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>P(e,t[r],n));if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[r,i]of e)if(!t.has(r)||!P(i,t.get(r),n))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;let r=[...t];for(let i of e)if(typeof i==`string`||typeof i==`number`||typeof i==`boolean`||i==null){if(!t.has(i))return!1}else if(!r.some(e=>P(i,e,n)))return!1;return!0}if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.source===t.source&&e.flags===t.flags;if(e instanceof Map||t instanceof Map||e instanceof Set||t instanceof Set)return!1;let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r)if(!Object.hasOwn(t,i)||!P(e[i],t[i],n))return!1;return!0}function F(e){return e==null}function I(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function L(e,t){if(typeof t==`number`&&(!Number.isInteger(t)||t<1))throw RangeError(`allocate: parts must be a positive integer, got ${t}`);let n=Array.isArray(t)?t:Array(t).fill(1);if(n.length===0)throw RangeError(`Ratios array cannot be empty`);if(n.some(e=>e<0))throw RangeError(`Ratios must be non-negative`);let r=n.reduce((e,t)=>e+t,0);if(r===0)throw RangeError(`Total ratio cannot be zero`);if(typeof e==`bigint`){let t=BigInt(r),i=Array.from({length:n.length-1},(r,i)=>e*BigInt(n[i])/t);return i.push(e-i.reduce((e,t)=>e+t,0n)),i}let i=Array.from({length:n.length-1},(t,i)=>Math.floor(e*n[i]/r));return i.push(e-i.reduce((e,t)=>e+t,0)),i}function ee(e,t,n){return t!=null&&e<t?t:n!=null&&e>n?n:e}function R(e,t,n){let[r,i,a]=t===void 0?[0,e,1]:n===void 0?[e,t,1]:[e,t,n];if(!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a))throw RangeError(`range: start, stop, and step must be finite numbers`);if(a===0)throw RangeError(`range: step cannot be 0`);if(r===i)return[];let o=(i-r)/a,s=Math.max(0,Number.isInteger(o)?o:Math.ceil(o+2**-52));if(s>1e7)throw RangeError(`range: exceeds maximum allowed size of 10,000,000`);return Array.from({length:s},(e,t)=>r+t*a)}function z(e){return e.replace(/\[(\d+)\]/g,`.$1`).replace(/^\.|\.$/g,``).split(`.`).filter(Boolean)}function B(e,t){let r=e;for(let e of z(t))if(n.has(e)||typeof r!=`object`||!r||(r=r[e],r===void 0))return;return r}function V(e,t){return B(e,t)}function H(e,t,n){let r=B(e,t);return r===void 0?n:r}function U(e,t){let n=B(e,t);if(n===void 0)throw TypeError(`Path does not exist: '${t}'`);return n}function W(e,t,n){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`bigint`)return`${e}n`;if(typeof e!=`object`)return JSON.stringify(e);if(n.has(e))return`[Circular]`;if(n.add(e),e instanceof Date)return`[Date:${Number.isNaN(e.getTime())?`Invalid`:e.toISOString()}]`;if(e instanceof RegExp)return`[RegExp:${e.source}/${e.flags}]`;if(e instanceof Set)return`[Set:${[...e].map(e=>W(e,t,n)).sort().join(`,`)}]`;if(e instanceof Map)return`[Map:${[...e.entries()].map(([e,r])=>[W(e,t,n),W(r,t,n)]).sort(([e,t],[n,r])=>e===n?t.localeCompare(r):e.localeCompare(n)).map(([e,t])=>`${e}=>${t}`).join(`,`)}]`;if(Array.isArray(e))return`[${e.map(e=>W(e,t,n)).join(`,`)}]`;let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null){if(t?.onClassInstance===`throw`)throw new C(`hash: unsupported type ${e.constructor?.name??`unknown`}`);return String(e)}let i=e;return`{${Object.keys(i).filter(e=>i[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${W(i[e],t,n)}`).join(`,`)}}`}function G(e,t){return W(e,t,new Set)}function K(e,t){let n=new Set(t),i={};for(let t of Object.keys(e))r(t)||n.has(t)||(i[t]=e[t]);return i}function q(e,t){let n={};for(let i of t)r(i)||Object.hasOwn(e,i)&&(n[i]=e[i]);return n}function J(e){let t=e?.next()??crypto.getRandomValues(new Uint32Array(1))[0]/4294967296;if(!Number.isFinite(t)||t<0||t>=1)throw RangeError(`random source must return a finite number in [0, 1)`);return t}function Y(e,t){return Math.floor(J(t)*e)}function X(e,t,n){if(e>t)throw RangeError(`random: minimum value must not be greater than maximum value`);return Y(t-e+1,n)+e}var Z=/(\p{Ll})(\p{Lu}|\p{N})|(\p{Lu}|\p{N})(\p{Lu}\p{Ll})|(\p{N})(\p{L})/gu;function Q(e){return e.replace(/[.*+?^${}()|[\]\\/-]/g,`\\$&`)}function $(e,t=` `){let n=Q(t);return e.trim().replace(Z,`$1$3$5${t}$2$4$6`).replace(/[^\p{L}\p{N}]+/gu,t).replace(RegExp(`^(?:${n})+|(?:${n})+$`,`g`),``)}function te(e){return $(e,` `).replace(/[^\p{L}\p{N}]+(.)/gu,(e,t)=>t.toUpperCase()).replace(/^./,e=>e.toLowerCase())}exports.ArsenalError=S,exports.ArsenalSerializationError=C,exports.abortError=f,exports.abortable=p,exports.allOf=O,exports.allocate=L,exports.anyOf=k,exports.attempt=g,exports.backoff=_,exports.camelCase=te,exports.chunk=e,exports.clamp=ee,exports.debounce=w,exports.filterMap=t,exports.getPath=V,exports.getPathOr=H,exports.groupBy=i,exports.hash=G,exports.indexBy=a,exports.isDefined=M,exports.isEqual=N,exports.isFail=h,exports.isNil=F,exports.isOk=m,exports.isPlainObject=I,exports.noneOf=A,exports.not=j,exports.omit=K,exports.once=T,exports.parallel=v,exports.partition=o,exports.pick=q,exports.pipe=E,exports.random=X,exports.randomFloat=J,exports.range=R,exports.requirePath=U,exports.retry=x,exports.sleep=y,exports.sort=l,exports.throttle=D,exports.uniq=d;
2
2
  //# sourceMappingURL=arsenal.cjs.map