@sapphire/iterator-utilities 1.1.0-next.63f6019b.0 → 2.0.0-next.09afdaab

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 (468) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +81 -15
  3. package/dist/cjs/index.cjs +218 -1
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +33 -10
  6. package/dist/cjs/lib/all.cjs +12 -0
  7. package/dist/cjs/lib/all.cjs.map +1 -0
  8. package/dist/cjs/lib/all.d.cts +2 -0
  9. package/dist/cjs/lib/any.cjs +12 -0
  10. package/dist/cjs/lib/any.cjs.map +1 -0
  11. package/dist/cjs/lib/any.d.cts +2 -0
  12. package/dist/cjs/lib/append.cjs +1 -1
  13. package/dist/cjs/lib/append.cjs.map +1 -1
  14. package/dist/cjs/lib/at.cjs +1 -1
  15. package/dist/cjs/lib/at.cjs.map +1 -1
  16. package/dist/cjs/lib/average.cjs +1 -1
  17. package/dist/cjs/lib/average.cjs.map +1 -1
  18. package/dist/cjs/lib/chain.cjs +1 -1
  19. package/dist/cjs/lib/chain.cjs.map +1 -1
  20. package/dist/cjs/lib/chunk.cjs +1 -1
  21. package/dist/cjs/lib/chunk.cjs.map +1 -1
  22. package/dist/cjs/lib/collect.cjs +12 -0
  23. package/dist/cjs/lib/collect.cjs.map +1 -0
  24. package/dist/cjs/lib/collect.d.cts +2 -0
  25. package/dist/cjs/lib/collectInto.cjs +17 -0
  26. package/dist/cjs/lib/collectInto.cjs.map +1 -0
  27. package/dist/cjs/lib/collectInto.d.cts +29 -0
  28. package/dist/cjs/lib/compact.cjs +1 -1
  29. package/dist/cjs/lib/compact.cjs.map +1 -1
  30. package/dist/cjs/lib/compare.cjs +15 -0
  31. package/dist/cjs/lib/compare.cjs.map +1 -0
  32. package/dist/cjs/lib/compare.d.cts +32 -0
  33. package/dist/cjs/lib/compareBy.cjs +26 -0
  34. package/dist/cjs/lib/compareBy.cjs.map +1 -0
  35. package/dist/cjs/lib/compareBy.d.cts +31 -0
  36. package/dist/cjs/lib/compress.cjs +1 -1
  37. package/dist/cjs/lib/compress.cjs.map +1 -1
  38. package/dist/cjs/lib/contains.cjs +2 -3
  39. package/dist/cjs/lib/contains.cjs.map +1 -1
  40. package/dist/cjs/lib/count.cjs +1 -1
  41. package/dist/cjs/lib/count.cjs.map +1 -1
  42. package/dist/cjs/lib/cycle.cjs +1 -1
  43. package/dist/cjs/lib/cycle.cjs.map +1 -1
  44. package/dist/cjs/lib/difference.cjs +1 -1
  45. package/dist/cjs/lib/difference.cjs.map +1 -1
  46. package/dist/cjs/lib/drop.cjs +4 -8
  47. package/dist/cjs/lib/drop.cjs.map +1 -1
  48. package/dist/cjs/lib/drop.d.cts +1 -1
  49. package/dist/cjs/lib/dropLast.cjs +2 -4
  50. package/dist/cjs/lib/dropLast.cjs.map +1 -1
  51. package/dist/cjs/lib/dropLast.d.cts +1 -1
  52. package/dist/cjs/lib/dropWhile.cjs +1 -2
  53. package/dist/cjs/lib/dropWhile.cjs.map +1 -1
  54. package/dist/cjs/lib/dropWhile.d.cts +1 -1
  55. package/dist/cjs/lib/empty.cjs +1 -1
  56. package/dist/cjs/lib/empty.cjs.map +1 -1
  57. package/dist/cjs/lib/enumerate.cjs +1 -1
  58. package/dist/cjs/lib/enumerate.cjs.map +1 -1
  59. package/dist/cjs/lib/equal.cjs +15 -0
  60. package/dist/cjs/lib/equal.cjs.map +1 -0
  61. package/dist/cjs/lib/equal.d.cts +26 -0
  62. package/dist/cjs/lib/equalBy.cjs +23 -0
  63. package/dist/cjs/lib/equalBy.cjs.map +1 -0
  64. package/dist/cjs/lib/equalBy.d.cts +27 -0
  65. package/dist/cjs/lib/every.cjs +2 -3
  66. package/dist/cjs/lib/every.cjs.map +1 -1
  67. package/dist/cjs/lib/filter.cjs +2 -4
  68. package/dist/cjs/lib/filter.cjs.map +1 -1
  69. package/dist/cjs/lib/filter.d.cts +1 -1
  70. package/dist/cjs/lib/find.cjs +1 -1
  71. package/dist/cjs/lib/find.cjs.map +1 -1
  72. package/dist/cjs/lib/findIndex.cjs +1 -1
  73. package/dist/cjs/lib/findIndex.cjs.map +1 -1
  74. package/dist/cjs/lib/first.cjs +1 -1
  75. package/dist/cjs/lib/first.cjs.map +1 -1
  76. package/dist/cjs/lib/flat.cjs +1 -1
  77. package/dist/cjs/lib/flat.cjs.map +1 -1
  78. package/dist/cjs/lib/flatMap.cjs +1 -1
  79. package/dist/cjs/lib/flatMap.cjs.map +1 -1
  80. package/dist/cjs/lib/forEach.cjs +1 -1
  81. package/dist/cjs/lib/forEach.cjs.map +1 -1
  82. package/dist/cjs/lib/from.cjs +1 -1
  83. package/dist/cjs/lib/from.cjs.map +1 -1
  84. package/dist/cjs/lib/fuse.cjs +26 -0
  85. package/dist/cjs/lib/fuse.cjs.map +1 -0
  86. package/dist/cjs/lib/fuse.d.cts +47 -0
  87. package/dist/cjs/lib/greaterOrEqualThan.cjs +17 -0
  88. package/dist/cjs/lib/greaterOrEqualThan.cjs.map +1 -0
  89. package/dist/cjs/lib/greaterOrEqualThan.d.cts +32 -0
  90. package/dist/cjs/lib/greaterThan.cjs +17 -0
  91. package/dist/cjs/lib/greaterThan.cjs.map +1 -0
  92. package/dist/cjs/lib/greaterThan.d.cts +32 -0
  93. package/dist/cjs/lib/indexOf.cjs +1 -2
  94. package/dist/cjs/lib/indexOf.cjs.map +1 -1
  95. package/dist/cjs/lib/indexOf.d.cts +1 -1
  96. package/dist/cjs/lib/inspect.cjs +25 -0
  97. package/dist/cjs/lib/inspect.cjs.map +1 -0
  98. package/dist/cjs/lib/inspect.d.cts +39 -0
  99. package/dist/cjs/lib/intersect.cjs +1 -1
  100. package/dist/cjs/lib/intersect.cjs.map +1 -1
  101. package/dist/cjs/lib/intersperse.cjs +35 -0
  102. package/dist/cjs/lib/intersperse.cjs.map +1 -0
  103. package/dist/cjs/lib/intersperse.d.cts +30 -0
  104. package/dist/cjs/lib/isEmpty.cjs +1 -1
  105. package/dist/cjs/lib/isEmpty.cjs.map +1 -1
  106. package/dist/cjs/lib/isSorted.cjs +15 -0
  107. package/dist/cjs/lib/isSorted.cjs.map +1 -0
  108. package/dist/cjs/lib/isSorted.d.cts +35 -0
  109. package/dist/cjs/lib/isSortedBy.cjs +26 -0
  110. package/dist/cjs/lib/isSortedBy.cjs.map +1 -0
  111. package/dist/cjs/lib/isSortedBy.d.cts +32 -0
  112. package/dist/cjs/lib/isSortedByKey.cjs +29 -0
  113. package/dist/cjs/lib/isSortedByKey.cjs.map +1 -0
  114. package/dist/cjs/lib/isSortedByKey.d.cts +30 -0
  115. package/dist/cjs/lib/last.cjs +1 -1
  116. package/dist/cjs/lib/last.cjs.map +1 -1
  117. package/dist/cjs/lib/lessOrEqualThan.cjs +17 -0
  118. package/dist/cjs/lib/lessOrEqualThan.cjs.map +1 -0
  119. package/dist/cjs/lib/lessOrEqualThan.d.cts +32 -0
  120. package/dist/cjs/lib/lessThan.cjs +17 -0
  121. package/dist/cjs/lib/lessThan.cjs.map +1 -0
  122. package/dist/cjs/lib/lessThan.d.cts +32 -0
  123. package/dist/cjs/lib/map.cjs +1 -1
  124. package/dist/cjs/lib/map.cjs.map +1 -1
  125. package/dist/cjs/lib/max.cjs +4 -9
  126. package/dist/cjs/lib/max.cjs.map +1 -1
  127. package/dist/cjs/lib/max.d.cts +8 -3
  128. package/dist/cjs/lib/maxBy.cjs +27 -0
  129. package/dist/cjs/lib/maxBy.cjs.map +1 -0
  130. package/dist/cjs/lib/maxBy.d.cts +31 -0
  131. package/dist/cjs/lib/maxByKey.cjs +32 -0
  132. package/dist/cjs/lib/maxByKey.cjs.map +1 -0
  133. package/dist/cjs/lib/maxByKey.d.cts +32 -0
  134. package/dist/cjs/lib/min.cjs +4 -9
  135. package/dist/cjs/lib/min.cjs.map +1 -1
  136. package/dist/cjs/lib/min.d.cts +8 -3
  137. package/dist/cjs/lib/minBy.cjs +27 -0
  138. package/dist/cjs/lib/minBy.cjs.map +1 -0
  139. package/dist/cjs/lib/minBy.d.cts +31 -0
  140. package/dist/cjs/lib/minByKey.cjs +32 -0
  141. package/dist/cjs/lib/minByKey.cjs.map +1 -0
  142. package/dist/cjs/lib/minByKey.d.cts +31 -0
  143. package/dist/cjs/lib/notEqual.cjs +15 -0
  144. package/dist/cjs/lib/notEqual.cjs.map +1 -0
  145. package/dist/cjs/lib/notEqual.d.cts +26 -0
  146. package/dist/cjs/lib/nth.cjs +12 -0
  147. package/dist/cjs/lib/nth.cjs.map +1 -0
  148. package/dist/cjs/lib/nth.d.cts +2 -0
  149. package/dist/cjs/lib/partition.cjs +1 -1
  150. package/dist/cjs/lib/partition.cjs.map +1 -1
  151. package/dist/cjs/lib/peekable.cjs +2 -3
  152. package/dist/cjs/lib/peekable.cjs.map +1 -1
  153. package/dist/cjs/lib/peekable.d.cts +1 -1
  154. package/dist/cjs/lib/position.cjs +12 -0
  155. package/dist/cjs/lib/position.cjs.map +1 -0
  156. package/dist/cjs/lib/position.d.cts +2 -0
  157. package/dist/cjs/lib/prepend.cjs +1 -1
  158. package/dist/cjs/lib/prepend.cjs.map +1 -1
  159. package/dist/cjs/lib/product.cjs +1 -1
  160. package/dist/cjs/lib/product.cjs.map +1 -1
  161. package/dist/cjs/lib/range.cjs +1 -1
  162. package/dist/cjs/lib/range.cjs.map +1 -1
  163. package/dist/cjs/lib/reduce.cjs +2 -3
  164. package/dist/cjs/lib/reduce.cjs.map +1 -1
  165. package/dist/cjs/lib/repeat.cjs +1 -1
  166. package/dist/cjs/lib/repeat.cjs.map +1 -1
  167. package/dist/cjs/lib/reverse.cjs +3 -6
  168. package/dist/cjs/lib/reverse.cjs.map +1 -1
  169. package/dist/cjs/lib/shared/_assertFunction.cjs +1 -1
  170. package/dist/cjs/lib/shared/_assertFunction.cjs.map +1 -1
  171. package/dist/cjs/lib/shared/_assertNotNegative.cjs +1 -1
  172. package/dist/cjs/lib/shared/_assertNotNegative.cjs.map +1 -1
  173. package/dist/cjs/lib/shared/_assertPositive.cjs +1 -1
  174. package/dist/cjs/lib/shared/_assertPositive.cjs.map +1 -1
  175. package/dist/cjs/lib/shared/_compare.cjs +36 -0
  176. package/dist/cjs/lib/shared/_compare.cjs.map +1 -0
  177. package/dist/cjs/lib/shared/_compare.d.cts +20 -0
  178. package/dist/cjs/lib/shared/_makeIterableIterator.cjs +1 -1
  179. package/dist/cjs/lib/shared/_makeIterableIterator.cjs.map +1 -1
  180. package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs +4 -7
  181. package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs.map +1 -1
  182. package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs +4 -7
  183. package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs.map +1 -1
  184. package/dist/cjs/lib/shared/_toNumberOrThrow.cjs +1 -1
  185. package/dist/cjs/lib/shared/_toNumberOrThrow.cjs.map +1 -1
  186. package/dist/cjs/lib/shared/comparators.cjs +28 -0
  187. package/dist/cjs/lib/shared/comparators.cjs.map +1 -0
  188. package/dist/cjs/lib/shared/comparators.d.cts +34 -0
  189. package/dist/cjs/lib/skip.cjs +12 -0
  190. package/dist/cjs/lib/skip.cjs.map +1 -0
  191. package/dist/cjs/lib/skip.d.cts +2 -0
  192. package/dist/cjs/lib/skipLast.cjs +12 -0
  193. package/dist/cjs/lib/skipLast.cjs.map +1 -0
  194. package/dist/cjs/lib/skipLast.d.cts +2 -0
  195. package/dist/cjs/lib/skipWhile.cjs +12 -0
  196. package/dist/cjs/lib/skipWhile.cjs.map +1 -0
  197. package/dist/cjs/lib/skipWhile.d.cts +2 -0
  198. package/dist/cjs/lib/slice.cjs +2 -3
  199. package/dist/cjs/lib/slice.cjs.map +1 -1
  200. package/dist/cjs/lib/some.cjs +1 -1
  201. package/dist/cjs/lib/some.cjs.map +1 -1
  202. package/dist/cjs/lib/sorted.cjs +1 -1
  203. package/dist/cjs/lib/sorted.cjs.map +1 -1
  204. package/dist/cjs/lib/starMap.cjs +1 -1
  205. package/dist/cjs/lib/starMap.cjs.map +1 -1
  206. package/dist/cjs/lib/stepBy.cjs +29 -0
  207. package/dist/cjs/lib/stepBy.cjs.map +1 -0
  208. package/dist/cjs/lib/stepBy.d.cts +24 -0
  209. package/dist/cjs/lib/sum.cjs +1 -1
  210. package/dist/cjs/lib/sum.cjs.map +1 -1
  211. package/dist/cjs/lib/take.cjs +2 -3
  212. package/dist/cjs/lib/take.cjs.map +1 -1
  213. package/dist/cjs/lib/takeLast.cjs +3 -5
  214. package/dist/cjs/lib/takeLast.cjs.map +1 -1
  215. package/dist/cjs/lib/takeWhile.cjs +12 -0
  216. package/dist/cjs/lib/takeWhile.cjs.map +1 -0
  217. package/dist/cjs/lib/takeWhile.d.cts +2 -0
  218. package/dist/cjs/lib/tee.cjs +2 -3
  219. package/dist/cjs/lib/tee.cjs.map +1 -1
  220. package/dist/cjs/lib/toArray.cjs +1 -1
  221. package/dist/cjs/lib/toArray.cjs.map +1 -1
  222. package/dist/cjs/lib/toIterableIterator.cjs +1 -1
  223. package/dist/cjs/lib/toIterableIterator.cjs.map +1 -1
  224. package/dist/cjs/lib/union.cjs +1 -1
  225. package/dist/cjs/lib/union.cjs.map +1 -1
  226. package/dist/cjs/lib/union.d.cts +1 -0
  227. package/dist/cjs/lib/unique.cjs +1 -1
  228. package/dist/cjs/lib/unique.cjs.map +1 -1
  229. package/dist/cjs/lib/unzip.cjs +2 -3
  230. package/dist/cjs/lib/unzip.cjs.map +1 -1
  231. package/dist/cjs/lib/zip.cjs +2 -3
  232. package/dist/cjs/lib/zip.cjs.map +1 -1
  233. package/dist/esm/{chunk-G5GHKT7C.mjs → chunk-PAWJFY3S.mjs} +2 -2
  234. package/dist/esm/chunk-PAWJFY3S.mjs.map +1 -0
  235. package/dist/esm/index.d.mts +33 -10
  236. package/dist/esm/index.mjs +32 -1
  237. package/dist/esm/index.mjs.map +1 -1
  238. package/dist/esm/lib/all.d.mts +2 -0
  239. package/dist/esm/lib/all.mjs +4 -0
  240. package/dist/esm/lib/all.mjs.map +1 -0
  241. package/dist/esm/lib/any.d.mts +2 -0
  242. package/dist/esm/lib/any.mjs +4 -0
  243. package/dist/esm/lib/any.mjs.map +1 -0
  244. package/dist/esm/lib/append.mjs +2 -2
  245. package/dist/esm/lib/append.mjs.map +1 -1
  246. package/dist/esm/lib/at.mjs +2 -2
  247. package/dist/esm/lib/at.mjs.map +1 -1
  248. package/dist/esm/lib/average.mjs +2 -2
  249. package/dist/esm/lib/average.mjs.map +1 -1
  250. package/dist/esm/lib/chain.mjs +2 -2
  251. package/dist/esm/lib/chain.mjs.map +1 -1
  252. package/dist/esm/lib/chunk.mjs +2 -2
  253. package/dist/esm/lib/chunk.mjs.map +1 -1
  254. package/dist/esm/lib/collect.d.mts +2 -0
  255. package/dist/esm/lib/collect.mjs +4 -0
  256. package/dist/esm/lib/collect.mjs.map +1 -0
  257. package/dist/esm/lib/collectInto.d.mts +29 -0
  258. package/dist/esm/lib/collectInto.mjs +14 -0
  259. package/dist/esm/lib/collectInto.mjs.map +1 -0
  260. package/dist/esm/lib/compact.mjs +2 -2
  261. package/dist/esm/lib/compact.mjs.map +1 -1
  262. package/dist/esm/lib/compare.d.mts +32 -0
  263. package/dist/esm/lib/compare.mjs +12 -0
  264. package/dist/esm/lib/compare.mjs.map +1 -0
  265. package/dist/esm/lib/compareBy.d.mts +31 -0
  266. package/dist/esm/lib/compareBy.mjs +23 -0
  267. package/dist/esm/lib/compareBy.mjs.map +1 -0
  268. package/dist/esm/lib/compress.mjs +2 -2
  269. package/dist/esm/lib/compress.mjs.map +1 -1
  270. package/dist/esm/lib/contains.mjs +3 -4
  271. package/dist/esm/lib/contains.mjs.map +1 -1
  272. package/dist/esm/lib/count.mjs +2 -2
  273. package/dist/esm/lib/count.mjs.map +1 -1
  274. package/dist/esm/lib/cycle.mjs +2 -2
  275. package/dist/esm/lib/cycle.mjs.map +1 -1
  276. package/dist/esm/lib/difference.mjs +2 -2
  277. package/dist/esm/lib/difference.mjs.map +1 -1
  278. package/dist/esm/lib/drop.d.mts +1 -1
  279. package/dist/esm/lib/drop.mjs +6 -9
  280. package/dist/esm/lib/drop.mjs.map +1 -1
  281. package/dist/esm/lib/dropLast.d.mts +1 -1
  282. package/dist/esm/lib/dropLast.mjs +4 -5
  283. package/dist/esm/lib/dropLast.mjs.map +1 -1
  284. package/dist/esm/lib/dropWhile.d.mts +1 -1
  285. package/dist/esm/lib/dropWhile.mjs +3 -3
  286. package/dist/esm/lib/dropWhile.mjs.map +1 -1
  287. package/dist/esm/lib/empty.mjs +2 -2
  288. package/dist/esm/lib/empty.mjs.map +1 -1
  289. package/dist/esm/lib/enumerate.mjs +2 -2
  290. package/dist/esm/lib/enumerate.mjs.map +1 -1
  291. package/dist/esm/lib/equal.d.mts +26 -0
  292. package/dist/esm/lib/equal.mjs +11 -0
  293. package/dist/esm/lib/equal.mjs.map +1 -0
  294. package/dist/esm/lib/equalBy.d.mts +27 -0
  295. package/dist/esm/lib/equalBy.mjs +19 -0
  296. package/dist/esm/lib/equalBy.mjs.map +1 -0
  297. package/dist/esm/lib/every.mjs +3 -4
  298. package/dist/esm/lib/every.mjs.map +1 -1
  299. package/dist/esm/lib/filter.d.mts +1 -1
  300. package/dist/esm/lib/filter.mjs +4 -5
  301. package/dist/esm/lib/filter.mjs.map +1 -1
  302. package/dist/esm/lib/find.mjs +2 -2
  303. package/dist/esm/lib/find.mjs.map +1 -1
  304. package/dist/esm/lib/findIndex.mjs +2 -2
  305. package/dist/esm/lib/findIndex.mjs.map +1 -1
  306. package/dist/esm/lib/first.mjs +2 -2
  307. package/dist/esm/lib/first.mjs.map +1 -1
  308. package/dist/esm/lib/flat.mjs +2 -2
  309. package/dist/esm/lib/flat.mjs.map +1 -1
  310. package/dist/esm/lib/flatMap.mjs +2 -2
  311. package/dist/esm/lib/flatMap.mjs.map +1 -1
  312. package/dist/esm/lib/forEach.mjs +2 -2
  313. package/dist/esm/lib/forEach.mjs.map +1 -1
  314. package/dist/esm/lib/from.mjs +2 -2
  315. package/dist/esm/lib/from.mjs.map +1 -1
  316. package/dist/esm/lib/fuse.d.mts +47 -0
  317. package/dist/esm/lib/fuse.mjs +23 -0
  318. package/dist/esm/lib/fuse.mjs.map +1 -0
  319. package/dist/esm/lib/greaterOrEqualThan.d.mts +32 -0
  320. package/dist/esm/lib/greaterOrEqualThan.mjs +13 -0
  321. package/dist/esm/lib/greaterOrEqualThan.mjs.map +1 -0
  322. package/dist/esm/lib/greaterThan.d.mts +32 -0
  323. package/dist/esm/lib/greaterThan.mjs +13 -0
  324. package/dist/esm/lib/greaterThan.mjs.map +1 -0
  325. package/dist/esm/lib/indexOf.d.mts +1 -1
  326. package/dist/esm/lib/indexOf.mjs +3 -3
  327. package/dist/esm/lib/indexOf.mjs.map +1 -1
  328. package/dist/esm/lib/inspect.d.mts +39 -0
  329. package/dist/esm/lib/inspect.mjs +22 -0
  330. package/dist/esm/lib/inspect.mjs.map +1 -0
  331. package/dist/esm/lib/intersect.mjs +2 -2
  332. package/dist/esm/lib/intersect.mjs.map +1 -1
  333. package/dist/esm/lib/intersperse.d.mts +30 -0
  334. package/dist/esm/lib/intersperse.mjs +32 -0
  335. package/dist/esm/lib/intersperse.mjs.map +1 -0
  336. package/dist/esm/lib/isEmpty.mjs +2 -2
  337. package/dist/esm/lib/isEmpty.mjs.map +1 -1
  338. package/dist/esm/lib/isSorted.d.mts +35 -0
  339. package/dist/esm/lib/isSorted.mjs +12 -0
  340. package/dist/esm/lib/isSorted.mjs.map +1 -0
  341. package/dist/esm/lib/isSortedBy.d.mts +32 -0
  342. package/dist/esm/lib/isSortedBy.mjs +23 -0
  343. package/dist/esm/lib/isSortedBy.mjs.map +1 -0
  344. package/dist/esm/lib/isSortedByKey.d.mts +30 -0
  345. package/dist/esm/lib/isSortedByKey.mjs +26 -0
  346. package/dist/esm/lib/isSortedByKey.mjs.map +1 -0
  347. package/dist/esm/lib/last.mjs +2 -2
  348. package/dist/esm/lib/last.mjs.map +1 -1
  349. package/dist/esm/lib/lessOrEqualThan.d.mts +32 -0
  350. package/dist/esm/lib/lessOrEqualThan.mjs +13 -0
  351. package/dist/esm/lib/lessOrEqualThan.mjs.map +1 -0
  352. package/dist/esm/lib/lessThan.d.mts +32 -0
  353. package/dist/esm/lib/lessThan.mjs +13 -0
  354. package/dist/esm/lib/lessThan.mjs.map +1 -0
  355. package/dist/esm/lib/map.mjs +2 -2
  356. package/dist/esm/lib/map.mjs.map +1 -1
  357. package/dist/esm/lib/max.d.mts +8 -3
  358. package/dist/esm/lib/max.mjs +5 -10
  359. package/dist/esm/lib/max.mjs.map +1 -1
  360. package/dist/esm/lib/maxBy.d.mts +31 -0
  361. package/dist/esm/lib/maxBy.mjs +24 -0
  362. package/dist/esm/lib/maxBy.mjs.map +1 -0
  363. package/dist/esm/lib/maxByKey.d.mts +32 -0
  364. package/dist/esm/lib/maxByKey.mjs +29 -0
  365. package/dist/esm/lib/maxByKey.mjs.map +1 -0
  366. package/dist/esm/lib/min.d.mts +8 -3
  367. package/dist/esm/lib/min.mjs +5 -10
  368. package/dist/esm/lib/min.mjs.map +1 -1
  369. package/dist/esm/lib/minBy.d.mts +31 -0
  370. package/dist/esm/lib/minBy.mjs +24 -0
  371. package/dist/esm/lib/minBy.mjs.map +1 -0
  372. package/dist/esm/lib/minByKey.d.mts +31 -0
  373. package/dist/esm/lib/minByKey.mjs +29 -0
  374. package/dist/esm/lib/minByKey.mjs.map +1 -0
  375. package/dist/esm/lib/notEqual.d.mts +26 -0
  376. package/dist/esm/lib/notEqual.mjs +11 -0
  377. package/dist/esm/lib/notEqual.mjs.map +1 -0
  378. package/dist/esm/lib/nth.d.mts +2 -0
  379. package/dist/esm/lib/nth.mjs +4 -0
  380. package/dist/esm/lib/nth.mjs.map +1 -0
  381. package/dist/esm/lib/partition.mjs +2 -2
  382. package/dist/esm/lib/partition.mjs.map +1 -1
  383. package/dist/esm/lib/peekable.d.mts +1 -1
  384. package/dist/esm/lib/peekable.mjs +3 -4
  385. package/dist/esm/lib/peekable.mjs.map +1 -1
  386. package/dist/esm/lib/position.d.mts +2 -0
  387. package/dist/esm/lib/position.mjs +4 -0
  388. package/dist/esm/lib/position.mjs.map +1 -0
  389. package/dist/esm/lib/prepend.mjs +2 -2
  390. package/dist/esm/lib/prepend.mjs.map +1 -1
  391. package/dist/esm/lib/product.mjs +2 -2
  392. package/dist/esm/lib/product.mjs.map +1 -1
  393. package/dist/esm/lib/range.mjs +2 -2
  394. package/dist/esm/lib/range.mjs.map +1 -1
  395. package/dist/esm/lib/reduce.mjs +3 -4
  396. package/dist/esm/lib/reduce.mjs.map +1 -1
  397. package/dist/esm/lib/repeat.mjs +2 -2
  398. package/dist/esm/lib/repeat.mjs.map +1 -1
  399. package/dist/esm/lib/reverse.mjs +4 -7
  400. package/dist/esm/lib/reverse.mjs.map +1 -1
  401. package/dist/esm/lib/shared/_assertFunction.mjs +2 -2
  402. package/dist/esm/lib/shared/_assertFunction.mjs.map +1 -1
  403. package/dist/esm/lib/shared/_assertNotNegative.mjs +2 -2
  404. package/dist/esm/lib/shared/_assertNotNegative.mjs.map +1 -1
  405. package/dist/esm/lib/shared/_assertPositive.mjs +2 -2
  406. package/dist/esm/lib/shared/_assertPositive.mjs.map +1 -1
  407. package/dist/esm/lib/shared/_compare.d.mts +20 -0
  408. package/dist/esm/lib/shared/_compare.mjs +30 -0
  409. package/dist/esm/lib/shared/_compare.mjs.map +1 -0
  410. package/dist/esm/lib/shared/_makeIterableIterator.mjs +2 -2
  411. package/dist/esm/lib/shared/_makeIterableIterator.mjs.map +1 -1
  412. package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs +5 -8
  413. package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs.map +1 -1
  414. package/dist/esm/lib/shared/_toIntegerOrThrow.mjs +5 -8
  415. package/dist/esm/lib/shared/_toIntegerOrThrow.mjs.map +1 -1
  416. package/dist/esm/lib/shared/_toNumberOrThrow.mjs +2 -2
  417. package/dist/esm/lib/shared/_toNumberOrThrow.mjs.map +1 -1
  418. package/dist/esm/lib/shared/comparators.d.mts +34 -0
  419. package/dist/esm/lib/shared/comparators.mjs +21 -0
  420. package/dist/esm/lib/shared/comparators.mjs.map +1 -0
  421. package/dist/esm/lib/skip.d.mts +2 -0
  422. package/dist/esm/lib/skip.mjs +4 -0
  423. package/dist/esm/lib/skip.mjs.map +1 -0
  424. package/dist/esm/lib/skipLast.d.mts +2 -0
  425. package/dist/esm/lib/skipLast.mjs +4 -0
  426. package/dist/esm/lib/skipLast.mjs.map +1 -0
  427. package/dist/esm/lib/skipWhile.d.mts +2 -0
  428. package/dist/esm/lib/skipWhile.mjs +4 -0
  429. package/dist/esm/lib/skipWhile.mjs.map +1 -0
  430. package/dist/esm/lib/slice.mjs +3 -4
  431. package/dist/esm/lib/slice.mjs.map +1 -1
  432. package/dist/esm/lib/some.mjs +2 -2
  433. package/dist/esm/lib/some.mjs.map +1 -1
  434. package/dist/esm/lib/sorted.mjs +2 -2
  435. package/dist/esm/lib/sorted.mjs.map +1 -1
  436. package/dist/esm/lib/starMap.mjs +2 -2
  437. package/dist/esm/lib/starMap.mjs.map +1 -1
  438. package/dist/esm/lib/stepBy.d.mts +24 -0
  439. package/dist/esm/lib/stepBy.mjs +26 -0
  440. package/dist/esm/lib/stepBy.mjs.map +1 -0
  441. package/dist/esm/lib/sum.mjs +2 -2
  442. package/dist/esm/lib/sum.mjs.map +1 -1
  443. package/dist/esm/lib/take.mjs +3 -4
  444. package/dist/esm/lib/take.mjs.map +1 -1
  445. package/dist/esm/lib/takeLast.mjs +4 -6
  446. package/dist/esm/lib/takeLast.mjs.map +1 -1
  447. package/dist/esm/lib/takeWhile.d.mts +2 -0
  448. package/dist/esm/lib/takeWhile.mjs +4 -0
  449. package/dist/esm/lib/takeWhile.mjs.map +1 -0
  450. package/dist/esm/lib/tee.mjs +3 -4
  451. package/dist/esm/lib/tee.mjs.map +1 -1
  452. package/dist/esm/lib/toArray.mjs +2 -2
  453. package/dist/esm/lib/toArray.mjs.map +1 -1
  454. package/dist/esm/lib/toIterableIterator.mjs +2 -2
  455. package/dist/esm/lib/toIterableIterator.mjs.map +1 -1
  456. package/dist/esm/lib/union.d.mts +1 -0
  457. package/dist/esm/lib/union.mjs +2 -2
  458. package/dist/esm/lib/union.mjs.map +1 -1
  459. package/dist/esm/lib/unique.mjs +2 -2
  460. package/dist/esm/lib/unique.mjs.map +1 -1
  461. package/dist/esm/lib/unzip.mjs +3 -4
  462. package/dist/esm/lib/unzip.mjs.map +1 -1
  463. package/dist/esm/lib/zip.mjs +3 -4
  464. package/dist/esm/lib/zip.mjs.map +1 -1
  465. package/dist/iife/index.global.js +413 -95
  466. package/dist/iife/index.global.js.map +1 -1
  467. package/package.json +300 -29
  468. package/dist/esm/chunk-G5GHKT7C.mjs.map +0 -1
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var _assertFunction_cjs = require('./shared/_assertFunction.cjs');
4
+ var _compare_cjs = require('./shared/_compare.cjs');
5
+ var comparators_cjs = require('./shared/comparators.cjs');
6
+ var toIterableIterator_cjs = require('./toIterableIterator.cjs');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ function maxByKey(iterable, callbackFn, comparator = comparators_cjs.defaultCompare) {
11
+ callbackFn = _assertFunction_cjs.assertFunction(callbackFn);
12
+ const iterator = toIterableIterator_cjs.toIterableIterator(iterable);
13
+ const first = iterator.next();
14
+ if (first.done) return null;
15
+ let maximum = first.value;
16
+ let maximumKey = callbackFn(maximum, 0);
17
+ let index = 1;
18
+ for (const value of iterator) {
19
+ const key = callbackFn(value, index++);
20
+ const comparison = _compare_cjs.compareIteratorElements(maximumKey, key, comparator);
21
+ if (!_compare_cjs.orderingIsGreater(comparison)) {
22
+ maximum = value;
23
+ maximumKey = key;
24
+ }
25
+ }
26
+ return maximum;
27
+ }
28
+ __name(maxByKey, "maxByKey");
29
+
30
+ exports.maxByKey = maxByKey;
31
+ //# sourceMappingURL=maxByKey.cjs.map
32
+ //# sourceMappingURL=maxByKey.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/maxByKey.ts"],"names":["defaultCompare","assertFunction","toIterableIterator","compareIteratorElements","orderingIsGreater"],"mappings":";;;;;;;;;AAkCO,SAAS,QACf,CAAA,QAAA,EACA,UACA,EAAA,UAAA,GAA8CA,8BACzB,EAAA;AACrB,EAAA,UAAA,GAAaC,mCAAe,UAAU,CAAA;AAEtC,EAAM,MAAA,QAAA,GAAWC,0CAAmB,QAAQ,CAAA;AAC5C,EAAM,MAAA,KAAA,GAAQ,SAAS,IAAK,EAAA;AAC5B,EAAI,IAAA,KAAA,CAAM,MAAa,OAAA,IAAA;AAEvB,EAAA,IAAI,UAAU,KAAM,CAAA,KAAA;AACpB,EAAI,IAAA,UAAA,GAAa,UAAW,CAAA,OAAA,EAAS,CAAC,CAAA;AACtC,EAAA,IAAI,KAAQ,GAAA,CAAA;AACZ,EAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC7B,IAAM,MAAA,GAAA,GAAM,UAAW,CAAA,KAAA,EAAO,KAAO,EAAA,CAAA;AACrC,IAAA,MAAM,UAAa,GAAAC,oCAAA,CAAoC,UAAY,EAAA,GAAA,EAAK,UAAU,CAAA;AAElF,IAAI,IAAA,CAACC,8BAAkB,CAAA,UAAU,CAAG,EAAA;AACnC,MAAU,OAAA,GAAA,KAAA;AACV,MAAa,UAAA,GAAA,GAAA;AAAA;AACd;AAGD,EAAO,OAAA,OAAA;AACR;AAzBgB,MAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"maxByKey.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport type { max } from './max';\nimport type { maxBy } from './maxBy';\nimport { assertFunction } from './shared/_assertFunction';\nimport { compareIteratorElements, orderingIsGreater, type CompareByComparator } from './shared/_compare';\nimport { defaultCompare } from './shared/comparators';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Returns the element that gives the maximum value from the specified function.\n *\n * If several elements are equally maximum, the last element is returned. If the iterator is empty, `null` is returned.\n *\n * @seealso {@link max} for a version that uses the default comparator.\n * @seealso {@link maxBy} for a version that allows custom comparators.\n *\n * @param iterable An iterator of number values to determine the maximum value of.\n * @param callbackFn A function to execute for each element produced by the iterator, producing a key to compare with.\n * @param comparator A function to execute for each element produced by the iterator. It should return a number value.\n * @returns The element that gives the maximum value from the specified function, or `null` if the iterator is empty.\n *\n * @example\n * ```typescript\n * import { maxByKey } from '@sapphire/iterator-utilities';\n *\n * const iterable = [-3, 0, 1, 5, -10];\n * console.log(maxByKey(iterable, (value) => Math.abs(value)));\n * // Output: -10\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function maxByKey<const ElementType, const MappedType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => MappedType,\n\tcomparator: CompareByComparator<MappedType> = defaultCompare\n): ElementType | null {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tconst iterator = toIterableIterator(iterable);\n\tconst first = iterator.next();\n\tif (first.done) return null;\n\n\tlet maximum = first.value;\n\tlet maximumKey = callbackFn(maximum, 0);\n\tlet index = 1;\n\tfor (const value of iterator) {\n\t\tconst key = callbackFn(value, index++);\n\t\tconst comparison = compareIteratorElements<MappedType>(maximumKey, key, comparator);\n\n\t\tif (!orderingIsGreater(comparison)) {\n\t\t\tmaximum = value;\n\t\t\tmaximumKey = key;\n\t\t}\n\t}\n\n\treturn maximum;\n}\n"]}
@@ -0,0 +1,32 @@
1
+ import { IterableResolvable } from './from.cjs';
2
+ import { CompareByComparator } from './shared/_compare.js';
3
+
4
+ /**
5
+ * Returns the element that gives the maximum value from the specified function.
6
+ *
7
+ * If several elements are equally maximum, the last element is returned. If the iterator is empty, `null` is returned.
8
+ *
9
+ * @seealso {@link max} for a version that uses the default comparator.
10
+ * @seealso {@link maxBy} for a version that allows custom comparators.
11
+ *
12
+ * @param iterable An iterator of number values to determine the maximum value of.
13
+ * @param callbackFn A function to execute for each element produced by the iterator, producing a key to compare with.
14
+ * @param comparator A function to execute for each element produced by the iterator. It should return a number value.
15
+ * @returns The element that gives the maximum value from the specified function, or `null` if the iterator is empty.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { maxByKey } from '@sapphire/iterator-utilities';
20
+ *
21
+ * const iterable = [-3, 0, 1, 5, -10];
22
+ * console.log(maxByKey(iterable, (value) => Math.abs(value)));
23
+ * // Output: -10
24
+ * ```
25
+ *
26
+ * @remarks
27
+ *
28
+ * This function consumes the entire iterator.
29
+ */
30
+ declare function maxByKey<const ElementType, const MappedType>(iterable: IterableResolvable<ElementType>, callbackFn: (element: ElementType, index: number) => MappedType, comparator?: CompareByComparator<MappedType>): ElementType | null;
31
+
32
+ export { maxByKey };
@@ -1,20 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var map_cjs = require('./map.cjs');
4
- var _toNumberOrThrow_cjs = require('./shared/_toNumberOrThrow.cjs');
3
+ var minBy_cjs = require('./minBy.cjs');
4
+ var comparators_cjs = require('./shared/comparators.cjs');
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
8
  function min(iterable) {
9
- let min2 = null;
10
- for (const value of map_cjs.map(iterable, _toNumberOrThrow_cjs.toNumberOrThrow)) {
11
- if (min2 === null || value < min2)
12
- min2 = value;
13
- }
14
- return min2;
9
+ return minBy_cjs.minBy(iterable, comparators_cjs.defaultCompare);
15
10
  }
16
11
  __name(min, "min");
17
12
 
18
13
  exports.min = min;
19
- //# sourceMappingURL=out.js.map
14
+ //# sourceMappingURL=min.cjs.map
20
15
  //# sourceMappingURL=min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/min.ts"],"names":["min"],"mappings":";;;;AACA,SAAS,WAAW;AACpB,SAAS,uBAA8C;AAqBhD,SAAS,IAAI,UAA+D;AAClF,MAAIA,OAAqB;AACzB,aAAW,SAAS,IAAI,UAAU,eAAe,GAAG;AACnD,QAAIA,SAAQ,QAAQ,QAAQA;AAAK,MAAAA,OAAM;AAAA,EACxC;AAEA,SAAOA;AACR;AAPgB","sourcesContent":["import type { IterableResolvable } from './from';\nimport { map } from './map';\nimport { toNumberOrThrow, type NumberResolvable } from './shared/_toNumberOrThrow';\n\n/**\n * Consumes the iterable and returns the lowest number element. If the iterable is empty, or contains only non-number values, it returns `null`.\n *\n * @param iterable An iterator of number values to determine the minimum value of.\n * @returns The minimum value in the input iterator, or `null` if the iterator is empty or contains only non-number values.\n *\n * @example\n * ```typescript\n * import { min } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(min(iterable));\n * // Output: 1\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function min(iterable: IterableResolvable<NumberResolvable>): number | null {\n\tlet min: number | null = null;\n\tfor (const value of map(iterable, toNumberOrThrow)) {\n\t\tif (min === null || value < min) min = value;\n\t}\n\n\treturn min;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/min.ts"],"names":["minBy","defaultCompare"],"mappings":";;;;;;;AA8BO,SAAS,IAAuB,QAA+D,EAAA;AACrG,EAAO,OAAAA,eAAA,CAAM,UAAUC,8BAAc,CAAA;AACtC;AAFgB,MAAA,CAAA,GAAA,EAAA,KAAA,CAAA","file":"min.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { minBy } from './minBy';\nimport type { minByKey } from './minByKey';\nimport { defaultCompare } from './shared/comparators';\n\n/**\n * Consumes the iterable and returns the lowest number element. If the iterable is empty, it returns `null`.\n *\n * This function uses the default comparator (lexicographically), which means it will compare the elements as strings.\n * If this is undesirable, use {@link minBy} instead.\n *\n * @seealso {@link minBy} for a version that allows custom comparators.\n * @seealso {@link minByKey} for a version that allows custom key extractors.\n *\n * @param iterable An iterator of number values to determine the minimum value of.\n * @returns The minimum value in the input iterator, or `null` if the iterator is empty or contains only non-number values.\n *\n * @example\n * ```typescript\n * import { min } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(min(iterable));\n * // Output: 1\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function min<const ElementType>(iterable: IterableResolvable<ElementType>): ElementType | null {\n\treturn minBy(iterable, defaultCompare);\n}\n"]}
@@ -1,8 +1,13 @@
1
1
  import { IterableResolvable } from './from.cjs';
2
- import { NumberResolvable } from './shared/_toNumberOrThrow.js';
3
2
 
4
3
  /**
5
- * Consumes the iterable and returns the lowest number element. If the iterable is empty, or contains only non-number values, it returns `null`.
4
+ * Consumes the iterable and returns the lowest number element. If the iterable is empty, it returns `null`.
5
+ *
6
+ * This function uses the default comparator (lexicographically), which means it will compare the elements as strings.
7
+ * If this is undesirable, use {@link minBy} instead.
8
+ *
9
+ * @seealso {@link minBy} for a version that allows custom comparators.
10
+ * @seealso {@link minByKey} for a version that allows custom key extractors.
6
11
  *
7
12
  * @param iterable An iterator of number values to determine the minimum value of.
8
13
  * @returns The minimum value in the input iterator, or `null` if the iterator is empty or contains only non-number values.
@@ -20,6 +25,6 @@ import { NumberResolvable } from './shared/_toNumberOrThrow.js';
20
25
  *
21
26
  * This function consumes the entire iterator.
22
27
  */
23
- declare function min(iterable: IterableResolvable<NumberResolvable>): number | null;
28
+ declare function min<const ElementType>(iterable: IterableResolvable<ElementType>): ElementType | null;
24
29
 
25
30
  export { min };
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var _assertFunction_cjs = require('./shared/_assertFunction.cjs');
4
+ var _compare_cjs = require('./shared/_compare.cjs');
5
+ var toIterableIterator_cjs = require('./toIterableIterator.cjs');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ function minBy(iterable, comparator) {
10
+ comparator = _assertFunction_cjs.assertFunction(comparator);
11
+ const iterator = toIterableIterator_cjs.toIterableIterator(iterable);
12
+ const first = iterator.next();
13
+ if (first.done) return null;
14
+ let minimum = first.value;
15
+ for (const value of iterator) {
16
+ const comparison = _compare_cjs.compareIteratorElements(value, minimum, comparator);
17
+ if (!_compare_cjs.orderingIsGreater(comparison)) {
18
+ minimum = value;
19
+ }
20
+ }
21
+ return minimum;
22
+ }
23
+ __name(minBy, "minBy");
24
+
25
+ exports.minBy = minBy;
26
+ //# sourceMappingURL=minBy.cjs.map
27
+ //# sourceMappingURL=minBy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/minBy.ts"],"names":["assertFunction","toIterableIterator","compareIteratorElements","orderingIsGreater"],"mappings":";;;;;;;;AAgCO,SAAS,KAAA,CACf,UACA,UACqB,EAAA;AACrB,EAAA,UAAA,GAAaA,mCAAe,UAAU,CAAA;AAEtC,EAAM,MAAA,QAAA,GAAWC,0CAAmB,QAAQ,CAAA;AAC5C,EAAM,MAAA,KAAA,GAAQ,SAAS,IAAK,EAAA;AAC5B,EAAI,IAAA,KAAA,CAAM,MAAa,OAAA,IAAA;AAEvB,EAAA,IAAI,UAAU,KAAM,CAAA,KAAA;AACpB,EAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC7B,IAAA,MAAM,UAAa,GAAAC,oCAAA,CAAqC,KAAO,EAAA,OAAA,EAAS,UAAU,CAAA;AAElF,IAAI,IAAA,CAACC,8BAAkB,CAAA,UAAU,CAAG,EAAA;AACnC,MAAU,OAAA,GAAA,KAAA;AAAA;AACX;AAGD,EAAO,OAAA,OAAA;AACR;AApBgB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"minBy.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport type { min } from './min';\nimport type { minByKey } from './minByKey';\nimport { assertFunction } from './shared/_assertFunction';\nimport { compareIteratorElements, orderingIsGreater, type CompareByComparator } from './shared/_compare';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Returns the element that gives the minimum value with respect to the specified comparison function.\n *\n * If several elements are equally minimum, the last element is returned. If the iterator is empty, `null` is returned.\n *\n * @seealso {@link min} for a version that uses the default comparator.\n * @seealso {@link minByKey} for a version that allows custom key extractors.\n *\n * @param iterable An iterator of number values to determine the minimum value of.\n * @param callbackFn A function to execute for each element produced by the iterator. It should return a number value.\n * @returns The element that gives the minimum value from the specified function, or `null` if the iterator is empty.\n *\n * @example\n * ```typescript\n * import { ascNumber, minBy } from '@sapphire/iterator-utilities';\n *\n * const iterable = [-3, 0, 1, 5, -10];\n * console.log(minBy(iterable, ascNumber));\n * // Output: -10\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function minBy<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tcomparator: CompareByComparator<ElementType>\n): ElementType | null {\n\tcomparator = assertFunction(comparator);\n\n\tconst iterator = toIterableIterator(iterable);\n\tconst first = iterator.next();\n\tif (first.done) return null;\n\n\tlet minimum = first.value;\n\tfor (const value of iterator) {\n\t\tconst comparison = compareIteratorElements<ElementType>(value, minimum, comparator);\n\n\t\tif (!orderingIsGreater(comparison)) {\n\t\t\tminimum = value;\n\t\t}\n\t}\n\n\treturn minimum;\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { IterableResolvable } from './from.cjs';
2
+ import { CompareByComparator } from './shared/_compare.js';
3
+
4
+ /**
5
+ * Returns the element that gives the minimum value with respect to the specified comparison function.
6
+ *
7
+ * If several elements are equally minimum, the last element is returned. If the iterator is empty, `null` is returned.
8
+ *
9
+ * @seealso {@link min} for a version that uses the default comparator.
10
+ * @seealso {@link minByKey} for a version that allows custom key extractors.
11
+ *
12
+ * @param iterable An iterator of number values to determine the minimum value of.
13
+ * @param callbackFn A function to execute for each element produced by the iterator. It should return a number value.
14
+ * @returns The element that gives the minimum value from the specified function, or `null` if the iterator is empty.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { ascNumber, minBy } from '@sapphire/iterator-utilities';
19
+ *
20
+ * const iterable = [-3, 0, 1, 5, -10];
21
+ * console.log(minBy(iterable, ascNumber));
22
+ * // Output: -10
23
+ * ```
24
+ *
25
+ * @remarks
26
+ *
27
+ * This function consumes the entire iterator.
28
+ */
29
+ declare function minBy<const ElementType>(iterable: IterableResolvable<ElementType>, comparator: CompareByComparator<ElementType>): ElementType | null;
30
+
31
+ export { minBy };
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var _assertFunction_cjs = require('./shared/_assertFunction.cjs');
4
+ var _compare_cjs = require('./shared/_compare.cjs');
5
+ var comparators_cjs = require('./shared/comparators.cjs');
6
+ var toIterableIterator_cjs = require('./toIterableIterator.cjs');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ function minByKey(iterable, callbackFn, comparator = comparators_cjs.defaultCompare) {
11
+ callbackFn = _assertFunction_cjs.assertFunction(callbackFn);
12
+ const iterator = toIterableIterator_cjs.toIterableIterator(iterable);
13
+ const first = iterator.next();
14
+ if (first.done) return null;
15
+ let minimum = first.value;
16
+ let minimumKey = callbackFn(minimum, 0);
17
+ let index = 1;
18
+ for (const value of iterator) {
19
+ const key = callbackFn(value, index++);
20
+ const comparison = _compare_cjs.compareIteratorElements(minimumKey, key, comparator);
21
+ if (!_compare_cjs.orderingIsLess(comparison)) {
22
+ minimum = value;
23
+ minimumKey = key;
24
+ }
25
+ }
26
+ return minimum;
27
+ }
28
+ __name(minByKey, "minByKey");
29
+
30
+ exports.minByKey = minByKey;
31
+ //# sourceMappingURL=minByKey.cjs.map
32
+ //# sourceMappingURL=minByKey.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/minByKey.ts"],"names":["defaultCompare","assertFunction","toIterableIterator","compareIteratorElements","orderingIsLess"],"mappings":";;;;;;;;;AAiCO,SAAS,QACf,CAAA,QAAA,EACA,UACA,EAAA,UAAA,GAA8CA,8BACzB,EAAA;AACrB,EAAA,UAAA,GAAaC,mCAAe,UAAU,CAAA;AAEtC,EAAM,MAAA,QAAA,GAAWC,0CAAmB,QAAQ,CAAA;AAC5C,EAAM,MAAA,KAAA,GAAQ,SAAS,IAAK,EAAA;AAC5B,EAAI,IAAA,KAAA,CAAM,MAAa,OAAA,IAAA;AAEvB,EAAA,IAAI,UAAU,KAAM,CAAA,KAAA;AACpB,EAAI,IAAA,UAAA,GAAa,UAAW,CAAA,OAAA,EAAS,CAAC,CAAA;AACtC,EAAA,IAAI,KAAQ,GAAA,CAAA;AACZ,EAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC7B,IAAM,MAAA,GAAA,GAAM,UAAW,CAAA,KAAA,EAAO,KAAO,EAAA,CAAA;AACrC,IAAA,MAAM,UAAa,GAAAC,oCAAA,CAAoC,UAAY,EAAA,GAAA,EAAK,UAAU,CAAA;AAElF,IAAI,IAAA,CAACC,2BAAe,CAAA,UAAU,CAAG,EAAA;AAChC,MAAU,OAAA,GAAA,KAAA;AACV,MAAa,UAAA,GAAA,GAAA;AAAA;AACd;AAGD,EAAO,OAAA,OAAA;AACR;AAzBgB,MAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"minByKey.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport type { min } from './min';\nimport type { minBy } from './minBy';\nimport { assertFunction } from './shared/_assertFunction';\nimport { compareIteratorElements, orderingIsLess, type CompareByComparator } from './shared/_compare';\nimport { defaultCompare } from './shared/comparators';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Returns the element that gives the minimum value from the specified function.\n *\n * If several elements are equally minimum, the last element is returned. If the iterator is empty, `null` is returned.\n *\n * @seealso {@link min} for a version that uses the default comparator.\n * @seealso {@link minBy} for a version that allows custom comparators.\n *\n * @param iterable An iterator of number values to determine the minimum value of.\n * @param callbackFn A function to execute for each element produced by the iterator. It should return a number value.\n * @returns The element that gives the minimum value from the specified function, or `null` if the iterator is empty.\n *\n * @example\n * ```typescript\n * import { minByKey } from '@sapphire/iterator-utilities';\n *\n * const iterable = [-3, 0, 1, 5, -10];\n * console.log(minByKey(iterable, (value) => Math.abs(value)));\n * // Output: 0\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function minByKey<const ElementType, const MappedType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (element: ElementType, index: number) => MappedType,\n\tcomparator: CompareByComparator<MappedType> = defaultCompare\n): ElementType | null {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tconst iterator = toIterableIterator(iterable);\n\tconst first = iterator.next();\n\tif (first.done) return null;\n\n\tlet minimum = first.value;\n\tlet minimumKey = callbackFn(minimum, 0);\n\tlet index = 1;\n\tfor (const value of iterator) {\n\t\tconst key = callbackFn(value, index++);\n\t\tconst comparison = compareIteratorElements<MappedType>(minimumKey, key, comparator);\n\n\t\tif (!orderingIsLess(comparison)) {\n\t\t\tminimum = value;\n\t\t\tminimumKey = key;\n\t\t}\n\t}\n\n\treturn minimum;\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { IterableResolvable } from './from.cjs';
2
+ import { CompareByComparator } from './shared/_compare.js';
3
+
4
+ /**
5
+ * Returns the element that gives the minimum value from the specified function.
6
+ *
7
+ * If several elements are equally minimum, the last element is returned. If the iterator is empty, `null` is returned.
8
+ *
9
+ * @seealso {@link min} for a version that uses the default comparator.
10
+ * @seealso {@link minBy} for a version that allows custom comparators.
11
+ *
12
+ * @param iterable An iterator of number values to determine the minimum value of.
13
+ * @param callbackFn A function to execute for each element produced by the iterator. It should return a number value.
14
+ * @returns The element that gives the minimum value from the specified function, or `null` if the iterator is empty.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { minByKey } from '@sapphire/iterator-utilities';
19
+ *
20
+ * const iterable = [-3, 0, 1, 5, -10];
21
+ * console.log(minByKey(iterable, (value) => Math.abs(value)));
22
+ * // Output: 0
23
+ * ```
24
+ *
25
+ * @remarks
26
+ *
27
+ * This function consumes the entire iterator.
28
+ */
29
+ declare function minByKey<const ElementType, const MappedType>(iterable: IterableResolvable<ElementType>, callbackFn: (element: ElementType, index: number) => MappedType, comparator?: CompareByComparator<MappedType>): ElementType | null;
30
+
31
+ export { minByKey };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var equal_cjs = require('./equal.cjs');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ function notEqual(iterable, other) {
8
+ return !equal_cjs.equal(iterable, other);
9
+ }
10
+ __name(notEqual, "notEqual");
11
+
12
+ exports.ne = notEqual;
13
+ exports.notEqual = notEqual;
14
+ //# sourceMappingURL=notEqual.cjs.map
15
+ //# sourceMappingURL=notEqual.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/notEqual.ts"],"names":["equal"],"mappings":";;;;;;AAwBO,SAAS,QAAA,CAA4B,UAA2C,KAAiD,EAAA;AACvI,EAAO,OAAA,CAACA,eAAM,CAAA,QAAA,EAAU,KAAK,CAAA;AAC9B;AAFgB,MAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"notEqual.cjs","sourcesContent":["import { equal } from './equal';\nimport type { IterableResolvable } from './from';\n\n/**\n * Determines if the elements of both iterators are not equal.\n *\n * @param iterable The iterator to compare.\n * @param other The iterator to compare against.\n * @returns Whether the two iterators are not equal.\n *\n * @example\n * ```typescript\n * import { notEqual } from '@sapphire/iterator-utilities';\n *\n * console.log(notEqual([1], [1]));\n * // Output: false\n * console.log(notEqual([1], [1, 2]));\n * // Output: true\n * ```\n *\n * @remarks\n *\n * This function consumes the entire iterator.\n */\nexport function notEqual<const ElementType>(iterable: IterableResolvable<ElementType>, other: IterableResolvable<ElementType>): boolean {\n\treturn !equal(iterable, other);\n}\n\nexport { notEqual as ne };\n"]}
@@ -0,0 +1,26 @@
1
+ import { IterableResolvable } from './from.cjs';
2
+
3
+ /**
4
+ * Determines if the elements of both iterators are not equal.
5
+ *
6
+ * @param iterable The iterator to compare.
7
+ * @param other The iterator to compare against.
8
+ * @returns Whether the two iterators are not equal.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { notEqual } from '@sapphire/iterator-utilities';
13
+ *
14
+ * console.log(notEqual([1], [1]));
15
+ * // Output: false
16
+ * console.log(notEqual([1], [1, 2]));
17
+ * // Output: true
18
+ * ```
19
+ *
20
+ * @remarks
21
+ *
22
+ * This function consumes the entire iterator.
23
+ */
24
+ declare function notEqual<const ElementType>(iterable: IterableResolvable<ElementType>, other: IterableResolvable<ElementType>): boolean;
25
+
26
+ export { notEqual as ne, notEqual };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var at_cjs = require('./at.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "nth", {
8
+ enumerable: true,
9
+ get: function () { return at_cjs.at; }
10
+ });
11
+ //# sourceMappingURL=nth.cjs.map
12
+ //# sourceMappingURL=nth.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"nth.cjs","sourcesContent":[]}
@@ -0,0 +1,2 @@
1
+ export { at as nth } from './at.cjs';
2
+ import './from.cjs';
@@ -22,5 +22,5 @@ function partition(iterable, predicate) {
22
22
  __name(partition, "partition");
23
23
 
24
24
  exports.partition = partition;
25
- //# sourceMappingURL=out.js.map
25
+ //# sourceMappingURL=partition.cjs.map
26
26
  //# sourceMappingURL=partition.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/partition.ts"],"names":[],"mappings":";;;;AACA,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAsC5B,SAAS,UACf,UACA,WACiC;AACjC,cAAY,eAAe,SAAS;AAEpC,QAAM,aAA4B,CAAC;AACnC,QAAM,cAA6B,CAAC;AAEpC,MAAI,QAAQ;AACZ,aAAW,SAAS,mBAAmB,QAAQ,GAAG;AACjD,QAAI,UAAU,OAAO,OAAO,GAAG;AAC9B,iBAAW,KAAK,KAAK;AAAA,IACtB,OAAO;AACN,kBAAY,KAAK,KAAK;AAAA,IACvB;AAAA,EACD;AAEA,SAAO,CAAC,YAAY,WAAW;AAChC;AAnBgB","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Consumes the iterable and creates two arrays, one with the elements that pass the test and another with the elements that don't.\n *\n * @param iterable An iterator to partition.\n * @param predicate A function that determines which partition an element belongs to.\n * @returns An array containing two iterators. The first iterator contains elements that satisfy the predicate, and the\n * second iterator contains elements that do not.\n *\n * @example\n * ```typescript\n * import { partition } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * const [even, odd] = partition(iterable, (value) => value % 2 === 0);\n *\n * console.log(even);\n * // Output: [2, 4]\n *\n * console.log(odd);\n * // Output: [1, 3, 5]\n * ```\n *\n * @remarks\n *\n * This function collects all elements of the provided iterator into two arrays based on the predicate before returning\n * them, which may not be desirable for large iterators.\n */\nexport function partition<const ElementType, const FilteredType extends ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tpredicate: (value: ElementType, index: number) => value is FilteredType\n): [FilteredType[], Exclude<ElementType, FilteredType>[]];\nexport function partition<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tpredicate: (value: ElementType, index: number) => boolean\n): [ElementType[], ElementType[]];\n\nexport function partition<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tpredicate: (value: ElementType, index: number) => boolean\n): [ElementType[], ElementType[]] {\n\tpredicate = assertFunction(predicate);\n\n\tconst bufferLeft: ElementType[] = [];\n\tconst bufferRight: ElementType[] = [];\n\n\tlet index = 0;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tif (predicate(value, index++)) {\n\t\t\tbufferLeft.push(value);\n\t\t} else {\n\t\t\tbufferRight.push(value);\n\t\t}\n\t}\n\n\treturn [bufferLeft, bufferRight];\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/partition.ts"],"names":["assertFunction","toIterableIterator"],"mappings":";;;;;;;AAwCO,SAAS,SAAA,CACf,UACA,SACiC,EAAA;AACjC,EAAA,SAAA,GAAYA,mCAAe,SAAS,CAAA;AAEpC,EAAA,MAAM,aAA4B,EAAC;AACnC,EAAA,MAAM,cAA6B,EAAC;AAEpC,EAAA,IAAI,KAAQ,GAAA,CAAA;AACZ,EAAW,KAAA,MAAA,KAAA,IAASC,yCAAmB,CAAA,QAAQ,CAAG,EAAA;AACjD,IAAI,IAAA,SAAA,CAAU,KAAO,EAAA,KAAA,EAAO,CAAG,EAAA;AAC9B,MAAA,UAAA,CAAW,KAAK,KAAK,CAAA;AAAA,KACf,MAAA;AACN,MAAA,WAAA,CAAY,KAAK,KAAK,CAAA;AAAA;AACvB;AAGD,EAAO,OAAA,CAAC,YAAY,WAAW,CAAA;AAChC;AAnBgB,MAAA,CAAA,SAAA,EAAA,WAAA,CAAA","file":"partition.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Consumes the iterable and creates two arrays, one with the elements that pass the test and another with the elements that don't.\n *\n * @param iterable An iterator to partition.\n * @param predicate A function that determines which partition an element belongs to.\n * @returns An array containing two iterators. The first iterator contains elements that satisfy the predicate, and the\n * second iterator contains elements that do not.\n *\n * @example\n * ```typescript\n * import { partition } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * const [even, odd] = partition(iterable, (value) => value % 2 === 0);\n *\n * console.log(even);\n * // Output: [2, 4]\n *\n * console.log(odd);\n * // Output: [1, 3, 5]\n * ```\n *\n * @remarks\n *\n * This function collects all elements of the provided iterator into two arrays based on the predicate before returning\n * them, which may not be desirable for large iterators.\n */\nexport function partition<const ElementType, const FilteredType extends ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tpredicate: (value: ElementType, index: number) => value is FilteredType\n): [FilteredType[], Exclude<ElementType, FilteredType>[]];\nexport function partition<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tpredicate: (value: ElementType, index: number) => boolean\n): [ElementType[], ElementType[]];\n\nexport function partition<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\tpredicate: (value: ElementType, index: number) => boolean\n): [ElementType[], ElementType[]] {\n\tpredicate = assertFunction(predicate);\n\n\tconst bufferLeft: ElementType[] = [];\n\tconst bufferRight: ElementType[] = [];\n\n\tlet index = 0;\n\tfor (const value of toIterableIterator(iterable)) {\n\t\tif (predicate(value, index++)) {\n\t\t\tbufferLeft.push(value);\n\t\t} else {\n\t\t\tbufferRight.push(value);\n\t\t}\n\t}\n\n\treturn [bufferLeft, bufferRight];\n}\n"]}
@@ -17,8 +17,7 @@ function peekable(iterable) {
17
17
  return resolvedIterable.next();
18
18
  },
19
19
  peek() {
20
- peeked = peeked ?? resolvedIterable.next();
21
- return peeked;
20
+ return peeked ??= resolvedIterable.next();
22
21
  },
23
22
  [Symbol.iterator]() {
24
23
  return this;
@@ -28,5 +27,5 @@ function peekable(iterable) {
28
27
  __name(peekable, "peekable");
29
28
 
30
29
  exports.peekable = peekable;
31
- //# sourceMappingURL=out.js.map
30
+ //# sourceMappingURL=peekable.cjs.map
32
31
  //# sourceMappingURL=peekable.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/peekable.ts"],"names":[],"mappings":";;;;AAAA,SAAS,YAAqC;AA6BvC,SAAS,SAA4B,UAAkE;AAC7G,QAAM,mBAAmB,KAAK,QAAQ;AACtC,MAAI;AACJ,SAAO;AAAA,IACN,OAAO;AACN,UAAI,QAAQ;AACX,cAAM,QAAQ;AACd,iBAAS;AACT,eAAO;AAAA,MACR;AAEA,aAAO,iBAAiB,KAAK;AAAA,IAC9B;AAAA,IACA,OAAO;AACN,eAAS,UAAU,iBAAiB,KAAK;AACzC,aAAO;AAAA,IACR;AAAA,IACA,CAAC,OAAO,QAAQ,IAAI;AACnB,aAAO;AAAA,IACR;AAAA,EACD;AACD;AArBgB","sourcesContent":["import { from, type IterableResolvable } from './from';\n\n/**\n * Creates an iterator that allows you to peek at the next element without advancing the iterator.\n *\n * @template ElementType The type of elements in the iterable.\n * @param iterable The iterable to create a peekable iterator from.\n * @returns A new peekable iterator.\n *\n * @example\n * ```typescript\n * import { peekable } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * const peekableIterator = peekable(iterable);\n *\n * console.log(peekableIterator.next());\n * // Output: { value: 1, done: false }\n *\n * console.log(peekableIterator.peek());\n * // Output: { value: 2, done: false }\n *\n * console.log(peekableIterator.next());\n * // Output: { value: 2, done: false }\n *\n * console.log(peekableIterator.next());\n * // Output: { value: 3, done: false }\n * ```\n */\nexport function peekable<const ElementType>(iterable: IterableResolvable<ElementType>): Peekable<ElementType> {\n\tconst resolvedIterable = from(iterable);\n\tlet peeked: IteratorResult<ElementType> | undefined;\n\treturn {\n\t\tnext() {\n\t\t\tif (peeked) {\n\t\t\t\tconst value = peeked;\n\t\t\t\tpeeked = undefined;\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\treturn resolvedIterable.next();\n\t\t},\n\t\tpeek() {\n\t\t\tpeeked = peeked ?? resolvedIterable.next();\n\t\t\treturn peeked;\n\t\t},\n\t\t[Symbol.iterator]() {\n\t\t\treturn this as IterableIterator<ElementType>;\n\t\t}\n\t};\n}\n\nexport interface Peekable<T> extends IterableIterator<T> {\n\tpeek(): IteratorResult<T> | undefined;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/peekable.ts"],"names":["from"],"mappings":";;;;;;AA6BO,SAAS,SAA4B,QAAkE,EAAA;AAC7G,EAAM,MAAA,gBAAA,GAAmBA,cAAK,QAAQ,CAAA;AACtC,EAAI,IAAA,MAAA;AACJ,EAAO,OAAA;AAAA,IACN,IAAO,GAAA;AACN,MAAA,IAAI,MAAQ,EAAA;AACX,QAAA,MAAM,KAAQ,GAAA,MAAA;AACd,QAAS,MAAA,GAAA,KAAA,CAAA;AACT,QAAO,OAAA,KAAA;AAAA;AAGR,MAAA,OAAO,iBAAiB,IAAK,EAAA;AAAA,KAC9B;AAAA,IACA,IAAO,GAAA;AACN,MAAQ,OAAA,MAAA,KAAW,iBAAiB,IAAK,EAAA;AAAA,KAC1C;AAAA,IACA,CAAC,MAAO,CAAA,QAAQ,CAAI,GAAA;AACnB,MAAO,OAAA,IAAA;AAAA;AACR,GACD;AACD;AApBgB,MAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"peekable.cjs","sourcesContent":["import { from, type IterableResolvable } from './from';\n\n/**\n * Creates an iterator that allows you to peek at the next element without advancing the iterator.\n *\n * @template ElementType The type of elements in the iterable.\n * @param iterable The iterable to create a peekable iterator from.\n * @returns A new peekable iterator.\n *\n * @example\n * ```typescript\n * import { peekable } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * const peekableIterator = peekable(iterable);\n *\n * console.log(peekableIterator.next());\n * // Output: { value: 1, done: false }\n *\n * console.log(peekableIterator.peek());\n * // Output: { value: 2, done: false }\n *\n * console.log(peekableIterator.next());\n * // Output: { value: 2, done: false }\n *\n * console.log(peekableIterator.next());\n * // Output: { value: 3, done: false }\n * ```\n */\nexport function peekable<const ElementType>(iterable: IterableResolvable<ElementType>): Peekable<ElementType> {\n\tconst resolvedIterable = from(iterable);\n\tlet peeked: IteratorResult<ElementType> | undefined;\n\treturn {\n\t\tnext() {\n\t\t\tif (peeked) {\n\t\t\t\tconst value = peeked;\n\t\t\t\tpeeked = undefined;\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\treturn resolvedIterable.next();\n\t\t},\n\t\tpeek() {\n\t\t\treturn (peeked ??= resolvedIterable.next());\n\t\t},\n\t\t[Symbol.iterator]() {\n\t\t\treturn this as IterableIterator<ElementType>;\n\t\t}\n\t};\n}\n\nexport interface Peekable<T> extends IterableIterator<T> {\n\tpeek(): IteratorResult<T>;\n}\n"]}
@@ -29,7 +29,7 @@ import { IterableResolvable } from './from.cjs';
29
29
  */
30
30
  declare function peekable<const ElementType>(iterable: IterableResolvable<ElementType>): Peekable<ElementType>;
31
31
  interface Peekable<T> extends IterableIterator<T> {
32
- peek(): IteratorResult<T> | undefined;
32
+ peek(): IteratorResult<T>;
33
33
  }
34
34
 
35
35
  export { type Peekable, peekable };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var indexOf_cjs = require('./indexOf.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "position", {
8
+ enumerable: true,
9
+ get: function () { return indexOf_cjs.indexOf; }
10
+ });
11
+ //# sourceMappingURL=position.cjs.map
12
+ //# sourceMappingURL=position.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"position.cjs","sourcesContent":[]}
@@ -0,0 +1,2 @@
1
+ export { indexOf as position } from './indexOf.cjs';
2
+ import './from.cjs';
@@ -13,5 +13,5 @@ function* prepend(iterable, ...iterables) {
13
13
  __name(prepend, "prepend");
14
14
 
15
15
  exports.prepend = prepend;
16
- //# sourceMappingURL=out.js.map
16
+ //# sourceMappingURL=prepend.cjs.map
17
17
  //# sourceMappingURL=prepend.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/prepend.ts"],"names":["iterable"],"mappings":";;;;AACA,SAAS,0BAA0B;AAmB5B,UAAU,QAChB,aACG,WAC6B;AAChC,aAAWA,aAAY,WAAW;AACjC,WAAO,mBAAmBA,SAAQ;AAAA,EACnC;AAEA,SAAO,mBAAmB,QAAQ;AACnC;AATiB","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterator with the provided iterables prepended to the first iterable.\n *\n * @param iterable The iterator to prepend values to.\n * @param iterables The iterables to prepend to the iterator.\n * @returns An iterator that yields the values of the provided iterator followed by the values of the provided iterables.\n *\n * @example\n * ```typescript\n * import { prepend } from '@sapphire/iterator-utilities';\n *\n * console.log([...prepend([3, 4, 5], [1, 2])]);\n * // Output: [1, 2, 3, 4, 5]\n * ```\n *\n * @seealso {@link append} to append values to the end of an iterator.\n */\nexport function* prepend<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\t...iterables: IterableResolvable<ElementType>[]\n): IterableIterator<ElementType> {\n\tfor (const iterable of iterables) {\n\t\tyield* toIterableIterator(iterable);\n\t}\n\n\tyield* toIterableIterator(iterable);\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/prepend.ts"],"names":["iterable","toIterableIterator"],"mappings":";;;;;;AAoBO,UAAU,OAAA,CAChB,aACG,SAC6B,EAAA;AAChC,EAAA,KAAA,MAAWA,aAAY,SAAW,EAAA;AACjC,IAAA,OAAOC,0CAAmBD,SAAQ,CAAA;AAAA;AAGnC,EAAA,OAAOC,0CAAmB,QAAQ,CAAA;AACnC;AATiB,MAAA,CAAA,OAAA,EAAA,SAAA,CAAA","file":"prepend.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Creates an iterator with the provided iterables prepended to the first iterable.\n *\n * @param iterable The iterator to prepend values to.\n * @param iterables The iterables to prepend to the iterator.\n * @returns An iterator that yields the values of the provided iterator followed by the values of the provided iterables.\n *\n * @example\n * ```typescript\n * import { prepend } from '@sapphire/iterator-utilities';\n *\n * console.log([...prepend([3, 4, 5], [1, 2])]);\n * // Output: [1, 2, 3, 4, 5]\n * ```\n *\n * @seealso {@link append} to append values to the end of an iterator.\n */\nexport function* prepend<const ElementType>(\n\titerable: IterableResolvable<ElementType>,\n\t...iterables: IterableResolvable<ElementType>[]\n): IterableIterator<ElementType> {\n\tfor (const iterable of iterables) {\n\t\tyield* toIterableIterator(iterable);\n\t}\n\n\tyield* toIterableIterator(iterable);\n}\n"]}
@@ -15,5 +15,5 @@ function product(iterable) {
15
15
  __name(product, "product");
16
16
 
17
17
  exports.product = product;
18
- //# sourceMappingURL=out.js.map
18
+ //# sourceMappingURL=product.cjs.map
19
19
  //# sourceMappingURL=product.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/product.ts"],"names":[],"mappings":";;;;AACA,SAAS,WAAW;AACpB,SAAS,uBAAuB;AAqBzB,SAAS,QAAQ,UAA8C;AACrE,MAAI,SAAS;AACb,aAAW,SAAS,IAAI,UAAU,eAAe,GAAG;AACnD,cAAU;AAAA,EACX;AAEA,SAAO;AACR;AAPgB","sourcesContent":["import type { IterableResolvable } from './from';\nimport { map } from './map';\nimport { toNumberOrThrow } from './shared/_toNumberOrThrow';\n\n/**\n * Consumes the iterable and returns the product of all the elements. If the iterable is empty, it returns `1`.\n *\n * @param iterable An iterator to calculate the product of.\n * @returns The product of the elements in the input iterator.\n *\n * @example\n * ```typescript\n * import { product } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(product(iterable));\n * // Output: 120\n *\n * const iterable = [1, 2, 3, 4, 5, 0];\n * console.log(product(iterable));\n * // Output: 0\n * ```\n */\nexport function product(iterable: IterableResolvable<number>): number {\n\tlet result = 1;\n\tfor (const value of map(iterable, toNumberOrThrow)) {\n\t\tresult *= value;\n\t}\n\n\treturn result;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/product.ts"],"names":["map","toNumberOrThrow"],"mappings":";;;;;;;AAuBO,SAAS,QAAQ,QAA8C,EAAA;AACrE,EAAA,IAAI,MAAS,GAAA,CAAA;AACb,EAAA,KAAA,MAAW,KAAS,IAAAA,WAAA,CAAI,QAAU,EAAAC,oCAAe,CAAG,EAAA;AACnD,IAAU,MAAA,IAAA,KAAA;AAAA;AAGX,EAAO,OAAA,MAAA;AACR;AAPgB,MAAA,CAAA,OAAA,EAAA,SAAA,CAAA","file":"product.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { map } from './map';\nimport { toNumberOrThrow } from './shared/_toNumberOrThrow';\n\n/**\n * Consumes the iterable and returns the product of all the elements. If the iterable is empty, it returns `1`.\n *\n * @param iterable An iterator to calculate the product of.\n * @returns The product of the elements in the input iterator.\n *\n * @example\n * ```typescript\n * import { product } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(product(iterable));\n * // Output: 120\n *\n * const iterable = [1, 2, 3, 4, 5, 0];\n * console.log(product(iterable));\n * // Output: 0\n * ```\n */\nexport function product(iterable: IterableResolvable<number>): number {\n\tlet result = 1;\n\tfor (const value of map(iterable, toNumberOrThrow)) {\n\t\tresult *= value;\n\t}\n\n\treturn result;\n}\n"]}
@@ -33,5 +33,5 @@ function* range(start, end, step) {
33
33
  __name(range, "range");
34
34
 
35
35
  exports.range = range;
36
- //# sourceMappingURL=out.js.map
36
+ //# sourceMappingURL=range.cjs.map
37
37
  //# sourceMappingURL=range.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/range.ts"],"names":[],"mappings":";;;;AAAA,SAAS,uBAAuB;AAgCzB,UAAU,MAAM,OAAe,KAAa,MAAqD;AACvG,UAAQ,gBAAgB,KAAK;AAC7B,QAAM,gBAAgB,GAAG;AAEzB,MAAI,SAAS,QAAW;AACvB,WAAO,QAAQ,MAAM,IAAI;AAAA,EAC1B,OAAO;AACN,WAAO,gBAAgB,IAAI;AAG3B,QAAI,SAAS,GAAG;AACf,YAAM,IAAI,WAAW,qBAAqB;AAAA,IAC3C;AAGA,QAAI,OAAO,KAAK,QAAQ,KAAK;AAC5B,YAAM,IAAI,WAAW,mDAAmD;AAAA,IACzE,WAAW,OAAO,KAAK,QAAQ,KAAK;AACnC,YAAM,IAAI,WAAW,sDAAsD;AAAA,IAC5E;AAAA,EACD;AAEA,MAAI,QAAQ,KAAK;AAChB,aAAS,IAAI,OAAO,IAAI,KAAK,KAAK,MAAM;AACvC,YAAM;AAAA,IACP;AAAA,EACD,OAAO;AACN,aAAS,IAAI,OAAO,IAAI,KAAK,KAAK,MAAM;AACvC,YAAM;AAAA,IACP;AAAA,EACD;AACD;AA/BiB","sourcesContent":["import { toNumberOrThrow } from './shared/_toNumberOrThrow';\n\n/**\n * Creates an iterable with the numbers from `start` to `stop` (exclusive) with an optional step.\n *\n * @param start The value of the first number in the range.\n * @param end The end value of the range.\n * @param step The amount to increment the range by.\n *\n * @example\n * ```typescript\n * import { range } from '@sapphire/iterator-utilities';\n *\n * const iterable = range(0, 5);\n * console.log([...iterable]);\n * // Output: [0, 1, 2, 3, 4]\n * ```\n *\n * @example\n * ```typescript\n * const iterable = range(5, 0);\n * console.log([...iterable]);\n * // Output: [5, 4, 3, 2, 1]\n * ```\n *\n * @example\n * ```typescript\n * const iterable = range(0, 5, 2);\n * console.log([...iterable]);\n * // Output: [0, 2, 4]\n * ```\n */\nexport function* range(start: number, end: number, step?: number | undefined): IterableIterator<number> {\n\tstart = toNumberOrThrow(start);\n\tend = toNumberOrThrow(end);\n\n\tif (step === undefined) {\n\t\tstep = start < end ? 1 : -1;\n\t} else {\n\t\tstep = toNumberOrThrow(step);\n\n\t\t// Prevent infinite loops.\n\t\tif (step === 0) {\n\t\t\tthrow new RangeError('Step cannot be zero');\n\t\t}\n\n\t\t// If the step is positive, the start must be less than the end.\n\t\tif (step > 0 && start > end) {\n\t\t\tthrow new RangeError('Start must be less than end when step is positive');\n\t\t} else if (step < 0 && start < end) {\n\t\t\tthrow new RangeError('Start must be greater than end when step is negative');\n\t\t}\n\t}\n\n\tif (start < end) {\n\t\tfor (let i = start; i < end; i += step) {\n\t\t\tyield i;\n\t\t}\n\t} else {\n\t\tfor (let i = start; i > end; i += step) {\n\t\t\tyield i;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/range.ts"],"names":["toNumberOrThrow"],"mappings":";;;;;;AAgCO,UAAU,KAAA,CAAM,KAAe,EAAA,GAAA,EAAa,IAAqD,EAAA;AACvG,EAAA,KAAA,GAAQA,qCAAgB,KAAK,CAAA;AAC7B,EAAA,GAAA,GAAMA,qCAAgB,GAAG,CAAA;AAEzB,EAAA,IAAI,SAAS,KAAW,CAAA,EAAA;AACvB,IAAO,IAAA,GAAA,KAAA,GAAQ,MAAM,CAAI,GAAA,CAAA,CAAA;AAAA,GACnB,MAAA;AACN,IAAA,IAAA,GAAOA,qCAAgB,IAAI,CAAA;AAG3B,IAAA,IAAI,SAAS,CAAG,EAAA;AACf,MAAM,MAAA,IAAI,WAAW,qBAAqB,CAAA;AAAA;AAI3C,IAAI,IAAA,IAAA,GAAO,CAAK,IAAA,KAAA,GAAQ,GAAK,EAAA;AAC5B,MAAM,MAAA,IAAI,WAAW,mDAAmD,CAAA;AAAA,KAC9D,MAAA,IAAA,IAAA,GAAO,CAAK,IAAA,KAAA,GAAQ,GAAK,EAAA;AACnC,MAAM,MAAA,IAAI,WAAW,sDAAsD,CAAA;AAAA;AAC5E;AAGD,EAAA,IAAI,QAAQ,GAAK,EAAA;AAChB,IAAA,KAAA,IAAS,CAAI,GAAA,KAAA,EAAO,CAAI,GAAA,GAAA,EAAK,KAAK,IAAM,EAAA;AACvC,MAAM,MAAA,CAAA;AAAA;AACP,GACM,MAAA;AACN,IAAA,KAAA,IAAS,CAAI,GAAA,KAAA,EAAO,CAAI,GAAA,GAAA,EAAK,KAAK,IAAM,EAAA;AACvC,MAAM,MAAA,CAAA;AAAA;AACP;AAEF;AA/BiB,MAAA,CAAA,KAAA,EAAA,OAAA,CAAA","file":"range.cjs","sourcesContent":["import { toNumberOrThrow } from './shared/_toNumberOrThrow';\n\n/**\n * Creates an iterable with the numbers from `start` to `stop` (exclusive) with an optional step.\n *\n * @param start The value of the first number in the range.\n * @param end The end value of the range.\n * @param step The amount to increment the range by.\n *\n * @example\n * ```typescript\n * import { range } from '@sapphire/iterator-utilities';\n *\n * const iterable = range(0, 5);\n * console.log([...iterable]);\n * // Output: [0, 1, 2, 3, 4]\n * ```\n *\n * @example\n * ```typescript\n * const iterable = range(5, 0);\n * console.log([...iterable]);\n * // Output: [5, 4, 3, 2, 1]\n * ```\n *\n * @example\n * ```typescript\n * const iterable = range(0, 5, 2);\n * console.log([...iterable]);\n * // Output: [0, 2, 4]\n * ```\n */\nexport function* range(start: number, end: number, step?: number | undefined): IterableIterator<number> {\n\tstart = toNumberOrThrow(start);\n\tend = toNumberOrThrow(end);\n\n\tif (step === undefined) {\n\t\tstep = start < end ? 1 : -1;\n\t} else {\n\t\tstep = toNumberOrThrow(step);\n\n\t\t// Prevent infinite loops.\n\t\tif (step === 0) {\n\t\t\tthrow new RangeError('Step cannot be zero');\n\t\t}\n\n\t\t// If the step is positive, the start must be less than the end.\n\t\tif (step > 0 && start > end) {\n\t\t\tthrow new RangeError('Start must be less than end when step is positive');\n\t\t} else if (step < 0 && start < end) {\n\t\t\tthrow new RangeError('Start must be greater than end when step is negative');\n\t\t}\n\t}\n\n\tif (start < end) {\n\t\tfor (let i = start; i < end; i += step) {\n\t\t\tyield i;\n\t\t}\n\t} else {\n\t\tfor (let i = start; i > end; i += step) {\n\t\t\tyield i;\n\t\t}\n\t}\n}\n"]}
@@ -12,8 +12,7 @@ function reduce(iterable, callbackFn, initialValue) {
12
12
  const resolvedIterable = toIterableIterator_cjs.toIterableIterator(iterable);
13
13
  if (arguments.length < 3) {
14
14
  const firstValue = resolvedIterable.next();
15
- if (firstValue.done)
16
- throw new TypeError("Reduce of empty iterator with no initial value");
15
+ if (firstValue.done) throw new TypeError("Reduce of empty iterator with no initial value");
17
16
  index = 1;
18
17
  accumulator = firstValue.value;
19
18
  } else {
@@ -28,5 +27,5 @@ function reduce(iterable, callbackFn, initialValue) {
28
27
  __name(reduce, "reduce");
29
28
 
30
29
  exports.reduce = reduce;
31
- //# sourceMappingURL=out.js.map
30
+ //# sourceMappingURL=reduce.cjs.map
32
31
  //# sourceMappingURL=reduce.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/reduce.ts"],"names":[],"mappings":";;;;AACA,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AA8B5B,SAAS,OACf,UACA,YACA,cACa;AACb,eAAa,eAAe,UAAU;AAEtC,MAAI;AACJ,MAAI;AACJ,QAAM,mBAAmB,mBAAmB,QAAQ;AACpD,MAAI,UAAU,SAAS,GAAG;AACzB,UAAM,aAAa,iBAAiB,KAAK;AACzC,QAAI,WAAW;AAAM,YAAM,IAAI,UAAU,gDAAgD;AAEzF,YAAQ;AACR,kBAAc,WAAW;AAAA,EAC1B,OAAO;AACN,YAAQ;AACR,kBAAc;AAAA,EACf;AAEA,aAAW,SAAS,kBAAkB;AACrC,kBAAc,WAAW,aAAa,OAAO,OAAO;AAAA,EACrD;AAEA,SAAO;AACR;AA1BgB","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Consumes the iterable and reduces it to the reducer function's result.\n *\n * @param iterable An iterator to reduce.\n * @param callbackFn A function to execute for each element produced by the iterator. Its return value becomes the value\n * of the `accumulator` parameter on the next invocation of `callbackFn`. For the last invocation, the return value\n * becomes the return value of `reduce()`.\n * @param initialValue A value to which `accumulator` is initialized the first time the callback is called. If\n * `initialValue` is specified, `callbackFn` starts executing with the first element as `currentValue`. If\n * `initialValue` is not specified, `accumulator` is initialized to the first element, and `callbackFn` starts executing\n * with the second element as `currentValue`. In this case, if the iterator is empty (so that there's no first value to\n * return as `accumulator`), an error is thrown.\n * @returns\n *\n * @example\n * ```typescript\n * import { reduce } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(reduce(iterable, (accumulator, currentValue) => accumulator + currentValue));\n * // Output: 15\n * ```\n *\n * @remarks\n *\n * If `initialValue` is not provided, the first element of the iterator is used as the initial value of `accumulator`,\n * consuming the first element.\n */\nexport function reduce<const ElementType, const MappedType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (accumulator: MappedType, currentValue: ElementType, currentIndex: number) => MappedType,\n\tinitialValue?: MappedType\n): MappedType {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index: number;\n\tlet accumulator: MappedType;\n\tconst resolvedIterable = toIterableIterator(iterable);\n\tif (arguments.length < 3) {\n\t\tconst firstValue = resolvedIterable.next();\n\t\tif (firstValue.done) throw new TypeError('Reduce of empty iterator with no initial value');\n\n\t\tindex = 1;\n\t\taccumulator = firstValue.value! as MappedType;\n\t} else {\n\t\tindex = 0;\n\t\taccumulator = initialValue!;\n\t}\n\n\tfor (const value of resolvedIterable) {\n\t\taccumulator = callbackFn(accumulator, value, index++);\n\t}\n\n\treturn accumulator;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/reduce.ts"],"names":["assertFunction","toIterableIterator"],"mappings":";;;;;;;AAgCO,SAAS,MAAA,CACf,QACA,EAAA,UAAA,EACA,YACa,EAAA;AACb,EAAA,UAAA,GAAaA,mCAAe,UAAU,CAAA;AAEtC,EAAI,IAAA,KAAA;AACJ,EAAI,IAAA,WAAA;AACJ,EAAM,MAAA,gBAAA,GAAmBC,0CAAmB,QAAQ,CAAA;AACpD,EAAI,IAAA,SAAA,CAAU,SAAS,CAAG,EAAA;AACzB,IAAM,MAAA,UAAA,GAAa,iBAAiB,IAAK,EAAA;AACzC,IAAA,IAAI,UAAW,CAAA,IAAA,EAAY,MAAA,IAAI,UAAU,gDAAgD,CAAA;AAEzF,IAAQ,KAAA,GAAA,CAAA;AACR,IAAA,WAAA,GAAc,UAAW,CAAA,KAAA;AAAA,GACnB,MAAA;AACN,IAAQ,KAAA,GAAA,CAAA;AACR,IAAc,WAAA,GAAA,YAAA;AAAA;AAGf,EAAA,KAAA,MAAW,SAAS,gBAAkB,EAAA;AACrC,IAAc,WAAA,GAAA,UAAA,CAAW,WAAa,EAAA,KAAA,EAAO,KAAO,EAAA,CAAA;AAAA;AAGrD,EAAO,OAAA,WAAA;AACR;AA1BgB,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA","file":"reduce.cjs","sourcesContent":["import type { IterableResolvable } from './from';\nimport { assertFunction } from './shared/_assertFunction';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Consumes the iterable and reduces it to the reducer function's result.\n *\n * @param iterable An iterator to reduce.\n * @param callbackFn A function to execute for each element produced by the iterator. Its return value becomes the value\n * of the `accumulator` parameter on the next invocation of `callbackFn`. For the last invocation, the return value\n * becomes the return value of `reduce()`.\n * @param initialValue A value to which `accumulator` is initialized the first time the callback is called. If\n * `initialValue` is specified, `callbackFn` starts executing with the first element as `currentValue`. If\n * `initialValue` is not specified, `accumulator` is initialized to the first element, and `callbackFn` starts executing\n * with the second element as `currentValue`. In this case, if the iterator is empty (so that there's no first value to\n * return as `accumulator`), an error is thrown.\n * @returns\n *\n * @example\n * ```typescript\n * import { reduce } from '@sapphire/iterator-utilities';\n *\n * const iterable = [1, 2, 3, 4, 5];\n * console.log(reduce(iterable, (accumulator, currentValue) => accumulator + currentValue));\n * // Output: 15\n * ```\n *\n * @remarks\n *\n * If `initialValue` is not provided, the first element of the iterator is used as the initial value of `accumulator`,\n * consuming the first element.\n */\nexport function reduce<const ElementType, const MappedType>(\n\titerable: IterableResolvable<ElementType>,\n\tcallbackFn: (accumulator: MappedType, currentValue: ElementType, currentIndex: number) => MappedType,\n\tinitialValue?: MappedType\n): MappedType {\n\tcallbackFn = assertFunction(callbackFn);\n\n\tlet index: number;\n\tlet accumulator: MappedType;\n\tconst resolvedIterable = toIterableIterator(iterable);\n\tif (arguments.length < 3) {\n\t\tconst firstValue = resolvedIterable.next();\n\t\tif (firstValue.done) throw new TypeError('Reduce of empty iterator with no initial value');\n\n\t\tindex = 1;\n\t\taccumulator = firstValue.value! as MappedType;\n\t} else {\n\t\tindex = 0;\n\t\taccumulator = initialValue!;\n\t}\n\n\tfor (const value of resolvedIterable) {\n\t\taccumulator = callbackFn(accumulator, value, index++);\n\t}\n\n\treturn accumulator;\n}\n"]}
@@ -16,5 +16,5 @@ function repeat(value, count) {
16
16
  __name(repeat, "repeat");
17
17
 
18
18
  exports.repeat = repeat;
19
- //# sourceMappingURL=out.js.map
19
+ //# sourceMappingURL=repeat.cjs.map
20
20
  //# sourceMappingURL=repeat.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/repeat.ts"],"names":[],"mappings":";;;;AAAA,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAmBzB,SAAS,OAA0B,OAAoB,OAA8C;AAC3G,UAAQ,kBAAkB,gBAAgB,KAAK,GAAG,KAAK;AAEvD,MAAI,IAAI;AACR,SAAO;AAAA,IAAkC,MACxC,KAAK,QACF,EAAE,MAAM,MAAM,OAAO,OAAU,KAC9B,KAAK,EAAE,MAAM,OAAO,MAAM;AAAA,EAC/B;AACD;AATgB","sourcesContent":["import { assertNotNegative } from './shared/_assertNotNegative';\nimport { makeIterableIterator } from './shared/_makeIterableIterator';\nimport { toNumberOrThrow } from './shared/_toNumberOrThrow';\n\n/**\n * Creates an iterable that repeats the input iterable `count` times.\n *\n * @param value The value to be repeated.\n * @param count The number of times to repeat the value.\n *\n * @example\n * ```typescript\n * import { repeat } from '@sapphire/iterator-utilities';\n *\n * const iterator = repeat('Hello, world!', 3);\n * console.log([...iterator]);\n * // Output: ['Hello, world!', 'Hello, world!', 'Hello, world!']\n * ```\n *\n * @remarks This function does not clone `value`, it will be repeated as a reference.\n */\nexport function repeat<const ElementType>(value: ElementType, count: number): IterableIterator<ElementType> {\n\tcount = assertNotNegative(toNumberOrThrow(count), count);\n\n\tlet i = 0;\n\treturn makeIterableIterator<ElementType>(() =>\n\t\ti >= count //\n\t\t\t? { done: true, value: undefined }\n\t\t\t: (i++, { done: false, value })\n\t);\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/repeat.ts"],"names":["assertNotNegative","toNumberOrThrow","makeIterableIterator"],"mappings":";;;;;;;;AAqBO,SAAS,MAAA,CAA0B,OAAoB,KAA8C,EAAA;AAC3G,EAAA,KAAA,GAAQA,wCAAkB,CAAAC,oCAAA,CAAgB,KAAK,CAAA,EAAG,KAAK,CAAA;AAEvD,EAAA,IAAI,CAAI,GAAA,CAAA;AACR,EAAO,OAAAC,8CAAA;AAAA,IAAkC,MACxC,CAAA,IAAK,KACF,GAAA,EAAE,IAAM,EAAA,IAAA,EAAM,KAAO,EAAA,KAAA,CAAA,EACpB,IAAA,CAAA,EAAA,EAAK,EAAE,IAAA,EAAM,OAAO,KAAM,EAAA;AAAA,GAC/B;AACD;AATgB,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA","file":"repeat.cjs","sourcesContent":["import { assertNotNegative } from './shared/_assertNotNegative';\nimport { makeIterableIterator } from './shared/_makeIterableIterator';\nimport { toNumberOrThrow } from './shared/_toNumberOrThrow';\n\n/**\n * Creates an iterable that repeats the input iterable `count` times.\n *\n * @param value The value to be repeated.\n * @param count The number of times to repeat the value.\n *\n * @example\n * ```typescript\n * import { repeat } from '@sapphire/iterator-utilities';\n *\n * const iterator = repeat('Hello, world!', 3);\n * console.log([...iterator]);\n * // Output: ['Hello, world!', 'Hello, world!', 'Hello, world!']\n * ```\n *\n * @remarks This function does not clone `value`, it will be repeated as a reference.\n */\nexport function repeat<const ElementType>(value: ElementType, count: number): IterableIterator<ElementType> {\n\tcount = assertNotNegative(toNumberOrThrow(count), count);\n\n\tlet i = 0;\n\treturn makeIterableIterator<ElementType>(() =>\n\t\ti >= count //\n\t\t\t? { done: true, value: undefined }\n\t\t\t: (i++, { done: false, value })\n\t);\n}\n"]}
@@ -1,14 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var toIterableIterator_cjs = require('./toIterableIterator.cjs');
3
+ var collect_cjs = require('./collect.cjs');
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
7
  function* reverse(iterable) {
8
- const items = [];
9
- for (const item of toIterableIterator_cjs.toIterableIterator(iterable)) {
10
- items.push(item);
11
- }
8
+ const items = collect_cjs.collect(iterable);
12
9
  for (let i = items.length - 1; i >= 0; i--) {
13
10
  yield items[i];
14
11
  }
@@ -16,5 +13,5 @@ function* reverse(iterable) {
16
13
  __name(reverse, "reverse");
17
14
 
18
15
  exports.reverse = reverse;
19
- //# sourceMappingURL=out.js.map
16
+ //# sourceMappingURL=reverse.cjs.map
20
17
  //# sourceMappingURL=reverse.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/reverse.ts"],"names":[],"mappings":";;;;AACA,SAAS,0BAA0B;AAuB5B,UAAU,QAA2B,UAA0E;AACrH,QAAM,QAAuB,CAAC;AAC9B,aAAW,QAAQ,mBAAmB,QAAQ,GAAG;AAChD,UAAM,KAAK,IAAI;AAAA,EAChB;AAEA,WAAS,IAAI,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK;AAC3C,UAAM,MAAM,CAAC;AAAA,EACd;AACD;AATiB","sourcesContent":["import type { IterableResolvable } from './from';\nimport { toIterableIterator } from './toIterableIterator';\n\n/**\n * Consumes the iterable and returns a new iterable with the elements in reverse order.\n *\n * @param iterable The iterator to reverse.\n * @returns An iterator whose element correspond to the elements of the provided iterator in reverse order.\n *\n * @example\n * ```typescript\n * import { reverse } from '@sapphire/iterator-utilities';\n *\n * console.log([...reverse([1, 2, 3, 4, 5])]);\n * // Output: [5, 4, 3, 2, 1]\n *\n * console.log([...reverse('hello')]);\n * // Output: ['o', 'l', 'l', 'e', 'h']\n * ```\n *\n * @remarks\n *\n * This function collects all elements of the provided iterator into an array before yielding them in reverse order.\n */\nexport function* reverse<const ElementType>(iterable: IterableResolvable<ElementType>): IterableIterator<ElementType> {\n\tconst items: ElementType[] = [];\n\tfor (const item of toIterableIterator(iterable)) {\n\t\titems.push(item);\n\t}\n\n\tfor (let i = items.length - 1; i >= 0; i--) {\n\t\tyield items[i];\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/reverse.ts"],"names":["collect"],"mappings":";;;;;;AAwBO,UAAU,QAA2B,QAA0E,EAAA;AACrH,EAAM,MAAA,KAAA,GAAQA,oBAAQ,QAAQ,CAAA;AAC9B,EAAA,KAAA,IAAS,IAAI,KAAM,CAAA,MAAA,GAAS,CAAG,EAAA,CAAA,IAAK,GAAG,CAAK,EAAA,EAAA;AAC3C,IAAA,MAAM,MAAM,CAAC,CAAA;AAAA;AAEf;AALiB,MAAA,CAAA,OAAA,EAAA,SAAA,CAAA","file":"reverse.cjs","sourcesContent":["import { collect } from './collect';\nimport type { IterableResolvable } from './from';\n\n/**\n * Consumes the iterable and returns a new iterable with the elements in reverse order.\n *\n * @param iterable The iterator to reverse.\n * @returns An iterator whose element correspond to the elements of the provided iterator in reverse order.\n *\n * @example\n * ```typescript\n * import { reverse } from '@sapphire/iterator-utilities';\n *\n * console.log([...reverse([1, 2, 3, 4, 5])]);\n * // Output: [5, 4, 3, 2, 1]\n *\n * console.log([...reverse('hello')]);\n * // Output: ['o', 'l', 'l', 'e', 'h']\n * ```\n *\n * @remarks\n *\n * This function collects all elements of the provided iterator into an array before yielding them in reverse order.\n */\nexport function* reverse<const ElementType>(iterable: IterableResolvable<ElementType>): IterableIterator<ElementType> {\n\tconst items = collect(iterable);\n\tfor (let i = items.length - 1; i >= 0; i--) {\n\t\tyield items[i];\n\t}\n}\n"]}
@@ -13,5 +13,5 @@ function assertFunction(value) {
13
13
  __name(assertFunction, "assertFunction");
14
14
 
15
15
  exports.assertFunction = assertFunction;
16
- //# sourceMappingURL=out.js.map
16
+ //# sourceMappingURL=_assertFunction.cjs.map
17
17
  //# sourceMappingURL=_assertFunction.cjs.map