@sapphire/iterator-utilities 1.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 (379) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +765 -0
  3. package/dist/cjs/index.cjs +385 -0
  4. package/dist/cjs/index.cjs.map +1 -0
  5. package/dist/cjs/index.d.cts +55 -0
  6. package/dist/cjs/lib/append.cjs +15 -0
  7. package/dist/cjs/lib/append.cjs.map +1 -0
  8. package/dist/cjs/lib/append.d.cts +21 -0
  9. package/dist/cjs/lib/at.cjs +18 -0
  10. package/dist/cjs/lib/at.cjs.map +1 -0
  11. package/dist/cjs/lib/at.d.cts +25 -0
  12. package/dist/cjs/lib/average.cjs +21 -0
  13. package/dist/cjs/lib/average.cjs.map +1 -0
  14. package/dist/cjs/lib/average.d.cts +25 -0
  15. package/dist/cjs/lib/chain.cjs +16 -0
  16. package/dist/cjs/lib/chain.cjs.map +1 -0
  17. package/dist/cjs/lib/chain.d.cts +20 -0
  18. package/dist/cjs/lib/chunk.cjs +27 -0
  19. package/dist/cjs/lib/chunk.cjs.map +1 -0
  20. package/dist/cjs/lib/chunk.d.cts +20 -0
  21. package/dist/cjs/lib/compact.cjs +14 -0
  22. package/dist/cjs/lib/compact.cjs.map +1 -0
  23. package/dist/cjs/lib/compact.d.cts +19 -0
  24. package/dist/cjs/lib/compress.cjs +24 -0
  25. package/dist/cjs/lib/compress.cjs.map +1 -0
  26. package/dist/cjs/lib/compress.d.cts +26 -0
  27. package/dist/cjs/lib/contains.cjs +18 -0
  28. package/dist/cjs/lib/contains.cjs.map +1 -0
  29. package/dist/cjs/lib/contains.d.cts +25 -0
  30. package/dist/cjs/lib/count.cjs +19 -0
  31. package/dist/cjs/lib/count.cjs.map +1 -0
  32. package/dist/cjs/lib/count.d.cts +24 -0
  33. package/dist/cjs/lib/cycle.cjs +23 -0
  34. package/dist/cjs/lib/cycle.cjs.map +1 -0
  35. package/dist/cjs/lib/cycle.d.cts +21 -0
  36. package/dist/cjs/lib/difference.cjs +18 -0
  37. package/dist/cjs/lib/difference.cjs.map +1 -0
  38. package/dist/cjs/lib/difference.d.cts +25 -0
  39. package/dist/cjs/lib/drop.cjs +28 -0
  40. package/dist/cjs/lib/drop.cjs.map +1 -0
  41. package/dist/cjs/lib/drop.d.cts +21 -0
  42. package/dist/cjs/lib/dropLast.cjs +23 -0
  43. package/dist/cjs/lib/dropLast.cjs.map +1 -0
  44. package/dist/cjs/lib/dropLast.d.cts +25 -0
  45. package/dist/cjs/lib/dropWhile.cjs +22 -0
  46. package/dist/cjs/lib/dropWhile.cjs.map +1 -0
  47. package/dist/cjs/lib/dropWhile.d.cts +24 -0
  48. package/dist/cjs/lib/empty.cjs +14 -0
  49. package/dist/cjs/lib/empty.cjs.map +1 -0
  50. package/dist/cjs/lib/empty.d.cts +17 -0
  51. package/dist/cjs/lib/enumerate.cjs +17 -0
  52. package/dist/cjs/lib/enumerate.cjs.map +1 -0
  53. package/dist/cjs/lib/enumerate.d.cts +24 -0
  54. package/dist/cjs/lib/every.cjs +21 -0
  55. package/dist/cjs/lib/every.cjs.map +1 -0
  56. package/dist/cjs/lib/every.d.cts +29 -0
  57. package/dist/cjs/lib/filter.cjs +21 -0
  58. package/dist/cjs/lib/filter.cjs.map +1 -0
  59. package/dist/cjs/lib/filter.d.cts +22 -0
  60. package/dist/cjs/lib/find.cjs +15 -0
  61. package/dist/cjs/lib/find.cjs.map +1 -0
  62. package/dist/cjs/lib/find.d.cts +26 -0
  63. package/dist/cjs/lib/findIndex.cjs +23 -0
  64. package/dist/cjs/lib/findIndex.cjs.map +1 -0
  65. package/dist/cjs/lib/findIndex.d.cts +25 -0
  66. package/dist/cjs/lib/first.cjs +14 -0
  67. package/dist/cjs/lib/first.cjs.map +1 -0
  68. package/dist/cjs/lib/first.d.cts +24 -0
  69. package/dist/cjs/lib/flat.cjs +16 -0
  70. package/dist/cjs/lib/flat.cjs.map +1 -0
  71. package/dist/cjs/lib/flat.d.cts +20 -0
  72. package/dist/cjs/lib/flatMap.cjs +19 -0
  73. package/dist/cjs/lib/flatMap.cjs.map +1 -0
  74. package/dist/cjs/lib/flatMap.d.cts +21 -0
  75. package/dist/cjs/lib/forEach.cjs +19 -0
  76. package/dist/cjs/lib/forEach.cjs.map +1 -0
  77. package/dist/cjs/lib/forEach.d.cts +24 -0
  78. package/dist/cjs/lib/from.cjs +25 -0
  79. package/dist/cjs/lib/from.cjs.map +1 -0
  80. package/dist/cjs/lib/from.d.cts +21 -0
  81. package/dist/cjs/lib/indexOf.cjs +22 -0
  82. package/dist/cjs/lib/indexOf.cjs.map +1 -0
  83. package/dist/cjs/lib/indexOf.d.cts +25 -0
  84. package/dist/cjs/lib/intersect.cjs +16 -0
  85. package/dist/cjs/lib/intersect.cjs.map +1 -0
  86. package/dist/cjs/lib/intersect.d.cts +26 -0
  87. package/dist/cjs/lib/isEmpty.cjs +14 -0
  88. package/dist/cjs/lib/isEmpty.cjs.map +1 -0
  89. package/dist/cjs/lib/isEmpty.d.cts +26 -0
  90. package/dist/cjs/lib/last.cjs +18 -0
  91. package/dist/cjs/lib/last.cjs.map +1 -0
  92. package/dist/cjs/lib/last.d.cts +24 -0
  93. package/dist/cjs/lib/map.cjs +19 -0
  94. package/dist/cjs/lib/map.cjs.map +1 -0
  95. package/dist/cjs/lib/map.d.cts +20 -0
  96. package/dist/cjs/lib/max.cjs +20 -0
  97. package/dist/cjs/lib/max.cjs.map +1 -0
  98. package/dist/cjs/lib/max.d.cts +25 -0
  99. package/dist/cjs/lib/min.cjs +20 -0
  100. package/dist/cjs/lib/min.cjs.map +1 -0
  101. package/dist/cjs/lib/min.d.cts +25 -0
  102. package/dist/cjs/lib/partition.cjs +26 -0
  103. package/dist/cjs/lib/partition.cjs.map +1 -0
  104. package/dist/cjs/lib/partition.d.cts +33 -0
  105. package/dist/cjs/lib/peekable.cjs +32 -0
  106. package/dist/cjs/lib/peekable.cjs.map +1 -0
  107. package/dist/cjs/lib/peekable.d.cts +35 -0
  108. package/dist/cjs/lib/prepend.cjs +17 -0
  109. package/dist/cjs/lib/prepend.cjs.map +1 -0
  110. package/dist/cjs/lib/prepend.d.cts +22 -0
  111. package/dist/cjs/lib/product.cjs +19 -0
  112. package/dist/cjs/lib/product.cjs.map +1 -0
  113. package/dist/cjs/lib/product.d.cts +24 -0
  114. package/dist/cjs/lib/range.cjs +37 -0
  115. package/dist/cjs/lib/range.cjs.map +1 -0
  116. package/dist/cjs/lib/range.d.cts +33 -0
  117. package/dist/cjs/lib/reduce.cjs +32 -0
  118. package/dist/cjs/lib/reduce.cjs.map +1 -0
  119. package/dist/cjs/lib/reduce.d.cts +33 -0
  120. package/dist/cjs/lib/repeat.cjs +20 -0
  121. package/dist/cjs/lib/repeat.cjs.map +1 -0
  122. package/dist/cjs/lib/repeat.d.cts +20 -0
  123. package/dist/cjs/lib/reverse.cjs +20 -0
  124. package/dist/cjs/lib/reverse.cjs.map +1 -0
  125. package/dist/cjs/lib/reverse.d.cts +26 -0
  126. package/dist/cjs/lib/shared/_assertFunction.cjs +17 -0
  127. package/dist/cjs/lib/shared/_assertFunction.cjs.map +1 -0
  128. package/dist/cjs/lib/shared/_assertFunction.d.cts +3 -0
  129. package/dist/cjs/lib/shared/_assertNotNegative.cjs +17 -0
  130. package/dist/cjs/lib/shared/_assertNotNegative.cjs.map +1 -0
  131. package/dist/cjs/lib/shared/_assertNotNegative.d.cts +3 -0
  132. package/dist/cjs/lib/shared/_assertPositive.cjs +17 -0
  133. package/dist/cjs/lib/shared/_assertPositive.cjs.map +1 -0
  134. package/dist/cjs/lib/shared/_assertPositive.d.cts +3 -0
  135. package/dist/cjs/lib/shared/_makeIterableIterator.cjs +19 -0
  136. package/dist/cjs/lib/shared/_makeIterableIterator.cjs.map +1 -0
  137. package/dist/cjs/lib/shared/_makeIterableIterator.d.cts +3 -0
  138. package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs +21 -0
  139. package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.cjs.map +1 -0
  140. package/dist/cjs/lib/shared/_toIntegerOrInfinityOrThrow.d.cts +3 -0
  141. package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs +21 -0
  142. package/dist/cjs/lib/shared/_toIntegerOrThrow.cjs.map +1 -0
  143. package/dist/cjs/lib/shared/_toIntegerOrThrow.d.cts +3 -0
  144. package/dist/cjs/lib/shared/_toNumberOrThrow.cjs +34 -0
  145. package/dist/cjs/lib/shared/_toNumberOrThrow.cjs.map +1 -0
  146. package/dist/cjs/lib/shared/_toNumberOrThrow.d.cts +8 -0
  147. package/dist/cjs/lib/slice.cjs +44 -0
  148. package/dist/cjs/lib/slice.cjs.map +1 -0
  149. package/dist/cjs/lib/slice.d.cts +62 -0
  150. package/dist/cjs/lib/some.cjs +22 -0
  151. package/dist/cjs/lib/some.cjs.map +1 -0
  152. package/dist/cjs/lib/some.d.cts +33 -0
  153. package/dist/cjs/lib/sorted.cjs +14 -0
  154. package/dist/cjs/lib/sorted.cjs.map +1 -0
  155. package/dist/cjs/lib/sorted.d.cts +25 -0
  156. package/dist/cjs/lib/starMap.cjs +19 -0
  157. package/dist/cjs/lib/starMap.cjs.map +1 -0
  158. package/dist/cjs/lib/starMap.d.cts +28 -0
  159. package/dist/cjs/lib/sum.cjs +19 -0
  160. package/dist/cjs/lib/sum.cjs.map +1 -0
  161. package/dist/cjs/lib/sum.d.cts +25 -0
  162. package/dist/cjs/lib/take.cjs +25 -0
  163. package/dist/cjs/lib/take.cjs.map +1 -0
  164. package/dist/cjs/lib/take.d.cts +21 -0
  165. package/dist/cjs/lib/takeLast.cjs +31 -0
  166. package/dist/cjs/lib/takeLast.cjs.map +1 -0
  167. package/dist/cjs/lib/takeLast.d.cts +25 -0
  168. package/dist/cjs/lib/tee.cjs +39 -0
  169. package/dist/cjs/lib/tee.cjs.map +1 -0
  170. package/dist/cjs/lib/tee.d.cts +25 -0
  171. package/dist/cjs/lib/toArray.cjs +14 -0
  172. package/dist/cjs/lib/toArray.cjs.map +1 -0
  173. package/dist/cjs/lib/toArray.d.cts +36 -0
  174. package/dist/cjs/lib/toIterableIterator.cjs +19 -0
  175. package/dist/cjs/lib/toIterableIterator.cjs.map +1 -0
  176. package/dist/cjs/lib/toIterableIterator.d.cts +32 -0
  177. package/dist/cjs/lib/union.cjs +22 -0
  178. package/dist/cjs/lib/union.cjs.map +1 -0
  179. package/dist/cjs/lib/union.d.cts +20 -0
  180. package/dist/cjs/lib/unique.cjs +14 -0
  181. package/dist/cjs/lib/unique.cjs.map +1 -0
  182. package/dist/cjs/lib/unique.d.cts +20 -0
  183. package/dist/cjs/lib/unzip.cjs +37 -0
  184. package/dist/cjs/lib/unzip.cjs.map +1 -0
  185. package/dist/cjs/lib/unzip.d.cts +32 -0
  186. package/dist/cjs/lib/zip.cjs +24 -0
  187. package/dist/cjs/lib/zip.cjs.map +1 -0
  188. package/dist/cjs/lib/zip.d.cts +30 -0
  189. package/dist/esm/chunk-G5GHKT7C.mjs +6 -0
  190. package/dist/esm/chunk-G5GHKT7C.mjs.map +1 -0
  191. package/dist/esm/index.d.mts +55 -0
  192. package/dist/esm/index.mjs +56 -0
  193. package/dist/esm/index.mjs.map +1 -0
  194. package/dist/esm/lib/append.d.mts +21 -0
  195. package/dist/esm/lib/append.mjs +11 -0
  196. package/dist/esm/lib/append.mjs.map +1 -0
  197. package/dist/esm/lib/at.d.mts +25 -0
  198. package/dist/esm/lib/at.mjs +15 -0
  199. package/dist/esm/lib/at.mjs.map +1 -0
  200. package/dist/esm/lib/average.d.mts +25 -0
  201. package/dist/esm/lib/average.mjs +18 -0
  202. package/dist/esm/lib/average.mjs.map +1 -0
  203. package/dist/esm/lib/chain.d.mts +20 -0
  204. package/dist/esm/lib/chain.mjs +13 -0
  205. package/dist/esm/lib/chain.mjs.map +1 -0
  206. package/dist/esm/lib/chunk.d.mts +20 -0
  207. package/dist/esm/lib/chunk.mjs +24 -0
  208. package/dist/esm/lib/chunk.mjs.map +1 -0
  209. package/dist/esm/lib/compact.d.mts +19 -0
  210. package/dist/esm/lib/compact.mjs +11 -0
  211. package/dist/esm/lib/compact.mjs.map +1 -0
  212. package/dist/esm/lib/compress.d.mts +26 -0
  213. package/dist/esm/lib/compress.mjs +21 -0
  214. package/dist/esm/lib/compress.mjs.map +1 -0
  215. package/dist/esm/lib/contains.d.mts +25 -0
  216. package/dist/esm/lib/contains.mjs +15 -0
  217. package/dist/esm/lib/contains.mjs.map +1 -0
  218. package/dist/esm/lib/count.d.mts +24 -0
  219. package/dist/esm/lib/count.mjs +16 -0
  220. package/dist/esm/lib/count.mjs.map +1 -0
  221. package/dist/esm/lib/cycle.d.mts +21 -0
  222. package/dist/esm/lib/cycle.mjs +20 -0
  223. package/dist/esm/lib/cycle.mjs.map +1 -0
  224. package/dist/esm/lib/difference.d.mts +25 -0
  225. package/dist/esm/lib/difference.mjs +13 -0
  226. package/dist/esm/lib/difference.mjs.map +1 -0
  227. package/dist/esm/lib/drop.d.mts +21 -0
  228. package/dist/esm/lib/drop.mjs +24 -0
  229. package/dist/esm/lib/drop.mjs.map +1 -0
  230. package/dist/esm/lib/dropLast.d.mts +25 -0
  231. package/dist/esm/lib/dropLast.mjs +19 -0
  232. package/dist/esm/lib/dropLast.mjs.map +1 -0
  233. package/dist/esm/lib/dropWhile.d.mts +24 -0
  234. package/dist/esm/lib/dropWhile.mjs +18 -0
  235. package/dist/esm/lib/dropWhile.mjs.map +1 -0
  236. package/dist/esm/lib/empty.d.mts +17 -0
  237. package/dist/esm/lib/empty.mjs +11 -0
  238. package/dist/esm/lib/empty.mjs.map +1 -0
  239. package/dist/esm/lib/enumerate.d.mts +24 -0
  240. package/dist/esm/lib/enumerate.mjs +14 -0
  241. package/dist/esm/lib/enumerate.mjs.map +1 -0
  242. package/dist/esm/lib/every.d.mts +29 -0
  243. package/dist/esm/lib/every.mjs +18 -0
  244. package/dist/esm/lib/every.mjs.map +1 -0
  245. package/dist/esm/lib/filter.d.mts +22 -0
  246. package/dist/esm/lib/filter.mjs +17 -0
  247. package/dist/esm/lib/filter.mjs.map +1 -0
  248. package/dist/esm/lib/find.d.mts +26 -0
  249. package/dist/esm/lib/find.mjs +12 -0
  250. package/dist/esm/lib/find.mjs.map +1 -0
  251. package/dist/esm/lib/findIndex.d.mts +25 -0
  252. package/dist/esm/lib/findIndex.mjs +20 -0
  253. package/dist/esm/lib/findIndex.mjs.map +1 -0
  254. package/dist/esm/lib/first.d.mts +24 -0
  255. package/dist/esm/lib/first.mjs +11 -0
  256. package/dist/esm/lib/first.mjs.map +1 -0
  257. package/dist/esm/lib/flat.d.mts +20 -0
  258. package/dist/esm/lib/flat.mjs +13 -0
  259. package/dist/esm/lib/flat.mjs.map +1 -0
  260. package/dist/esm/lib/flatMap.d.mts +21 -0
  261. package/dist/esm/lib/flatMap.mjs +16 -0
  262. package/dist/esm/lib/flatMap.mjs.map +1 -0
  263. package/dist/esm/lib/forEach.d.mts +24 -0
  264. package/dist/esm/lib/forEach.mjs +16 -0
  265. package/dist/esm/lib/forEach.mjs.map +1 -0
  266. package/dist/esm/lib/from.d.mts +21 -0
  267. package/dist/esm/lib/from.mjs +22 -0
  268. package/dist/esm/lib/from.mjs.map +1 -0
  269. package/dist/esm/lib/indexOf.d.mts +25 -0
  270. package/dist/esm/lib/indexOf.mjs +18 -0
  271. package/dist/esm/lib/indexOf.mjs.map +1 -0
  272. package/dist/esm/lib/intersect.d.mts +26 -0
  273. package/dist/esm/lib/intersect.mjs +13 -0
  274. package/dist/esm/lib/intersect.mjs.map +1 -0
  275. package/dist/esm/lib/isEmpty.d.mts +26 -0
  276. package/dist/esm/lib/isEmpty.mjs +11 -0
  277. package/dist/esm/lib/isEmpty.mjs.map +1 -0
  278. package/dist/esm/lib/last.d.mts +24 -0
  279. package/dist/esm/lib/last.mjs +15 -0
  280. package/dist/esm/lib/last.mjs.map +1 -0
  281. package/dist/esm/lib/map.d.mts +20 -0
  282. package/dist/esm/lib/map.mjs +16 -0
  283. package/dist/esm/lib/map.mjs.map +1 -0
  284. package/dist/esm/lib/max.d.mts +25 -0
  285. package/dist/esm/lib/max.mjs +17 -0
  286. package/dist/esm/lib/max.mjs.map +1 -0
  287. package/dist/esm/lib/min.d.mts +25 -0
  288. package/dist/esm/lib/min.mjs +17 -0
  289. package/dist/esm/lib/min.mjs.map +1 -0
  290. package/dist/esm/lib/partition.d.mts +33 -0
  291. package/dist/esm/lib/partition.mjs +23 -0
  292. package/dist/esm/lib/partition.mjs.map +1 -0
  293. package/dist/esm/lib/peekable.d.mts +35 -0
  294. package/dist/esm/lib/peekable.mjs +29 -0
  295. package/dist/esm/lib/peekable.mjs.map +1 -0
  296. package/dist/esm/lib/prepend.d.mts +22 -0
  297. package/dist/esm/lib/prepend.mjs +14 -0
  298. package/dist/esm/lib/prepend.mjs.map +1 -0
  299. package/dist/esm/lib/product.d.mts +24 -0
  300. package/dist/esm/lib/product.mjs +16 -0
  301. package/dist/esm/lib/product.mjs.map +1 -0
  302. package/dist/esm/lib/range.d.mts +33 -0
  303. package/dist/esm/lib/range.mjs +34 -0
  304. package/dist/esm/lib/range.mjs.map +1 -0
  305. package/dist/esm/lib/reduce.d.mts +33 -0
  306. package/dist/esm/lib/reduce.mjs +29 -0
  307. package/dist/esm/lib/reduce.mjs.map +1 -0
  308. package/dist/esm/lib/repeat.d.mts +20 -0
  309. package/dist/esm/lib/repeat.mjs +17 -0
  310. package/dist/esm/lib/repeat.mjs.map +1 -0
  311. package/dist/esm/lib/reverse.d.mts +26 -0
  312. package/dist/esm/lib/reverse.mjs +17 -0
  313. package/dist/esm/lib/reverse.mjs.map +1 -0
  314. package/dist/esm/lib/shared/_assertFunction.d.mts +3 -0
  315. package/dist/esm/lib/shared/_assertFunction.mjs +14 -0
  316. package/dist/esm/lib/shared/_assertFunction.mjs.map +1 -0
  317. package/dist/esm/lib/shared/_assertNotNegative.d.mts +3 -0
  318. package/dist/esm/lib/shared/_assertNotNegative.mjs +14 -0
  319. package/dist/esm/lib/shared/_assertNotNegative.mjs.map +1 -0
  320. package/dist/esm/lib/shared/_assertPositive.d.mts +3 -0
  321. package/dist/esm/lib/shared/_assertPositive.mjs +14 -0
  322. package/dist/esm/lib/shared/_assertPositive.mjs.map +1 -0
  323. package/dist/esm/lib/shared/_makeIterableIterator.d.mts +3 -0
  324. package/dist/esm/lib/shared/_makeIterableIterator.mjs +16 -0
  325. package/dist/esm/lib/shared/_makeIterableIterator.mjs.map +1 -0
  326. package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.d.mts +3 -0
  327. package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs +18 -0
  328. package/dist/esm/lib/shared/_toIntegerOrInfinityOrThrow.mjs.map +1 -0
  329. package/dist/esm/lib/shared/_toIntegerOrThrow.d.mts +3 -0
  330. package/dist/esm/lib/shared/_toIntegerOrThrow.mjs +18 -0
  331. package/dist/esm/lib/shared/_toIntegerOrThrow.mjs.map +1 -0
  332. package/dist/esm/lib/shared/_toNumberOrThrow.d.mts +8 -0
  333. package/dist/esm/lib/shared/_toNumberOrThrow.mjs +31 -0
  334. package/dist/esm/lib/shared/_toNumberOrThrow.mjs.map +1 -0
  335. package/dist/esm/lib/slice.d.mts +62 -0
  336. package/dist/esm/lib/slice.mjs +41 -0
  337. package/dist/esm/lib/slice.mjs.map +1 -0
  338. package/dist/esm/lib/some.d.mts +33 -0
  339. package/dist/esm/lib/some.mjs +19 -0
  340. package/dist/esm/lib/some.mjs.map +1 -0
  341. package/dist/esm/lib/sorted.d.mts +25 -0
  342. package/dist/esm/lib/sorted.mjs +11 -0
  343. package/dist/esm/lib/sorted.mjs.map +1 -0
  344. package/dist/esm/lib/starMap.d.mts +28 -0
  345. package/dist/esm/lib/starMap.mjs +16 -0
  346. package/dist/esm/lib/starMap.mjs.map +1 -0
  347. package/dist/esm/lib/sum.d.mts +25 -0
  348. package/dist/esm/lib/sum.mjs +16 -0
  349. package/dist/esm/lib/sum.mjs.map +1 -0
  350. package/dist/esm/lib/take.d.mts +21 -0
  351. package/dist/esm/lib/take.mjs +22 -0
  352. package/dist/esm/lib/take.mjs.map +1 -0
  353. package/dist/esm/lib/takeLast.d.mts +25 -0
  354. package/dist/esm/lib/takeLast.mjs +28 -0
  355. package/dist/esm/lib/takeLast.mjs.map +1 -0
  356. package/dist/esm/lib/tee.d.mts +25 -0
  357. package/dist/esm/lib/tee.mjs +36 -0
  358. package/dist/esm/lib/tee.mjs.map +1 -0
  359. package/dist/esm/lib/toArray.d.mts +36 -0
  360. package/dist/esm/lib/toArray.mjs +11 -0
  361. package/dist/esm/lib/toArray.mjs.map +1 -0
  362. package/dist/esm/lib/toIterableIterator.d.mts +32 -0
  363. package/dist/esm/lib/toIterableIterator.mjs +16 -0
  364. package/dist/esm/lib/toIterableIterator.mjs.map +1 -0
  365. package/dist/esm/lib/union.d.mts +20 -0
  366. package/dist/esm/lib/union.mjs +19 -0
  367. package/dist/esm/lib/union.mjs.map +1 -0
  368. package/dist/esm/lib/unique.d.mts +20 -0
  369. package/dist/esm/lib/unique.mjs +11 -0
  370. package/dist/esm/lib/unique.mjs.map +1 -0
  371. package/dist/esm/lib/unzip.d.mts +32 -0
  372. package/dist/esm/lib/unzip.mjs +34 -0
  373. package/dist/esm/lib/unzip.mjs.map +1 -0
  374. package/dist/esm/lib/zip.d.mts +30 -0
  375. package/dist/esm/lib/zip.mjs +21 -0
  376. package/dist/esm/lib/zip.mjs.map +1 -0
  377. package/dist/iife/index.global.js +834 -0
  378. package/dist/iife/index.global.js.map +1 -0
  379. package/package.json +692 -0
package/README.md ADDED
@@ -0,0 +1,765 @@
1
+ <div align="center">
2
+
3
+ ![Sapphire Logo](https://raw.githubusercontent.com/sapphiredev/assets/main/banners/SapphireCommunity.png)
4
+
5
+ # @sapphire/iterator-utilities
6
+
7
+ **Iterator utilities for JavaScript.**
8
+
9
+ [![GitHub](https://img.shields.io/github/license/sapphiredev/utilities)](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md)
10
+ [![codecov](https://codecov.io/gh/sapphiredev/utilities/branch/main/graph/badge.svg?token=OEGIV6RFDO)](https://codecov.io/gh/sapphiredev/utilities)
11
+ [![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/iterator-utilities?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/iterator-utilities)
12
+ [![npm](https://img.shields.io/npm/v/@sapphire/iterator-utilities?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/iterator-utilities)
13
+
14
+ </div>
15
+
16
+ **Table of Contents**
17
+
18
+ - [Features](#features)
19
+ - [Installation](#installation)
20
+ - [Usage](#usage)
21
+ - [Resolving](#resolving)
22
+ - [Checking for the existence of any bit](#checking-for-the-existence-of-any-bit)
23
+ - [Checking for the existence of one or multiple bits](#checking-for-the-existence-of-one-or-multiple-bits)
24
+ - [Getting the field's complement](#getting-the-fields-complement)
25
+ - [Getting the union of different fields](#getting-the-union-of-different-fields)
26
+ - [Getting the intersection between different fields](#getting-the-intersection-between-different-fields)
27
+ - [Getting the symmetric difference between different fields](#getting-the-symmetric-difference-between-different-fields)
28
+ - [Formatting a field](#formatting-a-field)
29
+ - [Buy us some doughnuts](#buy-us-some-doughnuts)
30
+ - [Contributors ✨](#contributors-)
31
+
32
+ ## Features
33
+
34
+ - Written in TypeScript
35
+ - Bundled with esbuild so it can be used in NodeJS and browsers
36
+ - Offers CommonJS, ESM and UMD bundles
37
+ - Fully tested
38
+
39
+ ## Installation
40
+
41
+ You can use the following command to install this package, or replace `npm install` with your package manager of choice.
42
+
43
+ ```sh
44
+ npm install @sapphire/iterator-utilities
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ For any of the following examples, you can import the utilities from the index file:
50
+
51
+ ```ts
52
+ import { append } from '@sapphire/iterator-utilities';
53
+ const { append } = require('@sapphire/iterator-utilities');
54
+ ```
55
+
56
+ Or you can import the utilities directly:
57
+
58
+ ```ts
59
+ import { append } from '@sapphire/iterator-utilities/append';
60
+ const { append } = require('@sapphire/iterator-utilities/append');
61
+ ```
62
+
63
+ ### `append`
64
+
65
+ Appends iterables to the end of the first iterable, returning a new iterable combining all of them. It's similar to concatenating arrays or doing `[...a, ...b, ...c]`.
66
+
67
+ ```typescript
68
+ const iterable = append([1, 2, 3], [4, 5, 6], [7, 8, 9]);
69
+ console.log([...iterable]);
70
+ // Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
71
+ ```
72
+
73
+ ### `at`
74
+
75
+ Advances the iterable to the `n`th element and returns it. If the iterable is exhausted before reaching the `n`th element, it returns `undefined`.
76
+
77
+ ```typescript
78
+ const iterable = [1, 2, 3, 4, 5];
79
+ console.log(at(iterable, 2));
80
+ // Output: 3
81
+ ```
82
+
83
+ ### `average`
84
+
85
+ Consumes the iterable and returns the average value of all the elements. If the iterable is empty, it returns `null`.
86
+
87
+ ```typescript
88
+ const iterable = [1, 2, 3, 4, 5];
89
+ console.log(average(iterable));
90
+ // Output: 3
91
+ ```
92
+
93
+ ### `chain`
94
+
95
+ Similar to `append`, but takes an iterable of iterables and chains them together.
96
+
97
+ ```typescript
98
+ const iterable = chain([1, 2, 3], [4, 5, 6], [7, 8, 9]);
99
+ console.log([...iterable]);
100
+ // Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
101
+ ```
102
+
103
+ ### `chunk`
104
+
105
+ Chunks the iterable into arrays of at most `size` elements.
106
+
107
+ ```typescript
108
+ const iterable = [1, 2, 3, 4, 5];
109
+ console.log([...chunk(iterable, 2)]);
110
+ // Output: [[1, 2], [3, 4], [5]]
111
+ ```
112
+
113
+ ### `compact`
114
+
115
+ Creates a new iterable that yields all the non-nullish values (`null` and `undefined`) from the iterable.
116
+
117
+ ```typescript
118
+ const iterable = [1, null, 2, undefined, 3];
119
+ console.log([...compact(iterable)]);
120
+ // Output: [1, 2, 3]
121
+ ```
122
+
123
+ ### `compress`
124
+
125
+ Creates a new iterable of the first iterable based on the truthiness of the corresponding element in the second iterable.
126
+
127
+ ```typescript
128
+ const iterable = compress([1, 2, 3, 4, 5], [true, false, true, false, true]);
129
+ console.log([...iterable]);
130
+ // Output: [1, 3, 5]
131
+ ```
132
+
133
+ ### `contains`
134
+
135
+ Advances the iterable until it finds the element, returning `true` if it's found and `false` otherwise.
136
+
137
+ ```typescript
138
+ const iterable = [1, 2, 3, 4, 5];
139
+ console.log(contains(iterable, 3));
140
+ // Output: true
141
+ ```
142
+
143
+ ### `count`
144
+
145
+ Consumes the iterable and returns the number of elements.
146
+
147
+ ```typescript
148
+ const iterable = [1, 2, 3, 4, 5];
149
+ console.log(count(iterable));
150
+ // Output: 5
151
+ ```
152
+
153
+ ### `cycle`
154
+
155
+ Creates an infinite iterable by cycling through the elements of the input iterable.
156
+
157
+ ```typescript
158
+ const iterable = cycle([1, 2, 3]);
159
+ for (const element of iterable) {
160
+ console.log(element);
161
+ // Output: 1, 2, 3, 1, 2, 3, 1, 2, 3, ...
162
+ }
163
+ ```
164
+
165
+ ### `difference`
166
+
167
+ Creates an iterable with the elements of the first iterable that are not in the second iterable.
168
+
169
+ ```typescript
170
+ const first = [1, 2, 3, 4, 5];
171
+ const second = [3, 4, 5, 6, 7];
172
+ console.log([...difference(first, second)]);
173
+ // Output: [1, 2]
174
+ ```
175
+
176
+ ### `drop`
177
+
178
+ Advances the iterable by `count` elements from the iterable.
179
+
180
+ ```typescript
181
+ const iterable = drop(iterator, 2);
182
+ console.log([...iterable]);
183
+ // Output: [3, 4, 5]
184
+ ```
185
+
186
+ ### `dropLast`
187
+
188
+ Consumes the iterable, creating a new iterator without the last `count` elements from the iterable.
189
+
190
+ ```typescript
191
+ const iterable = dropLast([1, 2, 3, 4, 5], 2);
192
+ console.log([...iterable]);
193
+ // Output: [1, 2, 3]
194
+ ```
195
+
196
+ ### `dropWhile`
197
+
198
+ Creates a new iterator without the elements that satisfy the specified test.
199
+
200
+ ```typescript
201
+ const iterable = dropWhile([1, 2, 3, 4, 5], (value) => value < 3);
202
+ console.log([...iterable]);
203
+ // Output: [3, 4, 5]
204
+ ```
205
+
206
+ ### `empty`
207
+
208
+ Creates an empty iterator.
209
+
210
+ ```typescript
211
+ const iterable = empty();
212
+ console.log([...iterable]);
213
+ // Output: []
214
+ ```
215
+
216
+ ### `enumerate`
217
+
218
+ Creates a new iterable that yields the index and value of each element.
219
+
220
+ ```typescript
221
+ const iterable = ['a', 'b', 'c'];
222
+ for (const [index, value] of enumerate(iterable)) {
223
+ console.log(`Index: ${index}, Value: ${value}`);
224
+ // Output: Index: 0, Value: a
225
+ // Output: Index: 1, Value: b
226
+ // Output: Index: 2, Value: c
227
+ }
228
+ ```
229
+
230
+ ### `every`
231
+
232
+ Tests whether all elements in the iterable pass the test implemented by the provided function.
233
+
234
+ ```typescript
235
+ const iterable = [1, 2, 3, 4, 5];
236
+ console.log(every(iterable, (value) => value < 10));
237
+ // Output: true
238
+ console.log(every(iterable, (value) => value < 3));
239
+ // Output: false
240
+ ```
241
+
242
+ ### `filter`
243
+
244
+ Creates an iterable with the elements that pass the test implemented by the provided function.
245
+
246
+ ```typescript
247
+ const iterable = [1, 2, 3, 4, 5];
248
+ console.log([...filter(iterable, (value) => value % 2 === 0)]);
249
+ // Output: [2, 4]
250
+ ```
251
+
252
+ ### `find`
253
+
254
+ Advances the iterable until it finds the element, returning it if it's found and `undefined` otherwise.
255
+
256
+ ```typescript
257
+ const iterable = [1, 2, 3, 4, 5];
258
+ console.log(find(iterable, (value) => value % 2 === 0));
259
+ // Output: 2
260
+ ```
261
+
262
+ ### `findIndex`
263
+
264
+ Advances the iterable until it finds the element, returning its index if it's found and `-1` otherwise.
265
+
266
+ ```typescript
267
+ const iterable = [1, 2, 3, 4, 5];
268
+ console.log(findIndex(iterable, (value) => value % 2 === 0));
269
+ // Output: 1
270
+ ```
271
+
272
+ ### `first`
273
+
274
+ Consumes the first element of the iterable, returning it if it's found and `undefined` otherwise.
275
+
276
+ ```typescript
277
+ const iterable = [1, 2, 3, 4, 5];
278
+ console.log(first(iterable));
279
+ // Output: 1
280
+ ```
281
+
282
+ ### `flat`
283
+
284
+ Creates an iterable that yields the elements of each iterable in the input iterable.
285
+
286
+ ```typescript
287
+ const iterable = flat([[1, 2], [3, 4], [5, 6]]);
288
+ console.log([...iterable]);
289
+ // Output: [1, 2, 3, 4, 5, 6]
290
+ ```
291
+
292
+ ### `flatMap`
293
+
294
+ Creates an iterable that yields the elements of each iterable returned by the provided function on each element of the input iterable.
295
+
296
+ ```typescript
297
+ const iterable = [1, 2, 3];
298
+ console.log([...flatMap(iterable, (value) => [value, value * 2])]);
299
+ // Output: [1, 2, 2, 4, 3, 6]
300
+ ```
301
+
302
+ ### `forEach`
303
+
304
+ Executes a provided function once for each iterable element.
305
+
306
+ ```typescript
307
+ const iterable = [1, 2, 3, 4, 5];
308
+ forEach(iterable, (value) => console.log(value));
309
+ // Output: 1, 2, 3, 4, 5
310
+ ```
311
+
312
+ ### `from`
313
+
314
+ Resolves an iterable from an iterable or iterator-like object.
315
+
316
+ ```typescript
317
+ const iterable = from([1, 2, 3, 4, 5]);
318
+ for (const element of iterable) {
319
+ console.log(element);
320
+ // Output: 1, 2, 3, 4, 5
321
+ }
322
+ ```
323
+
324
+ ### `indexOf`
325
+
326
+ Advances the iterable until it finds the element, returning its index if it's found and `-1` otherwise.
327
+
328
+ ```typescript
329
+ const iterable = [1, 2, 3, 4, 5];
330
+ console.log(indexOf(iterable, 3));
331
+ // Output: 2
332
+ ```
333
+
334
+ ### `intersect`
335
+
336
+ Creates an iterable with the elements that are in both input iterables.
337
+
338
+ ```typescript
339
+ const iterable = intersect([1, 2, 3, 4, 5], [3, 4, 5, 6, 7]);
340
+ console.log([...iterable]);
341
+ // Output: [3, 4, 5]
342
+ ```
343
+
344
+ ### `isEmpty`
345
+
346
+ Advances the iterable once, returning `true` if it's exhausted and `false` otherwise.
347
+
348
+ ```typescript
349
+ console.log(isEmpty([]));
350
+ // Output: true
351
+
352
+ console.log(isEmpty([1, 2, 3, 4, 5]));
353
+ // Output: false
354
+ ```
355
+
356
+ ### `last`
357
+
358
+ Consumes the iterable until it's exhausted, returning the last element.
359
+
360
+ ```typescript
361
+ const iterable = [1, 2, 3, 4, 5];
362
+ console.log(last(iterable));
363
+ // Output: 5
364
+ ```
365
+
366
+ ### `map`
367
+
368
+ Creates an iterable with the results of calling a provided function on each element.
369
+
370
+ ```typescript
371
+ const iterable = [1, 2, 3, 4, 5];
372
+ console.log([...map(iterable, (value) => value * 2)]);
373
+ // Output: [2, 4, 6, 8, 10]
374
+ ```
375
+
376
+ ### `max`
377
+
378
+ Consumes the iterable and returns the highest number element. If the iterable is empty, or contains only non-number values, it returns `null`.
379
+
380
+ ```typescript
381
+ const iterable = [1, 2, 3, 4, 5];
382
+ console.log(max(iterable));
383
+ // Output: 5
384
+ ```
385
+
386
+ ### `min`
387
+
388
+ Consumes the iterable and returns the lowest number element. If the iterable is empty, or contains only non-number values, it returns `null`.
389
+
390
+ ```typescript
391
+ const iterable = [1, 2, 3, 4, 5];
392
+ console.log(min(iterable));
393
+ // Output: 1
394
+ ```
395
+
396
+ ### `partition`
397
+
398
+ Consumes the iterable and creates two arrays, one with the elements that pass the test and another with the elements that don't.
399
+
400
+ ```typescript
401
+ const iterable = [1, 2, 3, 4, 5];
402
+ const [even, odd] = partition(iterable, (value) => value % 2 === 0);
403
+
404
+ console.log(even);
405
+ // Output: [2, 4]
406
+
407
+ console.log(odd);
408
+ // Output: [1, 3, 5]
409
+ ```
410
+
411
+ ### `peekable`
412
+
413
+ Creates an iterator that allows you to peek at the next element without advancing the iterator.
414
+
415
+ ```typescript
416
+ const iterable = [1, 2, 3, 4, 5];
417
+ const peekableIterator = peekable(iterable);
418
+
419
+ console.log(peekableIterator.next());
420
+ // Output: { value: 1, done: false }
421
+
422
+ console.log(peekableIterator.peek());
423
+ // Output: { value: 2, done: false }
424
+
425
+ console.log(peekableIterator.next());
426
+ // Output: { value: 2, done: false }
427
+
428
+ console.log(peekableIterator.next());
429
+ // Output: { value: 3, done: false }
430
+ ```
431
+
432
+ ### `prepend`
433
+
434
+ Creates an iterator with the provided iterables prepended to the first iterable.
435
+
436
+ ```typescript
437
+ console.log([...prepend([3, 4, 5], [1], [2])]);
438
+ // Output: [1, 2, 3, 4, 5]
439
+ ```
440
+
441
+ ### `product`
442
+
443
+ Consumes the iterable and returns the product of all the elements. If the iterable is empty, it returns `1`.
444
+
445
+ ```typescript
446
+ const iterable = [1, 2, 3, 4, 5];
447
+ console.log(product(iterable));
448
+ // Output: 120
449
+ ```
450
+
451
+ ### `range`
452
+
453
+ Creates an iterable with the numbers from `start` to `stop` (exclusive) with an optional step.
454
+
455
+ ```typescript
456
+ const iterable = range(0, 5);
457
+ console.log([...iterable]);
458
+ // Output: [0, 1, 2, 3, 4]
459
+ ```
460
+
461
+ If `start` is greater than `stop`, the iterable will count down with a negative step.
462
+
463
+ ```typescript
464
+ const iterable = range(5, 0);
465
+ console.log([...iterable]);
466
+ // Output: [5, 4, 3, 2, 1]
467
+ ```
468
+
469
+ You can also specify a step.
470
+
471
+ ```typescript
472
+ const iterable = range(0, 5, 2);
473
+ console.log([...iterable]);
474
+ // Output: [0, 2, 4]
475
+ ```
476
+
477
+ ### `reduce`
478
+
479
+ Consumes the iterable and reduces it to the reducer function's result.
480
+
481
+ ```typescript
482
+ const iterable = [1, 2, 3, 4, 5];
483
+ console.log(reduce(iterable, (accumulator, currentValue) => accumulator + currentValue));
484
+ // Output: 15
485
+ ```
486
+
487
+ ### `repeat`
488
+
489
+ Creates an iterable that repeats the input iterable `count` times.
490
+
491
+ ```typescript
492
+ const iterator = repeat('Hello, world!', 3);
493
+ console.log([...iterator]);
494
+ // Output: ['Hello, world!', 'Hello, world!', 'Hello, world!']
495
+ ```
496
+
497
+ ### `reverse`
498
+
499
+ Consumes the iterable and returns a new iterable with the elements in reverse order.
500
+
501
+ ```typescript
502
+ console.log([...reverse([1, 2, 3, 4, 5])]);
503
+ // Output: [5, 4, 3, 2, 1]
504
+
505
+ console.log([...reverse('hello')]);
506
+ // Output: ['o', 'l', 'l', 'e', 'h']
507
+ ```
508
+
509
+ ### `slice`
510
+
511
+ Produces an iterable with the elements from the `start` index to the `end` index (exclusive).
512
+
513
+ ```typescript
514
+ const iterable = [1, 2, 3, 4, 5];
515
+ console.log([...slice(iterable, 1, 3)]);
516
+ // Output: [2, 3]
517
+ ```
518
+
519
+ ```typescript
520
+ const iterable = [1, 2, 3, 4, 5];
521
+ console.log([...slice(iterable, -2)]);
522
+ // Output: [4, 5]
523
+ ```
524
+
525
+ ```typescript
526
+ const iterable = [1, 2, 3, 4, 5];
527
+ console.log([...slice(iterable, 2)]);
528
+ // Output: [3, 4, 5]
529
+ ```
530
+
531
+ ```typescript
532
+ const iterable = [1, 2, 3, 4, 5];
533
+ console.log([...slice(iterable, 2, -1)]);
534
+ // Output: [3, 4]
535
+ ```
536
+
537
+ ```typescript
538
+ const iterable = [1, 2, 3, 4, 5];
539
+ console.log([...slice(iterable, -2, -1)]);
540
+ // Output: [4]
541
+ ```
542
+
543
+ ```typescript
544
+ const iterable = [1, 2, 3, 4, 5];
545
+ console.log([...slice(iterable, 2, 1)]);
546
+ // Output: []
547
+ ```
548
+
549
+ ### `some`
550
+
551
+ Advances the iterable until it finds a matching element, returning `true` if it's found and `false` otherwise.
552
+
553
+ ```typescript
554
+ const iterable = [1, 2, 3, 4, 5];
555
+ console.log(some(iterable, (value) => value % 2 === 0));
556
+ // Output: true
557
+ ```
558
+
559
+ ```typescript
560
+ const iterable = [1, 2, 3, 4, 5];
561
+ console.log(some(iterable, (value) => value % 6 === 0));
562
+ // Output: false
563
+ ```
564
+
565
+ ### `sorted`
566
+
567
+ Consumes the iterable and returns a new iterable with the elements sorted.
568
+
569
+ ```typescript
570
+ const iterable = [5, 3, 1, 4, 2];
571
+ console.log([...sorted(iterable)]);
572
+ // Output: [1, 2, 3, 4, 5]
573
+ ```
574
+
575
+ ### `starMap`
576
+
577
+ Creates an iterable with the results of calling a provided function on each element of the input iterables as the function's parameters.
578
+
579
+ ```typescript
580
+ const iterable = [[1, 2], [3, 4], [5, 6]];
581
+ console.log([...starMap(iterable, (a, b) => a + b)]);
582
+ // Output: [3, 7, 11]
583
+ ```
584
+
585
+ ### `sum`
586
+
587
+ Consumes the iterable and returns the sum of all the elements.
588
+
589
+ ```typescript
590
+ const iterable = [1, 2, 3, 4, 5];
591
+ console.log(sum(iterable));
592
+ // Output: 15
593
+ ```
594
+
595
+ ### `take`
596
+
597
+ Creates an iterable with the first `count` elements.
598
+
599
+ ```typescript
600
+ const iterable = [1, 2, 3, 4, 5];
601
+ console.log([...take(iterable, 2)]);
602
+ // Output: [1, 2]
603
+ ```
604
+
605
+ ### `takeLast`
606
+
607
+ Consumes the iterable and returns a new iterable with the last `count` elements.
608
+
609
+ ```typescript
610
+ const iterable = [1, 2, 3, 4, 5];
611
+ console.log([...takeLast(iterable, 2)]);
612
+ // Output: [4, 5]
613
+ ```
614
+
615
+ ### `takeWhile`
616
+
617
+ Alias of [`filter`](#filter).
618
+
619
+ ### `tee`
620
+
621
+ Creates `count` independent iterators from the input iterable.
622
+
623
+ ```typescript
624
+ const iterable = [1, 2, 3, 4, 5];
625
+ const [iter1, iter2] = tee(iterable, 2);
626
+
627
+ console.log([...iter1]);
628
+ // Output: [1, 2, 3, 4, 5]
629
+
630
+ console.log([...iter2]);
631
+ // Output: [1, 2, 3, 4, 5]
632
+ ```
633
+
634
+ ### `toArray`
635
+
636
+ Consumes the iterable and returns an array with all the elements.
637
+
638
+ ```typescript
639
+ const array = [1, 2, 3, 4, 5];
640
+ console.log(toArray(array));
641
+ // Output: [1, 2, 3, 4, 5]
642
+ ```
643
+
644
+ ```typescript
645
+ const set = new Set([1, 2, 3, 4, 5]);
646
+ console.log(toArray(set));
647
+ // Output: [1, 2, 3, 4, 5]
648
+ ```
649
+
650
+ ```typescript
651
+ const map = new Map([['a', 1], ['b', 2], ['c', 3]]);
652
+ console.log(toArray(map));
653
+ // Output: [['a', 1], ['b', 2], ['c', 3]]
654
+ ```
655
+
656
+ ```typescript
657
+ const string = 'hello';
658
+ console.log(toArray(string));
659
+ // Output: ['h', 'e', 'l', 'l', 'o']
660
+ ```
661
+
662
+ ### `toIterableIterator`
663
+
664
+ Creates an iterable iterator from an iterable or iterator-like object.
665
+
666
+ ```typescript
667
+ const array = [1, 2, 3, 4, 5];
668
+ console.log([...toIterableIterator(array)]);
669
+ // Output: [1, 2, 3, 4, 5]
670
+ ```
671
+
672
+ ```typescript
673
+ const set = new Set([1, 2, 3, 4, 5]);
674
+ console.log([...toIterableIterator(set)]);
675
+ // Output: [1, 2, 3, 4, 5]
676
+ ```
677
+
678
+ ```typescript
679
+ const map = new Map([['a', 1], ['b', 2], ['c', 3]]);
680
+ console.log([...toIterableIterator(map)]);
681
+ // Output: [['a', 1], ['b', 2], ['c', 3]]
682
+ ```
683
+
684
+ ```typescript
685
+ const string = 'hello';
686
+ console.log([...toIterableIterator(string)]);
687
+ // Output: ['h', 'e', 'l', 'l', 'o']
688
+ ```
689
+
690
+ ### `union`
691
+
692
+ Creates an iterable with the elements that are in either input iterable.
693
+
694
+ ```typescript
695
+ const iterable1 = [1, 2, 3];
696
+ const iterable2 = [3, 4, 5];
697
+ console.log([...union(iterable1, iterable2)]);
698
+ // Output: [1, 2, 3, 4, 5]
699
+ ```
700
+
701
+ ### `unique`
702
+
703
+ Creates an iterable with the unique elements of the input iterable. Under the hood, it calls [`union`](#union) with the iterable itself.
704
+
705
+ ```typescript
706
+ const iterable = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5];
707
+ console.log([...unique(iterable)]);
708
+ // Output: [1, 2, 3, 4, 5]
709
+ ```
710
+
711
+ ### `unzip`
712
+
713
+ Creates an array for each element of the input iterable, transposing the input iterable. The opposite of [`zip`](#zip).
714
+
715
+ ```typescript
716
+ const iterable = [[1, 'a'], [2, 'b'], [3, 'c']];
717
+ const [numbers, letters] = unzip(iterable);
718
+
719
+ console.log(numbers);
720
+ // Output: [1, 2, 3]
721
+
722
+ console.log(letters);
723
+ // Output: ['a', 'b', 'c']
724
+ ```
725
+
726
+ ### `zip`
727
+
728
+ Creates an iterable with the elements of the input iterables zipped together. The opposite of [`unzip`](#unzip).
729
+
730
+ ```typescript
731
+ const iterable1 = [1, 2, 3];
732
+ const iterable2 = ['a', 'b', 'c'];
733
+ const iterable3 = [true, false, true];
734
+ console.log(zip(iterable1, iterable2, iterable3));
735
+ // Output: [
736
+ // [1, 'a', true],
737
+ // [2, 'b', false],
738
+ // [3, 'c', true]
739
+ // ]
740
+ ```
741
+
742
+ ## Buy us some doughnuts
743
+
744
+ Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!
745
+
746
+ We accept donations through Open Collective, Ko-fi, PayPal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.
747
+
748
+ | Donate With | Address |
749
+ | :-------------: | :-------------------------------------------------: |
750
+ | Open Collective | [Click Here](https://sapphirejs.dev/opencollective) |
751
+ | Ko-fi | [Click Here](https://sapphirejs.dev/kofi) |
752
+ | Patreon | [Click Here](https://sapphirejs.dev/patreon) |
753
+ | PayPal | [Click Here](https://sapphirejs.dev/paypal) |
754
+
755
+ ## Contributors
756
+
757
+ Please make sure to read the [Contributing Guide][contributing] before making a pull request.
758
+
759
+ Thank you to all the people who already contributed to Sapphire!
760
+
761
+ <a href="https://github.com/sapphiredev/utilities/graphs/contributors">
762
+ <img src="https://contrib.rocks/image?repo=sapphiredev/utilities" />
763
+ </a>
764
+
765
+ [contributing]: https://github.com/sapphiredev/.github/blob/main/.github/CONTRIBUTING.md