@daiso-tech/core 0.1.4 → 0.2.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 (351) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/_shared/utilities.js +19 -0
  3. package/dist/cjs/_shared/utilities.js.map +1 -0
  4. package/dist/cjs/collection/_shared.js +4 -2
  5. package/dist/cjs/collection/_shared.js.map +1 -1
  6. package/dist/cjs/collection/async-iterable-collection/_shared/_module.js +1 -1
  7. package/dist/cjs/collection/async-iterable-collection/_shared/_module.js.map +1 -1
  8. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js +8 -7
  9. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
  10. package/dist/cjs/collection/async-iterable-collection/_shared/{async-chunk-whilte-iterable.js → async-chunk-while-iterable.js} +14 -16
  11. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -0
  12. package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js +1 -2
  13. package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
  14. package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js +3 -6
  15. package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
  16. package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +19 -18
  17. package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
  18. package/dist/cjs/collection/async-iterable-collection/_shared/async-entries-iterable.js +1 -8
  19. package/dist/cjs/collection/async-iterable-collection/_shared/async-entries-iterable.js.map +1 -1
  20. package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js +6 -9
  21. package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
  22. package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +3 -6
  23. package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
  24. package/dist/cjs/collection/async-iterable-collection/_shared/async-group-by-iterable.js +12 -13
  25. package/dist/cjs/collection/async-iterable-collection/_shared/async-group-by-iterable.js.map +1 -1
  26. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +5 -12
  27. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
  28. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +5 -12
  29. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
  30. package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js +3 -6
  31. package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
  32. package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js +1 -2
  33. package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
  34. package/dist/cjs/collection/async-iterable-collection/_shared/async-pad-end-iterable.js +1 -4
  35. package/dist/cjs/collection/async-iterable-collection/_shared/async-pad-end-iterable.js.map +1 -1
  36. package/dist/cjs/collection/async-iterable-collection/_shared/async-pad-start-iterable.js +1 -4
  37. package/dist/cjs/collection/async-iterable-collection/_shared/async-pad-start-iterable.js.map +1 -1
  38. package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js +12 -19
  39. package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
  40. package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js +2 -3
  41. package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
  42. package/dist/cjs/collection/async-iterable-collection/_shared/async-reverse-iterable.js +3 -10
  43. package/dist/cjs/collection/async-iterable-collection/_shared/async-reverse-iterable.js.map +1 -1
  44. package/dist/cjs/collection/async-iterable-collection/_shared/async-shuffle-iterable.js +4 -2
  45. package/dist/cjs/collection/async-iterable-collection/_shared/async-shuffle-iterable.js.map +1 -1
  46. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js +4 -9
  47. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
  48. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +5 -12
  49. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
  50. package/dist/cjs/collection/async-iterable-collection/_shared/async-slice-iterable.js +2 -4
  51. package/dist/cjs/collection/async-iterable-collection/_shared/async-slice-iterable.js.map +1 -1
  52. package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js +4 -11
  53. package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
  54. package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js +7 -9
  55. package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
  56. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js +4 -9
  57. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
  58. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js +6 -9
  59. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
  60. package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js +1 -2
  61. package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
  62. package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js +2 -5
  63. package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
  64. package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js +6 -9
  65. package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
  66. package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js +1 -2
  67. package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
  68. package/dist/cjs/collection/async-iterable-collection/_shared/async-zip-iterable.js.map +1 -1
  69. package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js +173 -228
  70. package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
  71. package/dist/cjs/collection/iterable-collection/_shared/_module.js +1 -1
  72. package/dist/cjs/collection/iterable-collection/_shared/_module.js.map +1 -1
  73. package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js +8 -7
  74. package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
  75. package/dist/cjs/collection/iterable-collection/_shared/{chunk-whilte-iterable.js → chunk-while-iterable.js} +12 -14
  76. package/dist/cjs/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -0
  77. package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js +1 -2
  78. package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
  79. package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js +3 -6
  80. package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
  81. package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js +26 -20
  82. package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
  83. package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js +2 -9
  84. package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
  85. package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js +3 -6
  86. package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
  87. package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js +3 -6
  88. package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
  89. package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js +10 -12
  90. package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
  91. package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js +3 -6
  92. package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
  93. package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js +3 -6
  94. package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
  95. package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js +3 -6
  96. package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
  97. package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js +1 -2
  98. package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
  99. package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js +2 -6
  100. package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
  101. package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js +2 -6
  102. package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
  103. package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js +9 -11
  104. package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
  105. package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js +2 -3
  106. package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
  107. package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js +4 -12
  108. package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
  109. package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js +5 -4
  110. package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
  111. package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js +4 -9
  112. package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
  113. package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js +3 -6
  114. package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
  115. package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js +3 -6
  116. package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
  117. package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js +4 -11
  118. package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
  119. package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js +1 -2
  120. package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
  121. package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js +7 -9
  122. package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
  123. package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js +4 -9
  124. package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
  125. package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js +3 -6
  126. package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
  127. package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js +1 -2
  128. package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
  129. package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js +3 -6
  130. package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
  131. package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js +3 -6
  132. package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
  133. package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js +1 -2
  134. package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
  135. package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js +1 -2
  136. package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
  137. package/dist/cjs/collection/iterable-collection/iterable-collection.js +161 -251
  138. package/dist/cjs/collection/iterable-collection/iterable-collection.js.map +1 -1
  139. package/dist/cjs/collection/list-collection/list-collection.js +213 -299
  140. package/dist/cjs/collection/list-collection/list-collection.js.map +1 -1
  141. package/dist/cjs/contracts/collection/_shared.js +17 -10
  142. package/dist/cjs/contracts/collection/_shared.js.map +1 -1
  143. package/dist/esm/_shared/utilities.js +15 -0
  144. package/dist/esm/_shared/utilities.js.map +1 -0
  145. package/dist/esm/collection/_shared.js +4 -2
  146. package/dist/esm/collection/_shared.js.map +1 -1
  147. package/dist/esm/collection/async-iterable-collection/_shared/_module.js +1 -1
  148. package/dist/esm/collection/async-iterable-collection/_shared/_module.js.map +1 -1
  149. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js +8 -7
  150. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
  151. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js +37 -0
  152. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -0
  153. package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js +1 -2
  154. package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
  155. package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js +3 -6
  156. package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
  157. package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +19 -18
  158. package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
  159. package/dist/esm/collection/async-iterable-collection/_shared/async-entries-iterable.js +1 -8
  160. package/dist/esm/collection/async-iterable-collection/_shared/async-entries-iterable.js.map +1 -1
  161. package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js +6 -9
  162. package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
  163. package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +3 -6
  164. package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
  165. package/dist/esm/collection/async-iterable-collection/_shared/async-group-by-iterable.js +12 -13
  166. package/dist/esm/collection/async-iterable-collection/_shared/async-group-by-iterable.js.map +1 -1
  167. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +6 -13
  168. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
  169. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +6 -13
  170. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
  171. package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js +3 -6
  172. package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
  173. package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js +1 -2
  174. package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
  175. package/dist/esm/collection/async-iterable-collection/_shared/async-pad-end-iterable.js +1 -4
  176. package/dist/esm/collection/async-iterable-collection/_shared/async-pad-end-iterable.js.map +1 -1
  177. package/dist/esm/collection/async-iterable-collection/_shared/async-pad-start-iterable.js +1 -4
  178. package/dist/esm/collection/async-iterable-collection/_shared/async-pad-start-iterable.js.map +1 -1
  179. package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js +13 -20
  180. package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
  181. package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js +2 -3
  182. package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
  183. package/dist/esm/collection/async-iterable-collection/_shared/async-reverse-iterable.js +3 -10
  184. package/dist/esm/collection/async-iterable-collection/_shared/async-reverse-iterable.js.map +1 -1
  185. package/dist/esm/collection/async-iterable-collection/_shared/async-shuffle-iterable.js +4 -2
  186. package/dist/esm/collection/async-iterable-collection/_shared/async-shuffle-iterable.js.map +1 -1
  187. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js +4 -9
  188. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
  189. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +6 -13
  190. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
  191. package/dist/esm/collection/async-iterable-collection/_shared/async-slice-iterable.js +2 -4
  192. package/dist/esm/collection/async-iterable-collection/_shared/async-slice-iterable.js.map +1 -1
  193. package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js +4 -11
  194. package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
  195. package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js +7 -9
  196. package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
  197. package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js +4 -9
  198. package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
  199. package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js +6 -9
  200. package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
  201. package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js +1 -2
  202. package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
  203. package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js +2 -5
  204. package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
  205. package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js +6 -9
  206. package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
  207. package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js +1 -2
  208. package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
  209. package/dist/esm/collection/async-iterable-collection/_shared/async-zip-iterable.js.map +1 -1
  210. package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js +174 -229
  211. package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
  212. package/dist/esm/collection/iterable-collection/_shared/_module.js +1 -1
  213. package/dist/esm/collection/iterable-collection/_shared/_module.js.map +1 -1
  214. package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js +8 -7
  215. package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
  216. package/dist/esm/collection/iterable-collection/_shared/{chunk-whilte-iterable.js → chunk-while-iterable.js} +12 -14
  217. package/dist/esm/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -0
  218. package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js +1 -2
  219. package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
  220. package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js +3 -6
  221. package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
  222. package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js +24 -18
  223. package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
  224. package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js +3 -10
  225. package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
  226. package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js +3 -6
  227. package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
  228. package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js +3 -6
  229. package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
  230. package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js +10 -12
  231. package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
  232. package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js +3 -6
  233. package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
  234. package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js +3 -6
  235. package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
  236. package/dist/esm/collection/iterable-collection/_shared/map-iterable.js +3 -6
  237. package/dist/esm/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
  238. package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js +1 -2
  239. package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
  240. package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js +2 -6
  241. package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
  242. package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js +2 -6
  243. package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
  244. package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js +9 -11
  245. package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
  246. package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js +2 -3
  247. package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
  248. package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js +4 -12
  249. package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
  250. package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js +5 -4
  251. package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
  252. package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js +4 -9
  253. package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
  254. package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js +3 -6
  255. package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
  256. package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js +3 -6
  257. package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
  258. package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js +4 -11
  259. package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
  260. package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js +1 -2
  261. package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
  262. package/dist/esm/collection/iterable-collection/_shared/split-iterable.js +7 -9
  263. package/dist/esm/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
  264. package/dist/esm/collection/iterable-collection/_shared/take-iterable.js +4 -9
  265. package/dist/esm/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
  266. package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js +3 -6
  267. package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
  268. package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js +1 -2
  269. package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
  270. package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js +3 -6
  271. package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
  272. package/dist/esm/collection/iterable-collection/_shared/update-iterable.js +3 -6
  273. package/dist/esm/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
  274. package/dist/esm/collection/iterable-collection/_shared/when-iterable.js +1 -2
  275. package/dist/esm/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
  276. package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js +1 -2
  277. package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
  278. package/dist/esm/collection/iterable-collection/iterable-collection.js +162 -252
  279. package/dist/esm/collection/iterable-collection/iterable-collection.js.map +1 -1
  280. package/dist/esm/collection/list-collection/list-collection.js +214 -300
  281. package/dist/esm/collection/list-collection/list-collection.js.map +1 -1
  282. package/dist/esm/contracts/collection/_shared.js +12 -6
  283. package/dist/esm/contracts/collection/_shared.js.map +1 -1
  284. package/dist/types/_shared/types.d.ts +5 -0
  285. package/dist/types/_shared/utilities.d.ts +3 -0
  286. package/dist/types/collection/async-iterable-collection/_shared/_module.d.ts +1 -1
  287. package/dist/types/collection/async-iterable-collection/_shared/async-chunk-iterable.d.ts +2 -1
  288. package/dist/types/collection/async-iterable-collection/_shared/async-chunk-while-iterable.d.ts +12 -0
  289. package/dist/types/collection/async-iterable-collection/_shared/async-count-by-iterable.d.ts +3 -3
  290. package/dist/types/collection/async-iterable-collection/_shared/async-cross-join-iterable.d.ts +6 -5
  291. package/dist/types/collection/async-iterable-collection/_shared/async-entries-iterable.d.ts +3 -4
  292. package/dist/types/collection/async-iterable-collection/_shared/async-filter-iterable.d.ts +2 -3
  293. package/dist/types/collection/async-iterable-collection/_shared/async-flat-map-iterable.d.ts +1 -2
  294. package/dist/types/collection/async-iterable-collection/_shared/async-group-by-iterable.d.ts +4 -4
  295. package/dist/types/collection/async-iterable-collection/_shared/async-insert-after-iterable.d.ts +4 -4
  296. package/dist/types/collection/async-iterable-collection/_shared/async-insert-before-iterable.d.ts +4 -4
  297. package/dist/types/collection/async-iterable-collection/_shared/async-map-iterable.d.ts +1 -2
  298. package/dist/types/collection/async-iterable-collection/_shared/async-merge-iterable.d.ts +1 -1
  299. package/dist/types/collection/async-iterable-collection/_shared/async-pad-end-iterable.d.ts +2 -1
  300. package/dist/types/collection/async-iterable-collection/_shared/async-pad-start-iterable.d.ts +2 -1
  301. package/dist/types/collection/async-iterable-collection/_shared/async-partion-iterable.d.ts +4 -4
  302. package/dist/types/collection/async-iterable-collection/_shared/async-repeat-iterable.d.ts +2 -1
  303. package/dist/types/collection/async-iterable-collection/_shared/async-reverse-iterable.d.ts +3 -3
  304. package/dist/types/collection/async-iterable-collection/_shared/async-shuffle-iterable.d.ts +2 -1
  305. package/dist/types/collection/async-iterable-collection/_shared/async-skip-iterable.d.ts +1 -2
  306. package/dist/types/collection/async-iterable-collection/_shared/async-skip-until-iterable.d.ts +2 -3
  307. package/dist/types/collection/async-iterable-collection/_shared/async-slice-iterable.d.ts +1 -2
  308. package/dist/types/collection/async-iterable-collection/_shared/async-sliding-iterable.d.ts +1 -2
  309. package/dist/types/collection/async-iterable-collection/_shared/async-split-iterable.d.ts +3 -3
  310. package/dist/types/collection/async-iterable-collection/_shared/async-take-iterable.d.ts +1 -2
  311. package/dist/types/collection/async-iterable-collection/_shared/async-take-until-iterable.d.ts +2 -3
  312. package/dist/types/collection/async-iterable-collection/_shared/async-unique-iterable.d.ts +1 -2
  313. package/dist/types/collection/async-iterable-collection/_shared/async-update-iterable.d.ts +5 -6
  314. package/dist/types/collection/async-iterable-collection/_shared/async-zip-iterable.d.ts +2 -1
  315. package/dist/types/collection/async-iterable-collection/async-iterable-collection.d.ts +56 -54
  316. package/dist/types/collection/iterable-collection/_shared/_module.d.ts +1 -1
  317. package/dist/types/collection/iterable-collection/_shared/{chunk-whilte-iterable.d.ts → chunk-while-iterable.d.ts} +1 -2
  318. package/dist/types/collection/iterable-collection/_shared/count-by-iterable.d.ts +3 -3
  319. package/dist/types/collection/iterable-collection/_shared/cross-join-iterable.d.ts +5 -8
  320. package/dist/types/collection/iterable-collection/_shared/entries-iterable.d.ts +2 -3
  321. package/dist/types/collection/iterable-collection/_shared/filter-iterable.d.ts +1 -2
  322. package/dist/types/collection/iterable-collection/_shared/flat-map-iterable.d.ts +1 -2
  323. package/dist/types/collection/iterable-collection/_shared/group-by-iterable.d.ts +3 -3
  324. package/dist/types/collection/iterable-collection/_shared/insert-after-iterable.d.ts +1 -2
  325. package/dist/types/collection/iterable-collection/_shared/insert-before-iterable.d.ts +1 -2
  326. package/dist/types/collection/iterable-collection/_shared/map-iterable.d.ts +1 -2
  327. package/dist/types/collection/iterable-collection/_shared/partion-iterable.d.ts +1 -2
  328. package/dist/types/collection/iterable-collection/_shared/reverse-iterable.d.ts +1 -2
  329. package/dist/types/collection/iterable-collection/_shared/shuffle-iterable.d.ts +2 -1
  330. package/dist/types/collection/iterable-collection/_shared/skip-iterable.d.ts +1 -2
  331. package/dist/types/collection/iterable-collection/_shared/skip-until-iterable.d.ts +1 -2
  332. package/dist/types/collection/iterable-collection/_shared/slice-iterable.d.ts +1 -2
  333. package/dist/types/collection/iterable-collection/_shared/sliding-iterable.d.ts +1 -2
  334. package/dist/types/collection/iterable-collection/_shared/split-iterable.d.ts +1 -2
  335. package/dist/types/collection/iterable-collection/_shared/take-iterable.d.ts +1 -2
  336. package/dist/types/collection/iterable-collection/_shared/take-until-iterable.d.ts +1 -2
  337. package/dist/types/collection/iterable-collection/_shared/unique-iterable.d.ts +1 -2
  338. package/dist/types/collection/iterable-collection/_shared/update-iterable.d.ts +4 -5
  339. package/dist/types/collection/iterable-collection/_shared/zip-iterable.d.ts +1 -1
  340. package/dist/types/collection/iterable-collection/iterable-collection.d.ts +56 -54
  341. package/dist/types/collection/list-collection/list-collection.d.ts +57 -54
  342. package/dist/types/contracts/collection/_shared.d.ts +14 -158
  343. package/dist/types/contracts/collection/async-collection.contract.d.ts +430 -284
  344. package/dist/types/contracts/collection/collection.contract.d.ts +417 -260
  345. package/package.json +2 -1
  346. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-whilte-iterable.js.map +0 -1
  347. package/dist/cjs/collection/iterable-collection/_shared/chunk-whilte-iterable.js.map +0 -1
  348. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-whilte-iterable.js +0 -39
  349. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-whilte-iterable.js.map +0 -1
  350. package/dist/esm/collection/iterable-collection/_shared/chunk-whilte-iterable.js.map +0 -1
  351. package/dist/types/collection/async-iterable-collection/_shared/async-chunk-whilte-iterable.d.ts +0 -12
@@ -1,8 +1,8 @@
1
- import { CollectionError, ItemNotFoundError, MultipleItemsFoundError, IndexOverflowError, UnexpectedCollectionError, } from "../../contracts/collection/_module";
1
+ import { CollectionError, ItemNotFoundCollectionError, MultipleItemsFoundCollectionError, UnexpectedCollectionError, TypeCollectionError, EmptyCollectionError, } from "../../contracts/collection/_module";
2
2
  import { CrossJoinIterable, SlidingIteralbe, ShuffleIterable, EntriesIterable, FilterIterable, ChunkIterable, ChunkWhileIterable, CollapseIterable, CountByIterable, FlatMapIterable, GroupByIterable, InsertAfterIterable, InsertBeforeIterable, MapIterable, MergeIterable, PadEndIterable, PadStartIterable, PartionIterable, SkipIterable, SkipUntilIterable, SortIterable, SplitIterable, TakeIterable, TakeUntilIterable, TapIterable, UniqueIterable, UpdateIterable, WhenIterable, ZipIterable, ReverseIterable, SliceIterable, RepeatIterable, } from "../../collection/iterable-collection/_shared/_module";
3
+ import { simplifyLazyable } from "../../_shared/utilities";
3
4
  export class IterableCollection {
4
5
  iterable;
5
- static THROW_ON_NUMBER_LIMIT = false;
6
6
  static DEFAULT_CHUNK_SIZE = 1024;
7
7
  static makeCollection = (iterable = []) => {
8
8
  return new IterableCollection(iterable);
@@ -15,8 +15,7 @@ export class IterableCollection {
15
15
  yield* this.iterable;
16
16
  }
17
17
  catch (error) {
18
- if (error instanceof CollectionError ||
19
- error instanceof TypeError) {
18
+ if (error instanceof CollectionError) {
20
19
  throw error;
21
20
  }
22
21
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -25,38 +24,33 @@ export class IterableCollection {
25
24
  toIterator() {
26
25
  return this[Symbol.iterator]();
27
26
  }
28
- entries(throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
29
- return new IterableCollection(new EntriesIterable(this, throwOnIndexOverflow));
27
+ entries() {
28
+ return new IterableCollection(new EntriesIterable(this));
30
29
  }
31
- keys(throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
32
- return this.entries(throwOnIndexOverflow).map(([key]) => key);
30
+ keys() {
31
+ return this.entries().map(([key]) => key);
33
32
  }
34
33
  values() {
35
34
  return this.entries().map(([_key, value]) => value);
36
35
  }
37
- filter(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
38
- return new IterableCollection(new FilterIterable(this, predicateFn, throwOnIndexOverflow));
36
+ filter(predicateFn) {
37
+ return new IterableCollection(new FilterIterable(this, predicateFn));
39
38
  }
40
- reject(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
41
- return this.filter((...arguments_) => !predicateFn(...arguments_), throwOnIndexOverflow);
39
+ reject(predicateFn) {
40
+ return this.filter((...arguments_) => !predicateFn(...arguments_));
42
41
  }
43
- map(mapFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
44
- return new IterableCollection(new MapIterable(this, mapFn, throwOnIndexOverflow));
42
+ map(mapFn) {
43
+ return new IterableCollection(new MapIterable(this, mapFn));
45
44
  }
46
- reduce(settings) {
45
+ reduce(reduceFn, initialValue) {
47
46
  try {
48
- const { reduceFn: reduce, initialValue, throwOnIndexOverflow, } = settings;
49
47
  if (initialValue === undefined && this.isEmpty()) {
50
- throw new TypeError("Reduce of empty array must be inputed a initial value");
48
+ throw new TypeCollectionError("Reduce of empty array must be inputed a initial value");
51
49
  }
52
50
  if (initialValue !== undefined) {
53
51
  let output = initialValue, index = 0;
54
52
  for (const item of this) {
55
- if (throwOnIndexOverflow &&
56
- index === Number.MAX_SAFE_INTEGER) {
57
- throw new IndexOverflowError("Index has overflowed");
58
- }
59
- output = reduce(output, item, index, this);
53
+ output = reduceFn(output, item, index, this);
60
54
  index++;
61
55
  }
62
56
  return output;
@@ -64,11 +58,7 @@ export class IterableCollection {
64
58
  let output = this.firstOrFail(), index = 0, isFirstIteration = true;
65
59
  for (const item of this) {
66
60
  if (!isFirstIteration) {
67
- if (throwOnIndexOverflow &&
68
- index === Number.MAX_SAFE_INTEGER) {
69
- throw new IndexOverflowError("Index has overflowed");
70
- }
71
- output = reduce(output, item, index, this);
61
+ output = reduceFn(output, item, index, this);
72
62
  }
73
63
  isFirstIteration = false;
74
64
  index++;
@@ -76,30 +66,30 @@ export class IterableCollection {
76
66
  return output;
77
67
  }
78
68
  catch (error) {
79
- if (error instanceof CollectionError ||
80
- error instanceof TypeError) {
69
+ if (error instanceof CollectionError) {
81
70
  throw error;
82
71
  }
83
72
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
84
73
  }
85
74
  }
86
- join(settings) {
75
+ join(separator = ",") {
87
76
  try {
88
- return this.reduce({
89
- reduceFn(str, item) {
90
- if (typeof item !== "string") {
91
- throw new TypeError("Item type is invalid must be string");
92
- }
93
- const separator = settings?.seperator ?? ",";
94
- return str + separator + item;
95
- },
96
- throwOnIndexOverflow: settings?.throwOnIndexOverflow ??
97
- IterableCollection.THROW_ON_NUMBER_LIMIT,
98
- });
77
+ let str = null;
78
+ for (const item of this) {
79
+ if (typeof item !== "string") {
80
+ throw new TypeCollectionError("Item type is invalid must be string");
81
+ }
82
+ if (str === null) {
83
+ str = item;
84
+ }
85
+ else {
86
+ str = str + separator + item;
87
+ }
88
+ }
89
+ return str;
99
90
  }
100
91
  catch (error) {
101
- if (error instanceof CollectionError ||
102
- error instanceof TypeError) {
92
+ if (error instanceof CollectionError) {
103
93
  throw error;
104
94
  }
105
95
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -108,33 +98,34 @@ export class IterableCollection {
108
98
  collapse() {
109
99
  return new IterableCollection(new CollapseIterable(this));
110
100
  }
111
- flatMap(mapFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
112
- return new IterableCollection(new FlatMapIterable(this, mapFn, throwOnIndexOverflow));
101
+ flatMap(mapFn) {
102
+ return new IterableCollection(new FlatMapIterable(this, mapFn));
113
103
  }
114
- update(predicateFn, mapFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
115
- return new IterableCollection(new UpdateIterable(this, predicateFn, mapFn, throwOnIndexOverflow));
104
+ change(predicateFn, mapFn) {
105
+ return new IterableCollection(new UpdateIterable(this, predicateFn, mapFn));
116
106
  }
117
- page(settings) {
118
- const { page, pageSize, throwOnIndexOverflow } = settings;
107
+ page(page, pageSize) {
119
108
  if (page < 0) {
120
- return this.skip(page * pageSize, throwOnIndexOverflow).take(pageSize, throwOnIndexOverflow);
109
+ return this.skip(page * pageSize).take(pageSize);
121
110
  }
122
- return this.skip((page - 1) * pageSize, throwOnIndexOverflow).take(page * pageSize, throwOnIndexOverflow);
111
+ return this.skip((page - 1) * pageSize).take(pageSize);
123
112
  }
124
113
  sum() {
125
114
  try {
115
+ if (this.isEmpty()) {
116
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
117
+ }
126
118
  let sum = 0;
127
119
  for (const item of this) {
128
120
  if (typeof item !== "number") {
129
- throw new TypeError("Item type is invalid must be number");
121
+ throw new TypeCollectionError("Item type is invalid must be number");
130
122
  }
131
123
  sum += item;
132
124
  }
133
125
  return sum;
134
126
  }
135
127
  catch (error) {
136
- if (error instanceof CollectionError ||
137
- error instanceof TypeError) {
128
+ if (error instanceof CollectionError) {
138
129
  throw error;
139
130
  }
140
131
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -142,10 +133,13 @@ export class IterableCollection {
142
133
  }
143
134
  average() {
144
135
  try {
136
+ if (this.isEmpty()) {
137
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
138
+ }
145
139
  let size = 0, sum = 0;
146
140
  for (const item of this) {
147
141
  if (typeof item !== "number") {
148
- throw new TypeError("Item type is invalid must be number");
142
+ throw new TypeCollectionError("Item type is invalid must be number");
149
143
  }
150
144
  size++;
151
145
  sum += item;
@@ -153,33 +147,32 @@ export class IterableCollection {
153
147
  return (sum / size);
154
148
  }
155
149
  catch (error) {
156
- if (error instanceof CollectionError ||
157
- error instanceof TypeError) {
150
+ if (error instanceof CollectionError) {
158
151
  throw error;
159
152
  }
160
153
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
161
154
  }
162
155
  }
163
- median(throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
156
+ median() {
164
157
  if (this.isEmpty()) {
165
- return 0;
158
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
166
159
  }
167
- const size = this.size(throwOnIndexOverflow);
160
+ const size = this.size();
168
161
  if (size === 0) {
169
162
  return 0;
170
163
  }
171
164
  const isEven = size % 2 === 0, items = this.map((item) => {
172
165
  if (typeof item !== "number") {
173
- throw new TypeError("Item type is invalid must be number");
166
+ throw new TypeCollectionError("Item type is invalid must be number");
174
167
  }
175
168
  return item;
176
- }, throwOnIndexOverflow)
169
+ })
177
170
  .filter((_item, index) => {
178
171
  if (isEven) {
179
172
  return index === size / 2 || index === size / 2 - 1;
180
173
  }
181
174
  return index === Math.floor(size / 2);
182
- }, throwOnIndexOverflow)
175
+ })
183
176
  .toArray();
184
177
  if (isEven) {
185
178
  const [a, b] = items;
@@ -199,10 +192,13 @@ export class IterableCollection {
199
192
  }
200
193
  min() {
201
194
  try {
195
+ if (this.isEmpty()) {
196
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
197
+ }
202
198
  let min = 0;
203
199
  for (const item of this) {
204
200
  if (typeof item !== "number") {
205
- throw new TypeError("Item type is invalid must be number");
201
+ throw new TypeCollectionError("Item type is invalid must be number");
206
202
  }
207
203
  if (min === 0) {
208
204
  min = item;
@@ -214,8 +210,7 @@ export class IterableCollection {
214
210
  return min;
215
211
  }
216
212
  catch (error) {
217
- if (error instanceof CollectionError ||
218
- error instanceof TypeError) {
213
+ if (error instanceof CollectionError) {
219
214
  throw error;
220
215
  }
221
216
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -223,10 +218,13 @@ export class IterableCollection {
223
218
  }
224
219
  max() {
225
220
  try {
221
+ if (this.isEmpty()) {
222
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
223
+ }
226
224
  let max = 0;
227
225
  for (const item of this) {
228
226
  if (typeof item !== "number") {
229
- throw new TypeError("Item type is invalid must be number");
227
+ throw new TypeCollectionError("Item type is invalid must be number");
230
228
  }
231
229
  if (max === 0) {
232
230
  max = item;
@@ -238,23 +236,19 @@ export class IterableCollection {
238
236
  return max;
239
237
  }
240
238
  catch (error) {
241
- if (error instanceof CollectionError ||
242
- error instanceof TypeError) {
239
+ if (error instanceof CollectionError) {
243
240
  throw error;
244
241
  }
245
242
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
246
243
  }
247
244
  }
248
- percentage(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
245
+ percentage(predicateFn) {
249
246
  try {
250
247
  if (this.isEmpty()) {
251
- return 0;
248
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
252
249
  }
253
250
  let part = 0, total = 0;
254
251
  for (const item of this) {
255
- if (throwOnIndexOverflow && total === Number.MAX_SAFE_INTEGER) {
256
- throw new IndexOverflowError("The total amount has overflowed");
257
- }
258
252
  if (predicateFn(item, total, this)) {
259
253
  part++;
260
254
  }
@@ -263,20 +257,16 @@ export class IterableCollection {
263
257
  return (part / total) * 100;
264
258
  }
265
259
  catch (error) {
266
- if (error instanceof CollectionError ||
267
- error instanceof TypeError) {
260
+ if (error instanceof CollectionError) {
268
261
  throw error;
269
262
  }
270
263
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
271
264
  }
272
265
  }
273
- some(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
266
+ some(predicateFn) {
274
267
  try {
275
268
  let index = 0;
276
269
  for (const item of this) {
277
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
278
- throw new IndexOverflowError("Index has overflowed");
279
- }
280
270
  if (predicateFn(item, index, this)) {
281
271
  return true;
282
272
  }
@@ -285,20 +275,16 @@ export class IterableCollection {
285
275
  return false;
286
276
  }
287
277
  catch (error) {
288
- if (error instanceof CollectionError ||
289
- error instanceof TypeError) {
278
+ if (error instanceof CollectionError) {
290
279
  throw error;
291
280
  }
292
281
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
293
282
  }
294
283
  }
295
- every(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
284
+ every(predicateFn) {
296
285
  try {
297
286
  let index = 0, isTrue = true;
298
287
  for (const item of this) {
299
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
300
- throw new IndexOverflowError("Index has overflowed");
301
- }
302
288
  isTrue &&= predicateFn(item, index, this);
303
289
  if (!isTrue) {
304
290
  break;
@@ -308,30 +294,29 @@ export class IterableCollection {
308
294
  return isTrue;
309
295
  }
310
296
  catch (error) {
311
- if (error instanceof CollectionError ||
312
- error instanceof TypeError) {
297
+ if (error instanceof CollectionError) {
313
298
  throw error;
314
299
  }
315
300
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
316
301
  }
317
302
  }
318
- take(limit, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
319
- return new IterableCollection(new TakeIterable(this, limit, throwOnIndexOverflow));
303
+ take(limit) {
304
+ return new IterableCollection(new TakeIterable(this, limit));
320
305
  }
321
- takeUntil(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
322
- return new IterableCollection(new TakeUntilIterable(this, predicateFn, throwOnIndexOverflow));
306
+ takeUntil(predicateFn) {
307
+ return new IterableCollection(new TakeUntilIterable(this, predicateFn));
323
308
  }
324
- takeWhile(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
325
- return this.takeUntil((...arguments_) => !predicateFn(...arguments_), throwOnIndexOverflow);
309
+ takeWhile(predicateFn) {
310
+ return this.takeUntil((...arguments_) => !predicateFn(...arguments_));
326
311
  }
327
- skip(offset, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
328
- return new IterableCollection(new SkipIterable(this, offset, throwOnIndexOverflow));
312
+ skip(offset) {
313
+ return new IterableCollection(new SkipIterable(this, offset));
329
314
  }
330
- skipUntil(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
331
- return new IterableCollection(new SkipUntilIterable(this, predicateFn, throwOnIndexOverflow));
315
+ skipUntil(predicateFn) {
316
+ return new IterableCollection(new SkipUntilIterable(this, predicateFn));
332
317
  }
333
- skipWhile(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
334
- return this.skipUntil((...arguments_) => !predicateFn(...arguments_), throwOnIndexOverflow);
318
+ skipWhile(predicateFn) {
319
+ return this.skipUntil((...arguments_) => !predicateFn(...arguments_));
335
320
  }
336
321
  when(condition, callback) {
337
322
  return new IterableCollection(new WhenIterable(this, () => condition, callback));
@@ -350,8 +335,7 @@ export class IterableCollection {
350
335
  return callback(this);
351
336
  }
352
337
  catch (error) {
353
- if (error instanceof CollectionError ||
354
- error instanceof TypeError) {
338
+ if (error instanceof CollectionError) {
355
339
  throw error;
356
340
  }
357
341
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -363,30 +347,26 @@ export class IterableCollection {
363
347
  chunk(chunkSize) {
364
348
  return new IterableCollection(new ChunkIterable(this, chunkSize, IterableCollection.makeCollection));
365
349
  }
366
- chunkWhile(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
367
- return new IterableCollection(new ChunkWhileIterable(this, predicateFn, throwOnIndexOverflow, (iterable) => new IterableCollection(iterable)));
350
+ chunkWhile(predicateFn) {
351
+ return new IterableCollection(new ChunkWhileIterable(this, predicateFn, IterableCollection.makeCollection));
368
352
  }
369
- split(chunkAmount, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
370
- return new IterableCollection(new SplitIterable(this, chunkAmount, throwOnIndexOverflow, IterableCollection.makeCollection));
353
+ split(chunkAmount) {
354
+ return new IterableCollection(new SplitIterable(this, chunkAmount, IterableCollection.makeCollection));
371
355
  }
372
- partition(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
373
- return new IterableCollection(new PartionIterable(this, predicateFn, throwOnIndexOverflow, IterableCollection.makeCollection));
356
+ partition(predicateFn) {
357
+ return new IterableCollection(new PartionIterable(this, predicateFn, IterableCollection.makeCollection));
374
358
  }
375
- sliding(settings) {
376
- const { chunkSize, step = chunkSize - 1, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT, } = settings;
377
- return new IterableCollection(new SlidingIteralbe(this, chunkSize, step, throwOnIndexOverflow));
359
+ sliding(chunkSize, step = chunkSize - 1) {
360
+ return new IterableCollection(new SlidingIteralbe(this, chunkSize, step));
378
361
  }
379
- groupBy(settings) {
380
- return new IterableCollection(new GroupByIterable(this, settings?.selectFn, settings?.throwOnIndexOverflow ??
381
- IterableCollection.THROW_ON_NUMBER_LIMIT, (iterable) => new IterableCollection(iterable)));
362
+ groupBy(selectFn) {
363
+ return new IterableCollection(new GroupByIterable(this, selectFn, IterableCollection.makeCollection));
382
364
  }
383
- countBy(settings) {
384
- return new IterableCollection(new CountByIterable(this, settings?.selectFn, settings?.throwOnIndexOverflow ??
385
- IterableCollection.THROW_ON_NUMBER_LIMIT));
365
+ countBy(selectFn) {
366
+ return new IterableCollection(new CountByIterable(this, selectFn));
386
367
  }
387
- unique(settings) {
388
- return new IterableCollection(new UniqueIterable(this, settings?.selectFn, settings?.throwOnIndexOverflow ??
389
- IterableCollection.THROW_ON_NUMBER_LIMIT));
368
+ unique(selectFn) {
369
+ return new IterableCollection(new UniqueIterable(this, selectFn));
390
370
  }
391
371
  difference(iterable, mapFn = (item) => item) {
392
372
  const differenceCollection = new IterableCollection(iterable);
@@ -406,9 +386,8 @@ export class IterableCollection {
406
386
  padEnd(maxLength, fillItems) {
407
387
  return new IterableCollection(new PadEndIterable(this, maxLength, fillItems, IterableCollection.makeCollection));
408
388
  }
409
- slice(settings) {
410
- return new IterableCollection(new SliceIterable(this, settings?.start, settings?.end, settings?.throwOnIndexOverflow ??
411
- IterableCollection.THROW_ON_NUMBER_LIMIT));
389
+ slice(start, end) {
390
+ return new IterableCollection(new SliceIterable(this, start, end));
412
391
  }
413
392
  prepend(iterable) {
414
393
  return new IterableCollection(new MergeIterable(iterable, this));
@@ -416,14 +395,14 @@ export class IterableCollection {
416
395
  append(iterable) {
417
396
  return new IterableCollection(new MergeIterable(this, iterable));
418
397
  }
419
- insertBefore(predicateFn, iterable, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
420
- return new IterableCollection(new InsertBeforeIterable(this, predicateFn, iterable, throwOnIndexOverflow));
398
+ insertBefore(predicateFn, iterable) {
399
+ return new IterableCollection(new InsertBeforeIterable(this, predicateFn, iterable));
421
400
  }
422
- insertAfter(predicateFn, iterable, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
423
- return new IterableCollection(new InsertAfterIterable(this, predicateFn, iterable, throwOnIndexOverflow));
401
+ insertAfter(predicateFn, iterable) {
402
+ return new IterableCollection(new InsertAfterIterable(this, predicateFn, iterable));
424
403
  }
425
- crossJoin(...iterables) {
426
- return new IterableCollection(new CrossJoinIterable(this, iterables, IterableCollection.makeCollection));
404
+ crossJoin(iterable) {
405
+ return new IterableCollection(new CrossJoinIterable(this, iterable, IterableCollection.makeCollection));
427
406
  }
428
407
  zip(iterable) {
429
408
  return new IterableCollection(new ZipIterable(this, iterable));
@@ -431,90 +410,64 @@ export class IterableCollection {
431
410
  sort(comparator) {
432
411
  return new IterableCollection(new SortIterable(this, comparator));
433
412
  }
434
- reverse(settings) {
435
- return new IterableCollection(new ReverseIterable(this, settings?.chunkSize ?? IterableCollection.DEFAULT_CHUNK_SIZE, settings?.throwOnIndexOverflow ??
436
- IterableCollection.THROW_ON_NUMBER_LIMIT, (iterable) => new IterableCollection(iterable)));
413
+ reverse(chunkSize = IterableCollection.DEFAULT_CHUNK_SIZE) {
414
+ return new IterableCollection(new ReverseIterable(this, chunkSize, IterableCollection.makeCollection));
437
415
  }
438
- shuffle() {
439
- return new IterableCollection(new ShuffleIterable(this));
416
+ shuffle(mathRandom = Math.random) {
417
+ return new IterableCollection(new ShuffleIterable(this, mathRandom));
440
418
  }
441
- first(settings) {
419
+ first(predicateFn) {
442
420
  try {
443
- return this.firstOr({
444
- ...settings,
445
- defaultValue: null,
446
- });
421
+ return this.firstOr(null, predicateFn);
447
422
  }
448
423
  catch (error) {
449
- if (error instanceof CollectionError ||
450
- error instanceof TypeError) {
424
+ if (error instanceof CollectionError) {
451
425
  throw error;
452
426
  }
453
427
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
454
428
  }
455
429
  }
456
- firstOr(settings) {
430
+ firstOr(defaultValue, predicateFn = () => true) {
457
431
  try {
458
- const throwOnIndexOverflow = settings.throwOnIndexOverflow ??
459
- IterableCollection.THROW_ON_NUMBER_LIMIT;
460
432
  let index = 0;
461
- const predicateFn = settings.predicateFn ?? (() => true);
462
433
  for (const item of this) {
463
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
464
- throw new IndexOverflowError("Index has overflowed");
465
- }
466
434
  if (predicateFn(item, index, this)) {
467
435
  return item;
468
436
  }
469
437
  index++;
470
438
  }
471
- if (typeof settings.defaultValue === "function") {
472
- const defaultFn = settings.defaultValue;
473
- return defaultFn();
474
- }
475
- return settings.defaultValue;
439
+ return simplifyLazyable(defaultValue);
476
440
  }
477
441
  catch (error) {
478
- if (error instanceof CollectionError ||
479
- error instanceof TypeError) {
442
+ if (error instanceof CollectionError) {
480
443
  throw error;
481
444
  }
482
445
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
483
446
  }
484
447
  }
485
- firstOrFail(settings) {
486
- const item = this.first(settings);
448
+ firstOrFail(predicateFn) {
449
+ const item = this.first(predicateFn);
487
450
  if (item === null) {
488
- throw new ItemNotFoundError("Item was not found");
451
+ throw new ItemNotFoundCollectionError("Item was not found");
489
452
  }
490
453
  return item;
491
454
  }
492
- last(settings) {
455
+ last(predicateFn) {
493
456
  try {
494
- return this.lastOr({
495
- ...settings,
496
- defaultValue: null,
497
- });
457
+ return this.lastOr(null, predicateFn);
498
458
  }
499
459
  catch (error) {
500
- if (error instanceof CollectionError ||
501
- error instanceof TypeError) {
460
+ if (error instanceof CollectionError) {
502
461
  throw error;
503
462
  }
504
463
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
505
464
  }
506
465
  }
507
- lastOr(settings) {
466
+ lastOr(defaultValue, predicateFn = () => true) {
508
467
  try {
509
- const throwOnIndexOverflow = settings.throwOnIndexOverflow ??
510
- IterableCollection.THROW_ON_NUMBER_LIMIT;
511
468
  let index = 0;
512
- const predicateFn = settings.predicateFn ?? (() => true);
513
469
  let matchedItem = null;
514
470
  for (const item of this) {
515
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
516
- throw new IndexOverflowError("Index has overflowed");
517
- }
518
471
  if (predicateFn(item, index, this)) {
519
472
  matchedItem = item;
520
473
  }
@@ -523,124 +476,99 @@ export class IterableCollection {
523
476
  if (matchedItem) {
524
477
  return matchedItem;
525
478
  }
526
- if (typeof settings.defaultValue === "function") {
527
- const defaultFn = settings.defaultValue;
528
- return defaultFn();
529
- }
530
- return settings.defaultValue;
479
+ return simplifyLazyable(defaultValue);
531
480
  }
532
481
  catch (error) {
533
- if (error instanceof CollectionError ||
534
- error instanceof TypeError) {
482
+ if (error instanceof CollectionError) {
535
483
  throw error;
536
484
  }
537
485
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
538
486
  }
539
487
  }
540
- lastOrFail(settings) {
541
- const item = this.last(settings);
488
+ lastOrFail(predicateFn) {
489
+ const item = this.last(predicateFn);
542
490
  if (item === null) {
543
- throw new ItemNotFoundError("Item was not found");
491
+ throw new ItemNotFoundCollectionError("Item was not found");
544
492
  }
545
493
  return item;
546
494
  }
547
- before(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
548
- return this.beforeOr(null, predicateFn, throwOnIndexOverflow);
495
+ before(predicateFn) {
496
+ return this.beforeOr(null, predicateFn);
549
497
  }
550
- beforeOr(defaultValue, predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
498
+ beforeOr(defaultValue, predicateFn) {
551
499
  try {
552
500
  let beforeItem = null, index = 0;
553
501
  for (const item of this) {
554
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
555
- throw new IndexOverflowError("Index has overflowed");
556
- }
557
502
  if (predicateFn(item, index, this) && beforeItem) {
558
503
  return beforeItem;
559
504
  }
560
505
  index++;
561
506
  beforeItem = item;
562
507
  }
563
- if (typeof defaultValue === "function") {
564
- const defaultFn = defaultValue;
565
- return defaultFn();
566
- }
567
- return defaultValue;
508
+ return simplifyLazyable(defaultValue);
568
509
  }
569
510
  catch (error) {
570
- if (error instanceof CollectionError ||
571
- error instanceof TypeError) {
511
+ if (error instanceof CollectionError) {
572
512
  throw error;
573
513
  }
574
514
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
575
515
  }
576
516
  }
577
- beforeOrFail(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
578
- const item = this.before(predicateFn, throwOnIndexOverflow);
517
+ beforeOrFail(predicateFn) {
518
+ const item = this.before(predicateFn);
579
519
  if (item === null) {
580
- throw new ItemNotFoundError("Item was not found");
520
+ throw new ItemNotFoundCollectionError("Item was not found");
581
521
  }
582
522
  return item;
583
523
  }
584
- after(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
585
- return this.afterOr(null, predicateFn, throwOnIndexOverflow);
524
+ after(predicateFn) {
525
+ return this.afterOr(null, predicateFn);
586
526
  }
587
- afterOr(defaultValue, predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
527
+ afterOr(defaultValue, predicateFn) {
588
528
  try {
589
529
  let hasMatched = false, index = 0;
590
530
  for (const item of this) {
591
531
  if (hasMatched) {
592
532
  return item;
593
533
  }
594
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
595
- throw new IndexOverflowError("Index has overflowed");
596
- }
597
534
  hasMatched = predicateFn(item, index, this);
598
535
  index++;
599
536
  }
600
- if (typeof defaultValue === "function") {
601
- const defaultFn = defaultValue;
602
- return defaultFn();
603
- }
604
- return defaultValue;
537
+ return simplifyLazyable(defaultValue);
605
538
  }
606
539
  catch (error) {
607
- if (error instanceof CollectionError ||
608
- error instanceof TypeError) {
540
+ if (error instanceof CollectionError) {
609
541
  throw error;
610
542
  }
611
543
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
612
544
  }
613
545
  }
614
- afterOrFail(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
615
- const item = this.after(predicateFn, throwOnIndexOverflow);
546
+ afterOrFail(predicateFn) {
547
+ const item = this.after(predicateFn);
616
548
  if (item === null) {
617
- throw new ItemNotFoundError("Item was not found");
549
+ throw new ItemNotFoundCollectionError("Item was not found");
618
550
  }
619
551
  return item;
620
552
  }
621
- sole(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
553
+ sole(predicateFn) {
622
554
  try {
623
555
  let index = 0, matchedItem = null;
624
556
  for (const item of this) {
625
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
626
- throw new IndexOverflowError("Index has overflowed");
627
- }
628
557
  if (predicateFn(item, index, this)) {
629
558
  if (matchedItem !== null) {
630
- throw new MultipleItemsFoundError("Multiple items were found");
559
+ throw new MultipleItemsFoundCollectionError("Multiple items were found");
631
560
  }
632
561
  matchedItem = item;
633
562
  }
634
563
  index++;
635
564
  }
636
565
  if (matchedItem === null) {
637
- throw new ItemNotFoundError("Item was not found");
566
+ throw new ItemNotFoundCollectionError("Item was not found");
638
567
  }
639
568
  return matchedItem;
640
569
  }
641
570
  catch (error) {
642
- if (error instanceof CollectionError ||
643
- error instanceof TypeError) {
571
+ if (error instanceof CollectionError) {
644
572
  throw error;
645
573
  }
646
574
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -649,13 +577,10 @@ export class IterableCollection {
649
577
  nth(step) {
650
578
  return this.filter((_item, index) => index % step === 0);
651
579
  }
652
- count(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
580
+ count(predicateFn) {
653
581
  try {
654
582
  let size = 0;
655
583
  for (const item of this) {
656
- if (throwOnIndexOverflow && size === Number.MAX_SAFE_INTEGER) {
657
- throw new IndexOverflowError("Size has overflowed");
658
- }
659
584
  if (predicateFn(item, size, this)) {
660
585
  size++;
661
586
  }
@@ -663,15 +588,14 @@ export class IterableCollection {
663
588
  return size;
664
589
  }
665
590
  catch (error) {
666
- if (error instanceof CollectionError ||
667
- error instanceof TypeError) {
591
+ if (error instanceof CollectionError) {
668
592
  throw error;
669
593
  }
670
594
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
671
595
  }
672
596
  }
673
- size(throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
674
- return this.count(() => true, throwOnIndexOverflow);
597
+ size() {
598
+ return this.count(() => true);
675
599
  }
676
600
  isEmpty() {
677
601
  try {
@@ -681,8 +605,7 @@ export class IterableCollection {
681
605
  return true;
682
606
  }
683
607
  catch (error) {
684
- if (error instanceof CollectionError ||
685
- error instanceof TypeError) {
608
+ if (error instanceof CollectionError) {
686
609
  throw error;
687
610
  }
688
611
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -691,13 +614,10 @@ export class IterableCollection {
691
614
  isNotEmpty() {
692
615
  return !this.isEmpty();
693
616
  }
694
- searchFirst(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
617
+ searchFirst(predicateFn) {
695
618
  try {
696
619
  let index = 0;
697
620
  for (const item of this) {
698
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
699
- throw new IndexOverflowError("Index has overflowed");
700
- }
701
621
  if (predicateFn(item, index, this)) {
702
622
  return index;
703
623
  }
@@ -706,21 +626,17 @@ export class IterableCollection {
706
626
  return -1;
707
627
  }
708
628
  catch (error) {
709
- if (error instanceof CollectionError ||
710
- error instanceof TypeError) {
629
+ if (error instanceof CollectionError) {
711
630
  throw error;
712
631
  }
713
632
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
714
633
  }
715
634
  }
716
- searchLast(predicateFn, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
635
+ searchLast(predicateFn) {
717
636
  try {
718
637
  let index = 0;
719
638
  let matchedIndex = -1;
720
639
  for (const item of this) {
721
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
722
- throw new IndexOverflowError("Index has overflowed");
723
- }
724
640
  if (predicateFn(item, index, this)) {
725
641
  matchedIndex = index;
726
642
  }
@@ -729,27 +645,22 @@ export class IterableCollection {
729
645
  return matchedIndex;
730
646
  }
731
647
  catch (error) {
732
- if (error instanceof CollectionError ||
733
- error instanceof TypeError) {
648
+ if (error instanceof CollectionError) {
734
649
  throw error;
735
650
  }
736
651
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
737
652
  }
738
653
  }
739
- forEach(callback, throwOnIndexOverflow = IterableCollection.THROW_ON_NUMBER_LIMIT) {
654
+ forEach(callback) {
740
655
  try {
741
656
  let index = 0;
742
657
  for (const item of this) {
743
- if (throwOnIndexOverflow && index === Number.MAX_SAFE_INTEGER) {
744
- throw new IndexOverflowError("Index has overflowed");
745
- }
746
658
  callback(item, index, this);
747
659
  index++;
748
660
  }
749
661
  }
750
662
  catch (error) {
751
- if (error instanceof CollectionError ||
752
- error instanceof TypeError) {
663
+ if (error instanceof CollectionError) {
753
664
  throw error;
754
665
  }
755
666
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
@@ -760,8 +671,7 @@ export class IterableCollection {
760
671
  return [...this];
761
672
  }
762
673
  catch (error) {
763
- if (error instanceof CollectionError ||
764
- error instanceof TypeError) {
674
+ if (error instanceof CollectionError) {
765
675
  throw error;
766
676
  }
767
677
  throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);