@daiso-tech/core 0.3.0 → 0.5.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 (439) hide show
  1. package/dist/cjs/_module.js +2 -0
  2. package/dist/cjs/_module.js.map +1 -1
  3. package/dist/cjs/async/_module.js +30 -0
  4. package/dist/cjs/async/_module.js.map +1 -0
  5. package/dist/cjs/async/_shared.js +34 -0
  6. package/dist/cjs/async/_shared.js.map +1 -0
  7. package/dist/cjs/async/abortable/_module.js +18 -0
  8. package/dist/cjs/async/abortable/_module.js.map +1 -0
  9. package/dist/cjs/async/abortable/abortable.js +48 -0
  10. package/dist/cjs/async/abortable/abortable.js.map +1 -0
  11. package/dist/cjs/async/abortable-iterable/_module.js +18 -0
  12. package/dist/cjs/async/abortable-iterable/_module.js.map +1 -0
  13. package/dist/cjs/async/abortable-iterable/abortable-iterable.js +32 -0
  14. package/dist/cjs/async/abortable-iterable/abortable-iterable.js.map +1 -0
  15. package/dist/cjs/async/backof-policies/_module.js +21 -0
  16. package/dist/cjs/async/backof-policies/_module.js.map +1 -0
  17. package/dist/cjs/async/backof-policies/_shared.js +7 -0
  18. package/dist/cjs/async/backof-policies/_shared.js.map +1 -0
  19. package/dist/cjs/async/backof-policies/constant-backoff-policy/_module.js +18 -0
  20. package/dist/cjs/async/backof-policies/constant-backoff-policy/_module.js.map +1 -0
  21. package/dist/cjs/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +19 -0
  22. package/dist/cjs/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
  23. package/dist/cjs/async/backof-policies/exponential-backoff-policy/_module.js +18 -0
  24. package/dist/cjs/async/backof-policies/exponential-backoff-policy/_module.js.map +1 -0
  25. package/dist/cjs/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +23 -0
  26. package/dist/cjs/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
  27. package/dist/cjs/async/backof-policies/linear-backoff-policy/_module.js +18 -0
  28. package/dist/cjs/async/backof-policies/linear-backoff-policy/_module.js.map +1 -0
  29. package/dist/cjs/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +23 -0
  30. package/dist/cjs/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
  31. package/dist/cjs/async/backof-policies/polynomial-backoff-policy/_module.js +18 -0
  32. package/dist/cjs/async/backof-policies/polynomial-backoff-policy/_module.js.map +1 -0
  33. package/dist/cjs/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +23 -0
  34. package/dist/cjs/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
  35. package/dist/cjs/async/delay/_module.js +18 -0
  36. package/dist/cjs/async/delay/_module.js.map +1 -0
  37. package/dist/cjs/async/delay/delay.js +24 -0
  38. package/dist/cjs/async/delay/delay.js.map +1 -0
  39. package/dist/cjs/async/delay-iterable/_module.js +18 -0
  40. package/dist/cjs/async/delay-iterable/_module.js.map +1 -0
  41. package/dist/cjs/async/delay-iterable/delay-iterable.js +36 -0
  42. package/dist/cjs/async/delay-iterable/delay-iterable.js.map +1 -0
  43. package/dist/cjs/async/lazy-promise/_module.js +18 -0
  44. package/dist/cjs/async/lazy-promise/_module.js.map +1 -0
  45. package/dist/cjs/async/lazy-promise/lazy-promise.js +22 -0
  46. package/dist/cjs/async/lazy-promise/lazy-promise.js.map +1 -0
  47. package/dist/cjs/async/retry/_module.js +18 -0
  48. package/dist/cjs/async/retry/_module.js.map +1 -0
  49. package/dist/cjs/async/retry/retry.js +43 -0
  50. package/dist/cjs/async/retry/retry.js.map +1 -0
  51. package/dist/cjs/async/retry-iterable/_module.js +18 -0
  52. package/dist/cjs/async/retry-iterable/_module.js.map +1 -0
  53. package/dist/cjs/async/retry-iterable/retry-iterable.js +32 -0
  54. package/dist/cjs/async/retry-iterable/retry-iterable.js.map +1 -0
  55. package/dist/cjs/async/timeout/_module.js +18 -0
  56. package/dist/cjs/async/timeout/_module.js.map +1 -0
  57. package/dist/cjs/async/timeout/timeout.js +28 -0
  58. package/dist/cjs/async/timeout/timeout.js.map +1 -0
  59. package/dist/cjs/async/timeout-iterable/_module.js +18 -0
  60. package/dist/cjs/async/timeout-iterable/_module.js.map +1 -0
  61. package/dist/cjs/async/timeout-iterable/timeout-iterable.js +11 -0
  62. package/dist/cjs/async/timeout-iterable/timeout-iterable.js.map +1 -0
  63. package/dist/cjs/collection/async-iterable-collection/_shared/_module.js +1 -3
  64. package/dist/cjs/collection/async-iterable-collection/_shared/_module.js.map +1 -1
  65. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js +14 -23
  66. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
  67. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js +12 -21
  68. package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -1
  69. package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js +5 -14
  70. package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
  71. package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js +9 -18
  72. package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
  73. package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +18 -27
  74. package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
  75. package/dist/cjs/collection/async-iterable-collection/_shared/async-error-handler-iterable.js +31 -0
  76. package/dist/cjs/collection/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -0
  77. package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js +3 -12
  78. package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
  79. package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +2 -11
  80. package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
  81. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +8 -17
  82. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
  83. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +8 -17
  84. package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
  85. package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js +2 -11
  86. package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
  87. package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js +2 -11
  88. package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
  89. package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js +9 -18
  90. package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
  91. package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js +4 -13
  92. package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
  93. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js +3 -12
  94. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
  95. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +7 -16
  96. package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
  97. package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js +9 -18
  98. package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
  99. package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js +17 -26
  100. package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
  101. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js +3 -12
  102. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
  103. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js +4 -13
  104. package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
  105. package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js +2 -11
  106. package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
  107. package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js +6 -15
  108. package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
  109. package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js +5 -14
  110. package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
  111. package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js +4 -13
  112. package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
  113. package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js +177 -265
  114. package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
  115. package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js +14 -23
  116. package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
  117. package/dist/cjs/collection/iterable-collection/_shared/chunk-while-iterable.js +12 -21
  118. package/dist/cjs/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -1
  119. package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js +5 -14
  120. package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
  121. package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js +9 -18
  122. package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
  123. package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js +19 -31
  124. package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
  125. package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js +4 -13
  126. package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
  127. package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js +3 -12
  128. package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
  129. package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js +2 -11
  130. package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
  131. package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js +9 -18
  132. package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
  133. package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js +6 -16
  134. package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
  135. package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js +6 -16
  136. package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
  137. package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js +2 -11
  138. package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
  139. package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js +2 -11
  140. package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
  141. package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js +11 -20
  142. package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
  143. package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js +11 -20
  144. package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
  145. package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js +9 -18
  146. package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
  147. package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js +4 -13
  148. package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
  149. package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js +4 -13
  150. package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
  151. package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js +9 -18
  152. package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
  153. package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js +3 -12
  154. package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
  155. package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js +6 -15
  156. package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
  157. package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js +15 -24
  158. package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
  159. package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js +9 -18
  160. package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
  161. package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js +1 -10
  162. package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
  163. package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js +17 -26
  164. package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
  165. package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js +3 -12
  166. package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
  167. package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js +4 -13
  168. package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
  169. package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js +2 -11
  170. package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
  171. package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js +6 -15
  172. package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
  173. package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js +5 -14
  174. package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
  175. package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js +4 -13
  176. package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
  177. package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js +6 -15
  178. package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
  179. package/dist/cjs/collection/iterable-collection/iterable-collection.js +154 -346
  180. package/dist/cjs/collection/iterable-collection/iterable-collection.js.map +1 -1
  181. package/dist/cjs/collection/list-collection/list-collection.js +348 -931
  182. package/dist/cjs/collection/list-collection/list-collection.js.map +1 -1
  183. package/dist/cjs/storage/storage.js +25 -15
  184. package/dist/cjs/storage/storage.js.map +1 -1
  185. package/dist/cjs/utilities/_module.js +18 -0
  186. package/dist/cjs/utilities/_module.js.map +1 -0
  187. package/dist/cjs/utilities/time-span/_module.js +18 -0
  188. package/dist/cjs/utilities/time-span/_module.js.map +1 -0
  189. package/dist/cjs/utilities/time-span/time-span.js +103 -0
  190. package/dist/cjs/utilities/time-span/time-span.js.map +1 -0
  191. package/dist/esm/_module.js +2 -0
  192. package/dist/esm/_module.js.map +1 -1
  193. package/dist/esm/async/_module.js +12 -0
  194. package/dist/esm/async/_module.js.map +1 -0
  195. package/dist/esm/async/_shared.js +27 -0
  196. package/dist/esm/async/_shared.js.map +1 -0
  197. package/dist/esm/async/abortable/_module.js +2 -0
  198. package/dist/esm/async/abortable/_module.js.map +1 -0
  199. package/dist/esm/async/abortable/abortable.js +45 -0
  200. package/dist/esm/async/abortable/abortable.js.map +1 -0
  201. package/dist/esm/async/abortable-iterable/_module.js +2 -0
  202. package/dist/esm/async/abortable-iterable/_module.js.map +1 -0
  203. package/dist/esm/async/abortable-iterable/abortable-iterable.js +29 -0
  204. package/dist/esm/async/abortable-iterable/abortable-iterable.js.map +1 -0
  205. package/dist/esm/async/backof-policies/_module.js +5 -0
  206. package/dist/esm/async/backof-policies/_module.js.map +1 -0
  207. package/dist/esm/async/backof-policies/_shared.js +4 -0
  208. package/dist/esm/async/backof-policies/_shared.js.map +1 -0
  209. package/dist/esm/async/backof-policies/constant-backoff-policy/_module.js +2 -0
  210. package/dist/esm/async/backof-policies/constant-backoff-policy/_module.js.map +1 -0
  211. package/dist/esm/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +16 -0
  212. package/dist/esm/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
  213. package/dist/esm/async/backof-policies/exponential-backoff-policy/_module.js +2 -0
  214. package/dist/esm/async/backof-policies/exponential-backoff-policy/_module.js.map +1 -0
  215. package/dist/esm/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +20 -0
  216. package/dist/esm/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
  217. package/dist/esm/async/backof-policies/linear-backoff-policy/_module.js +2 -0
  218. package/dist/esm/async/backof-policies/linear-backoff-policy/_module.js.map +1 -0
  219. package/dist/esm/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +20 -0
  220. package/dist/esm/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
  221. package/dist/esm/async/backof-policies/polynomial-backoff-policy/_module.js +2 -0
  222. package/dist/esm/async/backof-policies/polynomial-backoff-policy/_module.js.map +1 -0
  223. package/dist/esm/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +20 -0
  224. package/dist/esm/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
  225. package/dist/esm/async/delay/_module.js +2 -0
  226. package/dist/esm/async/delay/_module.js.map +1 -0
  227. package/dist/esm/async/delay/delay.js +21 -0
  228. package/dist/esm/async/delay/delay.js.map +1 -0
  229. package/dist/esm/async/delay-iterable/_module.js +2 -0
  230. package/dist/esm/async/delay-iterable/_module.js.map +1 -0
  231. package/dist/esm/async/delay-iterable/delay-iterable.js +33 -0
  232. package/dist/esm/async/delay-iterable/delay-iterable.js.map +1 -0
  233. package/dist/esm/async/lazy-promise/_module.js +2 -0
  234. package/dist/esm/async/lazy-promise/_module.js.map +1 -0
  235. package/dist/esm/async/lazy-promise/lazy-promise.js +17 -0
  236. package/dist/esm/async/lazy-promise/lazy-promise.js.map +1 -0
  237. package/dist/esm/async/retry/_module.js +2 -0
  238. package/dist/esm/async/retry/_module.js.map +1 -0
  239. package/dist/esm/async/retry/retry.js +40 -0
  240. package/dist/esm/async/retry/retry.js.map +1 -0
  241. package/dist/esm/async/retry-iterable/_module.js +2 -0
  242. package/dist/esm/async/retry-iterable/_module.js.map +1 -0
  243. package/dist/esm/async/retry-iterable/retry-iterable.js +29 -0
  244. package/dist/esm/async/retry-iterable/retry-iterable.js.map +1 -0
  245. package/dist/esm/async/timeout/_module.js +2 -0
  246. package/dist/esm/async/timeout/_module.js.map +1 -0
  247. package/dist/esm/async/timeout/timeout.js +25 -0
  248. package/dist/esm/async/timeout/timeout.js.map +1 -0
  249. package/dist/esm/async/timeout-iterable/_module.js +2 -0
  250. package/dist/esm/async/timeout-iterable/_module.js.map +1 -0
  251. package/dist/esm/async/timeout-iterable/timeout-iterable.js +8 -0
  252. package/dist/esm/async/timeout-iterable/timeout-iterable.js.map +1 -0
  253. package/dist/esm/collection/async-iterable-collection/_shared/_module.js +1 -3
  254. package/dist/esm/collection/async-iterable-collection/_shared/_module.js.map +1 -1
  255. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js +14 -23
  256. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
  257. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js +12 -21
  258. package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -1
  259. package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js +5 -14
  260. package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
  261. package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js +9 -18
  262. package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
  263. package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +17 -26
  264. package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
  265. package/dist/esm/collection/async-iterable-collection/_shared/async-error-handler-iterable.js +27 -0
  266. package/dist/esm/collection/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -0
  267. package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js +3 -12
  268. package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
  269. package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +2 -11
  270. package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
  271. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +8 -17
  272. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
  273. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +8 -17
  274. package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
  275. package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js +2 -11
  276. package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
  277. package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js +2 -11
  278. package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
  279. package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js +9 -18
  280. package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
  281. package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js +4 -13
  282. package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
  283. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js +3 -12
  284. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
  285. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +7 -16
  286. package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
  287. package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js +9 -18
  288. package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
  289. package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js +17 -26
  290. package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
  291. package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js +3 -12
  292. package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
  293. package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js +4 -13
  294. package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
  295. package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js +2 -11
  296. package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
  297. package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js +6 -15
  298. package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
  299. package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js +5 -14
  300. package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
  301. package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js +4 -13
  302. package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
  303. package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js +179 -267
  304. package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
  305. package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js +14 -23
  306. package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
  307. package/dist/esm/collection/iterable-collection/_shared/chunk-while-iterable.js +12 -21
  308. package/dist/esm/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -1
  309. package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js +5 -14
  310. package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
  311. package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js +9 -18
  312. package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
  313. package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js +19 -31
  314. package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
  315. package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js +4 -13
  316. package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
  317. package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js +3 -12
  318. package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
  319. package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js +2 -11
  320. package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
  321. package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js +9 -18
  322. package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
  323. package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js +6 -16
  324. package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
  325. package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js +6 -16
  326. package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
  327. package/dist/esm/collection/iterable-collection/_shared/map-iterable.js +2 -11
  328. package/dist/esm/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
  329. package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js +2 -11
  330. package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
  331. package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js +11 -20
  332. package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
  333. package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js +11 -20
  334. package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
  335. package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js +9 -18
  336. package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
  337. package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js +4 -13
  338. package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
  339. package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js +4 -13
  340. package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
  341. package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js +9 -18
  342. package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
  343. package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js +3 -12
  344. package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
  345. package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js +6 -15
  346. package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
  347. package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js +15 -24
  348. package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
  349. package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js +9 -18
  350. package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
  351. package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js +1 -10
  352. package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
  353. package/dist/esm/collection/iterable-collection/_shared/split-iterable.js +17 -26
  354. package/dist/esm/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
  355. package/dist/esm/collection/iterable-collection/_shared/take-iterable.js +3 -12
  356. package/dist/esm/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
  357. package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js +4 -13
  358. package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
  359. package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js +2 -11
  360. package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
  361. package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js +6 -15
  362. package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
  363. package/dist/esm/collection/iterable-collection/_shared/update-iterable.js +5 -14
  364. package/dist/esm/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
  365. package/dist/esm/collection/iterable-collection/_shared/when-iterable.js +4 -13
  366. package/dist/esm/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
  367. package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js +6 -15
  368. package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
  369. package/dist/esm/collection/iterable-collection/iterable-collection.js +155 -347
  370. package/dist/esm/collection/iterable-collection/iterable-collection.js.map +1 -1
  371. package/dist/esm/collection/list-collection/list-collection.js +349 -932
  372. package/dist/esm/collection/list-collection/list-collection.js.map +1 -1
  373. package/dist/esm/storage/storage.js +25 -15
  374. package/dist/esm/storage/storage.js.map +1 -1
  375. package/dist/esm/utilities/_module.js +2 -0
  376. package/dist/esm/utilities/_module.js.map +1 -0
  377. package/dist/esm/utilities/time-span/_module.js +2 -0
  378. package/dist/esm/utilities/time-span/_module.js.map +1 -0
  379. package/dist/esm/utilities/time-span/time-span.js +99 -0
  380. package/dist/esm/utilities/time-span/time-span.js.map +1 -0
  381. package/dist/types/_module.d.ts +2 -0
  382. package/dist/types/_shared/types.d.ts +2 -2
  383. package/dist/types/async/_module.d.ts +11 -0
  384. package/dist/types/async/_shared.d.ts +35 -0
  385. package/dist/types/async/abortable/_module.d.ts +1 -0
  386. package/dist/types/async/abortable/abortable.d.ts +39 -0
  387. package/dist/types/async/abortable-iterable/_module.d.ts +1 -0
  388. package/dist/types/async/abortable-iterable/abortable-iterable.d.ts +36 -0
  389. package/dist/types/async/backof-policies/_module.d.ts +5 -0
  390. package/dist/types/async/backof-policies/_shared.d.ts +12 -0
  391. package/dist/types/async/backof-policies/constant-backoff-policy/_module.d.ts +1 -0
  392. package/dist/types/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +28 -0
  393. package/dist/types/async/backof-policies/exponential-backoff-policy/_module.d.ts +1 -0
  394. package/dist/types/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +36 -0
  395. package/dist/types/async/backof-policies/linear-backoff-policy/_module.d.ts +1 -0
  396. package/dist/types/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +32 -0
  397. package/dist/types/async/backof-policies/polynomial-backoff-policy/_module.d.ts +1 -0
  398. package/dist/types/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +36 -0
  399. package/dist/types/async/delay/_module.d.ts +1 -0
  400. package/dist/types/async/delay/delay.d.ts +38 -0
  401. package/dist/types/async/delay-iterable/_module.d.ts +1 -0
  402. package/dist/types/async/delay-iterable/delay-iterable.d.ts +57 -0
  403. package/dist/types/async/lazy-promise/_module.d.ts +1 -0
  404. package/dist/types/async/lazy-promise/lazy-promise.d.ts +28 -0
  405. package/dist/types/async/retry/_module.d.ts +1 -0
  406. package/dist/types/async/retry/retry.d.ts +86 -0
  407. package/dist/types/async/retry-iterable/_module.d.ts +1 -0
  408. package/dist/types/async/retry-iterable/retry-iterable.d.ts +86 -0
  409. package/dist/types/async/timeout/_module.d.ts +1 -0
  410. package/dist/types/async/timeout/timeout.d.ts +40 -0
  411. package/dist/types/async/timeout-iterable/_module.d.ts +1 -0
  412. package/dist/types/async/timeout-iterable/timeout-iterable.d.ts +64 -0
  413. package/dist/types/collection/async-iterable-collection/_shared/_module.d.ts +1 -3
  414. package/dist/types/collection/async-iterable-collection/_shared/async-error-handler-iterable.d.ts +6 -0
  415. package/dist/types/collection/async-iterable-collection/_shared/async-when-iterable.d.ts +1 -1
  416. package/dist/types/collection/async-iterable-collection/async-iterable-collection.d.ts +39 -37
  417. package/dist/types/contracts/collection/_shared.d.ts +7 -7
  418. package/dist/types/contracts/collection/async-collection.contract.d.ts +51 -39
  419. package/dist/types/contracts/storage/storage.contract.d.ts +2 -1
  420. package/dist/types/storage/storage.d.ts +5 -3
  421. package/dist/types/utilities/_module.d.ts +1 -0
  422. package/dist/types/utilities/time-span/_module.d.ts +1 -0
  423. package/dist/types/utilities/time-span/time-span.d.ts +50 -0
  424. package/package.json +1 -1
  425. package/dist/cjs/collection/async-iterable-collection/_shared/async-abort-iterable.js +0 -25
  426. package/dist/cjs/collection/async-iterable-collection/_shared/async-abort-iterable.js.map +0 -1
  427. package/dist/cjs/collection/async-iterable-collection/_shared/async-delay-iterable.js +0 -25
  428. package/dist/cjs/collection/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
  429. package/dist/cjs/collection/async-iterable-collection/_shared/async-timeout-iterable.js +0 -21
  430. package/dist/cjs/collection/async-iterable-collection/_shared/async-timeout-iterable.js.map +0 -1
  431. package/dist/esm/collection/async-iterable-collection/_shared/async-abort-iterable.js +0 -21
  432. package/dist/esm/collection/async-iterable-collection/_shared/async-abort-iterable.js.map +0 -1
  433. package/dist/esm/collection/async-iterable-collection/_shared/async-delay-iterable.js +0 -21
  434. package/dist/esm/collection/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
  435. package/dist/esm/collection/async-iterable-collection/_shared/async-timeout-iterable.js +0 -17
  436. package/dist/esm/collection/async-iterable-collection/_shared/async-timeout-iterable.js.map +0 -1
  437. package/dist/types/collection/async-iterable-collection/_shared/async-abort-iterable.d.ts +0 -10
  438. package/dist/types/collection/async-iterable-collection/_shared/async-delay-iterable.d.ts +0 -10
  439. package/dist/types/collection/async-iterable-collection/_shared/async-timeout-iterable.d.ts +0 -10
@@ -1,5 +1,5 @@
1
1
  import { isIterable } from "../../collection/_shared";
2
- import { CollectionError, ItemNotFoundCollectionError, MultipleItemsFoundCollectionError, UnexpectedCollectionError, TypeCollectionError, EmptyCollectionError, } from "../../contracts/collection/_module";
2
+ import { ItemNotFoundCollectionError, MultipleItemsFoundCollectionError, UnexpectedCollectionError, TypeCollectionError, EmptyCollectionError, } from "../../contracts/collection/_module";
3
3
  import { simplifyLazyable } from "../../_shared/utilities";
4
4
  export class ListCollection {
5
5
  array;
@@ -13,147 +13,65 @@ export class ListCollection {
13
13
  return this[Symbol.iterator]();
14
14
  }
15
15
  entries() {
16
- try {
17
- return new ListCollection(this.array.entries());
18
- }
19
- catch (error) {
20
- if (error instanceof CollectionError) {
21
- throw error;
22
- }
23
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
24
- }
16
+ return new ListCollection(this.array.entries());
25
17
  }
26
18
  keys() {
27
- try {
28
- return new ListCollection(this.array.keys());
29
- }
30
- catch (error) {
31
- if (error instanceof CollectionError) {
32
- throw error;
33
- }
34
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
35
- }
19
+ return new ListCollection(this.array.keys());
36
20
  }
37
21
  values() {
38
22
  return new ListCollection(this);
39
23
  }
40
24
  filter(predicateFn) {
41
- try {
42
- return new ListCollection(this.array.filter((item, index) => predicateFn(item, index, this)));
43
- }
44
- catch (error) {
45
- if (error instanceof CollectionError) {
46
- throw error;
47
- }
48
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
49
- }
25
+ return new ListCollection(this.array.filter((item, index) => predicateFn(item, index, this)));
50
26
  }
51
27
  reject(predicateFn) {
52
- try {
53
- return new ListCollection(this.array.filter((item, index) => !predicateFn(item, index, this)));
54
- }
55
- catch (error) {
56
- if (error instanceof CollectionError) {
57
- throw error;
58
- }
59
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
60
- }
28
+ return new ListCollection(this.array.filter((item, index) => !predicateFn(item, index, this)));
61
29
  }
62
30
  map(mapFn) {
63
- try {
64
- return new ListCollection(this.array.map((item, index) => mapFn(item, index, this)));
65
- }
66
- catch (error) {
67
- if (error instanceof CollectionError) {
68
- throw error;
69
- }
70
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
71
- }
31
+ return new ListCollection(this.array.map((item, index) => mapFn(item, index, this)));
72
32
  }
73
33
  reduce(reduceFn, initialValue) {
74
- try {
75
- if (initialValue === undefined && this.isEmpty()) {
76
- throw new TypeCollectionError("Reduce of empty array must be inputed a initial value");
77
- }
78
- if (initialValue !== undefined) {
79
- return this.array.reduce((initialValue, item, index) => reduceFn(initialValue, item, index, this), initialValue);
80
- }
81
- return this.array.reduce((initialValue, item, index) => {
82
- const reduce = reduceFn;
83
- return reduce(initialValue, item, index, this);
84
- });
34
+ if (initialValue === undefined && this.isEmpty()) {
35
+ throw new TypeCollectionError("Reduce of empty array must be inputed a initial value");
85
36
  }
86
- catch (error) {
87
- if (error instanceof CollectionError) {
88
- throw error;
89
- }
90
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
37
+ if (initialValue !== undefined) {
38
+ return this.array.reduce((initialValue, item, index) => reduceFn(initialValue, item, index, this), initialValue);
91
39
  }
40
+ return this.array.reduce((initialValue, item, index) => {
41
+ const reduce = reduceFn;
42
+ return reduce(initialValue, item, index, this);
43
+ });
92
44
  }
93
45
  join(separator = ",") {
94
- try {
95
- for (const item of this) {
96
- if (typeof item !== "string") {
97
- throw new TypeCollectionError("Item type is invalid must be string");
98
- }
46
+ for (const item of this) {
47
+ if (typeof item !== "string") {
48
+ throw new TypeCollectionError("Item type is invalid must be string");
99
49
  }
100
- return this.array.join(separator);
101
- }
102
- catch (error) {
103
- if (error instanceof CollectionError) {
104
- throw error;
105
- }
106
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
107
50
  }
51
+ return this.array.join(separator);
108
52
  }
109
53
  collapse() {
110
- try {
111
- const items = [];
112
- for (const item of this.array) {
113
- if (isIterable(item)) {
114
- items.push(...item);
115
- }
116
- else {
117
- items.push(item);
118
- }
54
+ const items = [];
55
+ for (const item of this.array) {
56
+ if (isIterable(item)) {
57
+ items.push(...item);
119
58
  }
120
- return new ListCollection(items);
121
- }
122
- catch (error) {
123
- if (error instanceof CollectionError) {
124
- throw error;
59
+ else {
60
+ items.push(item);
125
61
  }
126
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
127
62
  }
63
+ return new ListCollection(items);
128
64
  }
129
65
  flatMap(mapFn) {
130
- try {
131
- return new ListCollection(this.array.flatMap((item, index) => [
132
- ...mapFn(item, index, this),
133
- ]));
134
- }
135
- catch (error) {
136
- if (error instanceof CollectionError) {
137
- throw error;
138
- }
139
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
140
- }
66
+ return new ListCollection(this.array.flatMap((item, index) => [...mapFn(item, index, this)]));
141
67
  }
142
68
  change(predicateFn, mapFn) {
143
- try {
144
- return new ListCollection(this.array.map((item, index) => {
145
- if (predicateFn(item, index, this)) {
146
- return mapFn(item, index, this);
147
- }
148
- return item;
149
- }));
150
- }
151
- catch (error) {
152
- if (error instanceof CollectionError) {
153
- throw error;
69
+ return new ListCollection(this.array.map((item, index) => {
70
+ if (predicateFn(item, index, this)) {
71
+ return mapFn(item, index, this);
154
72
  }
155
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
156
- }
73
+ return item;
74
+ }));
157
75
  }
158
76
  page(page, pageSize) {
159
77
  if (page < 0) {
@@ -179,1028 +97,527 @@ export class ListCollection {
179
97
  return (this.sum() / this.size());
180
98
  }
181
99
  median() {
182
- try {
183
- if (this.isEmpty()) {
184
- throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
185
- }
186
- const nbrs = this.array.map((item) => {
187
- if (typeof item !== "number") {
188
- throw new TypeCollectionError("Item type is invalid must be number");
189
- }
190
- return item;
191
- }), index = Math.floor(this.array.length / 2), isEven = this.array.length % 2 === 0, a = nbrs[index];
192
- if (a === undefined) {
193
- throw new UnexpectedCollectionError("Is in invalid state");
194
- }
195
- const b = nbrs[index - 1];
196
- if (isEven) {
197
- if (b === undefined) {
198
- throw new UnexpectedCollectionError("Is in invalid state");
199
- }
200
- return ((a + b) / 2);
100
+ if (this.isEmpty()) {
101
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
102
+ }
103
+ const nbrs = this.array.map((item) => {
104
+ if (typeof item !== "number") {
105
+ throw new TypeCollectionError("Item type is invalid must be number");
201
106
  }
202
- return a;
107
+ return item;
108
+ }), index = Math.floor(this.array.length / 2), isEven = this.array.length % 2 === 0, a = nbrs[index];
109
+ if (a === undefined) {
110
+ throw new UnexpectedCollectionError("Is in invalid state");
203
111
  }
204
- catch (error) {
205
- if (error instanceof CollectionError) {
206
- throw error;
112
+ const b = nbrs[index - 1];
113
+ if (isEven) {
114
+ if (b === undefined) {
115
+ throw new UnexpectedCollectionError("Is in invalid state");
207
116
  }
208
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
117
+ return ((a + b) / 2);
209
118
  }
119
+ return a;
210
120
  }
211
121
  min() {
212
- try {
213
- if (this.isEmpty()) {
214
- throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
122
+ if (this.isEmpty()) {
123
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
124
+ }
125
+ let min = 0;
126
+ for (const item of this.array) {
127
+ if (typeof item !== "number") {
128
+ throw new TypeCollectionError("Item type is invalid must be number");
215
129
  }
216
- let min = 0;
217
- for (const item of this.array) {
218
- if (typeof item !== "number") {
219
- throw new TypeCollectionError("Item type is invalid must be number");
220
- }
221
- if (min === 0) {
222
- min = item;
223
- }
224
- else if (min > item) {
225
- min = item;
226
- }
130
+ if (min === 0) {
131
+ min = item;
227
132
  }
228
- return min;
229
- }
230
- catch (error) {
231
- if (error instanceof CollectionError) {
232
- throw error;
133
+ else if (min > item) {
134
+ min = item;
233
135
  }
234
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
235
136
  }
137
+ return min;
236
138
  }
237
139
  max() {
238
- try {
239
- if (this.isEmpty()) {
240
- throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
140
+ if (this.isEmpty()) {
141
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
142
+ }
143
+ let max = 0;
144
+ for (const item of this.array) {
145
+ if (typeof item !== "number") {
146
+ throw new TypeCollectionError("Item type is invalid must be number");
241
147
  }
242
- let max = 0;
243
- for (const item of this.array) {
244
- if (typeof item !== "number") {
245
- throw new TypeCollectionError("Item type is invalid must be number");
246
- }
247
- if (max === 0) {
248
- max = item;
249
- }
250
- else if (max < item) {
251
- max = item;
252
- }
148
+ if (max === 0) {
149
+ max = item;
253
150
  }
254
- return max;
255
- }
256
- catch (error) {
257
- if (error instanceof CollectionError) {
258
- throw error;
151
+ else if (max < item) {
152
+ max = item;
259
153
  }
260
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
261
154
  }
155
+ return max;
262
156
  }
263
157
  percentage(predicateFn) {
264
- try {
265
- if (this.isEmpty()) {
266
- throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
267
- }
268
- return (this.count(predicateFn) / this.size()) * 100;
269
- }
270
- catch (error) {
271
- if (error instanceof CollectionError) {
272
- throw error;
273
- }
274
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
158
+ if (this.isEmpty()) {
159
+ throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
275
160
  }
161
+ return (this.count(predicateFn) / this.size()) * 100;
276
162
  }
277
163
  some(predicateFn) {
278
- try {
279
- return this.array.some((item, index) => predicateFn(item, index, this));
280
- }
281
- catch (error) {
282
- if (error instanceof CollectionError) {
283
- throw error;
284
- }
285
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
286
- }
164
+ return this.array.some((item, index) => predicateFn(item, index, this));
287
165
  }
288
166
  every(predicateFn) {
289
- try {
290
- return this.array.every((item, index) => predicateFn(item, index, this));
291
- }
292
- catch (error) {
293
- if (error instanceof CollectionError) {
294
- throw error;
295
- }
296
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
297
- }
167
+ return this.array.every((item, index) => predicateFn(item, index, this));
298
168
  }
299
169
  take(limit) {
300
- try {
301
- return new ListCollection(this.array.slice(0, limit));
302
- }
303
- catch (error) {
304
- if (error instanceof CollectionError) {
305
- throw error;
306
- }
307
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
308
- }
170
+ return new ListCollection(this.array.slice(0, limit));
309
171
  }
310
172
  takeUntil(predicateFn) {
311
- try {
312
- const items = [];
313
- for (const [index, item] of this.array.entries()) {
314
- if (predicateFn(item, index, this)) {
315
- break;
316
- }
317
- items.push(item);
318
- }
319
- return new ListCollection(items);
320
- }
321
- catch (error) {
322
- if (error instanceof CollectionError) {
323
- throw error;
173
+ const items = [];
174
+ for (const [index, item] of this.array.entries()) {
175
+ if (predicateFn(item, index, this)) {
176
+ break;
324
177
  }
325
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
178
+ items.push(item);
326
179
  }
180
+ return new ListCollection(items);
327
181
  }
328
182
  takeWhile(predicateFn) {
329
- try {
330
- return this.takeUntil((...arguments_) => !predicateFn(...arguments_));
331
- }
332
- catch (error) {
333
- if (error instanceof CollectionError) {
334
- throw error;
335
- }
336
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
337
- }
183
+ return this.takeUntil((...arguments_) => !predicateFn(...arguments_));
338
184
  }
339
185
  skip(offset) {
340
- try {
341
- return new ListCollection(this.array.slice(offset));
342
- }
343
- catch (error) {
344
- if (error instanceof CollectionError) {
345
- throw error;
346
- }
347
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
348
- }
186
+ return new ListCollection(this.array.slice(offset));
349
187
  }
350
188
  skipUntil(predicateFn) {
351
- try {
352
- let hasMatched = false;
353
- const items = [];
354
- for (const [index, item] of this.array.entries()) {
355
- if (!hasMatched) {
356
- hasMatched = predicateFn(item, index, this);
357
- }
358
- if (hasMatched) {
359
- items.push(item);
360
- }
189
+ let hasMatched = false;
190
+ const items = [];
191
+ for (const [index, item] of this.array.entries()) {
192
+ if (!hasMatched) {
193
+ hasMatched = predicateFn(item, index, this);
361
194
  }
362
- return new ListCollection(items);
363
- }
364
- catch (error) {
365
- if (error instanceof CollectionError) {
366
- throw error;
195
+ if (hasMatched) {
196
+ items.push(item);
367
197
  }
368
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
369
198
  }
199
+ return new ListCollection(items);
370
200
  }
371
201
  skipWhile(predicateFn) {
372
- try {
373
- return this.skipUntil((...arguments_) => !predicateFn(...arguments_));
374
- }
375
- catch (error) {
376
- if (error instanceof CollectionError) {
377
- throw error;
378
- }
379
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
380
- }
202
+ return this.skipUntil((...arguments_) => !predicateFn(...arguments_));
381
203
  }
382
204
  when(condition, callback) {
383
- try {
384
- if (condition) {
385
- return callback(this);
386
- }
387
- return this;
388
- }
389
- catch (error) {
390
- if (error instanceof CollectionError) {
391
- throw error;
392
- }
393
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
205
+ if (condition) {
206
+ return callback(this);
394
207
  }
208
+ return this;
395
209
  }
396
210
  whenEmpty(callback) {
397
- try {
398
- return this.when(this.isEmpty(), callback);
399
- }
400
- catch (error) {
401
- if (error instanceof CollectionError) {
402
- throw error;
403
- }
404
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
405
- }
211
+ return this.when(this.isEmpty(), callback);
406
212
  }
407
213
  whenNot(condition, callback) {
408
- try {
409
- return this.when(!condition, callback);
410
- }
411
- catch (error) {
412
- if (error instanceof CollectionError) {
413
- throw error;
414
- }
415
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
416
- }
214
+ return this.when(!condition, callback);
417
215
  }
418
216
  whenNotEmpty(callback) {
419
- try {
420
- return this.when(this.isNotEmpty(), callback);
421
- }
422
- catch (error) {
423
- if (error instanceof CollectionError) {
424
- throw error;
425
- }
426
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
427
- }
217
+ return this.when(this.isNotEmpty(), callback);
428
218
  }
429
219
  pipe(callback) {
430
- try {
431
- return callback(this);
432
- }
433
- catch (error) {
434
- if (error instanceof CollectionError) {
435
- throw error;
436
- }
437
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
438
- }
220
+ return callback(this);
439
221
  }
440
222
  tap(callback) {
441
- try {
442
- callback(this);
443
- return new ListCollection(this);
444
- }
445
- catch (error) {
446
- if (error instanceof CollectionError) {
447
- throw error;
448
- }
449
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
450
- }
223
+ callback(this);
224
+ return new ListCollection(this);
451
225
  }
452
226
  chunk(chunkSize) {
453
- try {
454
- const chunks = [];
455
- for (let index = 0; index < this.size(); index += chunkSize) {
456
- chunks.push(new ListCollection(this.array.slice(index, index + chunkSize)));
457
- }
458
- return new ListCollection(chunks);
459
- }
460
- catch (error) {
461
- if (error instanceof CollectionError) {
462
- throw error;
463
- }
464
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
227
+ const chunks = [];
228
+ for (let index = 0; index < this.size(); index += chunkSize) {
229
+ chunks.push(new ListCollection(this.array.slice(index, index + chunkSize)));
465
230
  }
231
+ return new ListCollection(chunks);
466
232
  }
467
233
  chunkWhile(predicateFn) {
468
- try {
469
- let currentChunk = new ListCollection([]);
470
- const chunks = [];
471
- for (const [index, item] of this.array.entries()) {
472
- if (index === 0) {
473
- currentChunk = currentChunk.append([item]);
474
- }
475
- else if (predicateFn(item, index, currentChunk)) {
476
- currentChunk = currentChunk.append([item]);
477
- }
478
- else {
479
- chunks.push(currentChunk);
480
- currentChunk = new ListCollection([item]);
481
- }
234
+ let currentChunk = new ListCollection([]);
235
+ const chunks = [];
236
+ for (const [index, item] of this.array.entries()) {
237
+ if (index === 0) {
238
+ currentChunk = currentChunk.append([item]);
482
239
  }
483
- chunks.push(currentChunk);
484
- return new ListCollection(chunks);
485
- }
486
- catch (error) {
487
- if (error instanceof CollectionError) {
488
- throw error;
240
+ else if (predicateFn(item, index, currentChunk)) {
241
+ currentChunk = currentChunk.append([item]);
242
+ }
243
+ else {
244
+ chunks.push(currentChunk);
245
+ currentChunk = new ListCollection([item]);
489
246
  }
490
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
491
247
  }
248
+ chunks.push(currentChunk);
249
+ return new ListCollection(chunks);
492
250
  }
493
251
  split(chunkAmount) {
494
- try {
495
- const size = this.size(), minChunkSize = Math.floor(size / chunkAmount), restSize = size % chunkAmount, chunkSizes = Array.from({
496
- length: chunkAmount,
497
- }).fill(minChunkSize);
498
- for (let index = 1; index <= restSize; index++) {
499
- const chunkIndex = (index - 1) % chunkAmount;
500
- if (chunkSizes[chunkIndex]) {
501
- chunkSizes[chunkIndex] = chunkSizes[chunkIndex] + 1;
502
- }
252
+ const size = this.size(), minChunkSize = Math.floor(size / chunkAmount), restSize = size % chunkAmount, chunkSizes = Array.from({
253
+ length: chunkAmount,
254
+ }).fill(minChunkSize);
255
+ for (let index = 1; index <= restSize; index++) {
256
+ const chunkIndex = (index - 1) % chunkAmount;
257
+ if (chunkSizes[chunkIndex]) {
258
+ chunkSizes[chunkIndex] = chunkSizes[chunkIndex] + 1;
503
259
  }
504
- let end = 0, start = 0;
505
- const chunks = [];
506
- for (const chunkSize of chunkSizes) {
507
- end += chunkSize;
508
- chunks.push(new ListCollection(this.array.slice(start, end)));
509
- start += chunkSize;
510
- }
511
- return new ListCollection(chunks);
512
260
  }
513
- catch (error) {
514
- if (error instanceof CollectionError) {
515
- throw error;
516
- }
517
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
261
+ let end = 0, start = 0;
262
+ const chunks = [];
263
+ for (const chunkSize of chunkSizes) {
264
+ end += chunkSize;
265
+ chunks.push(new ListCollection(this.array.slice(start, end)));
266
+ start += chunkSize;
518
267
  }
268
+ return new ListCollection(chunks);
519
269
  }
520
270
  partition(predicateFn) {
521
- try {
522
- const chunkA = [], chunkB = [];
523
- for (const [index, item] of this.array.entries()) {
524
- if (predicateFn(item, index, this)) {
525
- chunkA.push(item);
526
- }
527
- else {
528
- chunkB.push(item);
529
- }
271
+ const chunkA = [], chunkB = [];
272
+ for (const [index, item] of this.array.entries()) {
273
+ if (predicateFn(item, index, this)) {
274
+ chunkA.push(item);
530
275
  }
531
- return new ListCollection([
532
- new ListCollection(chunkA),
533
- new ListCollection(chunkB),
534
- ]);
535
- }
536
- catch (error) {
537
- if (error instanceof CollectionError) {
538
- throw error;
276
+ else {
277
+ chunkB.push(item);
539
278
  }
540
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
541
279
  }
280
+ return new ListCollection([
281
+ new ListCollection(chunkA),
282
+ new ListCollection(chunkB),
283
+ ]);
542
284
  }
543
285
  sliding(chunkSize, step = chunkSize - 1) {
544
- try {
545
- let chunks = new ListCollection([]);
546
- if (step <= 0) {
547
- return new ListCollection([]);
548
- }
549
- for (let index = 0; index < this.size(); index += step) {
550
- const start = index;
551
- const end = index + chunkSize;
552
- chunks = chunks.append([this.slice(start, end)]);
553
- if (end >= this.size()) {
554
- break;
555
- }
556
- }
557
- return chunks;
286
+ let chunks = new ListCollection([]);
287
+ if (step <= 0) {
288
+ return new ListCollection([]);
558
289
  }
559
- catch (error) {
560
- if (error instanceof CollectionError) {
561
- throw error;
290
+ for (let index = 0; index < this.size(); index += step) {
291
+ const start = index;
292
+ const end = index + chunkSize;
293
+ chunks = chunks.append([this.slice(start, end)]);
294
+ if (end >= this.size()) {
295
+ break;
562
296
  }
563
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
564
297
  }
298
+ return chunks;
565
299
  }
566
300
  groupBy(selectFn = (item) => item) {
567
- try {
568
- const map = new Map();
569
- for (const [index, item] of this.array.entries()) {
570
- const key = selectFn(item, index, this);
571
- let collection = map.get(key);
572
- if (collection === undefined) {
573
- collection = new ListCollection([]);
574
- map.set(key, collection);
575
- }
576
- map.set(key, collection.append([item]));
577
- }
578
- return new ListCollection(map);
579
- }
580
- catch (error) {
581
- if (error instanceof CollectionError) {
582
- throw error;
301
+ const map = new Map();
302
+ for (const [index, item] of this.array.entries()) {
303
+ const key = selectFn(item, index, this);
304
+ let collection = map.get(key);
305
+ if (collection === undefined) {
306
+ collection = new ListCollection([]);
307
+ map.set(key, collection);
583
308
  }
584
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
309
+ map.set(key, collection.append([item]));
585
310
  }
311
+ return new ListCollection(map);
586
312
  }
587
313
  countBy(selectFn = (item) => item) {
588
- try {
589
- const map = new Map();
590
- for (const [index, item] of this.array.entries()) {
591
- const key = selectFn(item, index, this);
592
- if (!map.has(key)) {
593
- map.set(key, 0);
594
- }
595
- const counter = map.get(key);
596
- if (counter !== undefined) {
597
- map.set(key, counter + 1);
598
- }
314
+ const map = new Map();
315
+ for (const [index, item] of this.array.entries()) {
316
+ const key = selectFn(item, index, this);
317
+ if (!map.has(key)) {
318
+ map.set(key, 0);
599
319
  }
600
- return new ListCollection(map);
601
- }
602
- catch (error) {
603
- if (error instanceof CollectionError) {
604
- throw error;
320
+ const counter = map.get(key);
321
+ if (counter !== undefined) {
322
+ map.set(key, counter + 1);
605
323
  }
606
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
607
324
  }
325
+ return new ListCollection(map);
608
326
  }
609
327
  unique(selectFn = (item) => item) {
610
- try {
611
- const set = new Set([]), items = [];
612
- for (const [index, item] of this.array.entries()) {
613
- const item_ = selectFn(item, index, this);
614
- if (!set.has(item_)) {
615
- items.push(item);
616
- }
617
- set.add(item_);
618
- }
619
- return new ListCollection(items);
620
- }
621
- catch (error) {
622
- if (error instanceof CollectionError) {
623
- throw error;
328
+ const set = new Set([]), items = [];
329
+ for (const [index, item] of this.array.entries()) {
330
+ const item_ = selectFn(item, index, this);
331
+ if (!set.has(item_)) {
332
+ items.push(item);
624
333
  }
625
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
334
+ set.add(item_);
626
335
  }
336
+ return new ListCollection(items);
627
337
  }
628
338
  difference(iterable, selectFn = (item) => item) {
629
- try {
630
- const differenceCollection = new ListCollection(iterable);
631
- return this.filter((item, index, collection) => {
632
- return !differenceCollection.some((matchItem, matchIndex, matchCollection) => {
633
- return (selectFn(item, index, collection) ===
634
- selectFn(matchItem, matchIndex, matchCollection));
635
- });
339
+ const differenceCollection = new ListCollection(iterable);
340
+ return this.filter((item, index, collection) => {
341
+ return !differenceCollection.some((matchItem, matchIndex, matchCollection) => {
342
+ return (selectFn(item, index, collection) ===
343
+ selectFn(matchItem, matchIndex, matchCollection));
636
344
  });
637
- }
638
- catch (error) {
639
- if (error instanceof CollectionError) {
640
- throw error;
641
- }
642
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
643
- }
345
+ });
644
346
  }
645
347
  repeat(amount) {
646
- try {
647
- let collection = new ListCollection([]);
648
- for (let index = 0; index < amount; index++) {
649
- collection = collection.append(this);
650
- }
651
- return collection;
652
- }
653
- catch (error) {
654
- if (error instanceof CollectionError) {
655
- throw error;
656
- }
657
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
348
+ let collection = new ListCollection([]);
349
+ for (let index = 0; index < amount; index++) {
350
+ collection = collection.append(this);
658
351
  }
352
+ return collection;
659
353
  }
660
354
  padStart(maxLength, fillItems) {
661
- try {
662
- const fillItemsArray = [...fillItems];
663
- const size = this.size();
664
- const repeat = Math.floor((maxLength - size) / fillItemsArray.length);
665
- const resultItemsArray = [];
666
- for (let index = 0; index < repeat; index++) {
667
- resultItemsArray.push(...fillItemsArray);
668
- }
669
- const restAmount = maxLength - (repeat * fillItemsArray.length + size);
670
- for (let index = 0; index < restAmount; index++) {
671
- const fillItem = fillItemsArray[index];
672
- if (fillItem) {
673
- resultItemsArray.push(fillItem);
674
- }
675
- }
676
- resultItemsArray.push(...this);
677
- return new ListCollection(resultItemsArray);
355
+ const fillItemsArray = [...fillItems];
356
+ const size = this.size();
357
+ const repeat = Math.floor((maxLength - size) / fillItemsArray.length);
358
+ const resultItemsArray = [];
359
+ for (let index = 0; index < repeat; index++) {
360
+ resultItemsArray.push(...fillItemsArray);
678
361
  }
679
- catch (error) {
680
- if (error instanceof CollectionError) {
681
- throw error;
362
+ const restAmount = maxLength - (repeat * fillItemsArray.length + size);
363
+ for (let index = 0; index < restAmount; index++) {
364
+ const fillItem = fillItemsArray[index];
365
+ if (fillItem) {
366
+ resultItemsArray.push(fillItem);
682
367
  }
683
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
684
368
  }
369
+ resultItemsArray.push(...this);
370
+ return new ListCollection(resultItemsArray);
685
371
  }
686
372
  padEnd(maxLength, fillItems) {
687
- try {
688
- const fillItemsArray = [...fillItems];
689
- const size = this.size();
690
- const repeat = Math.floor((maxLength - size) / fillItemsArray.length);
691
- const resultItemsArray = [];
692
- for (let index = 0; index < repeat; index++) {
693
- resultItemsArray.push(...fillItemsArray);
694
- }
695
- const restAmount = maxLength - (repeat * fillItemsArray.length + size);
696
- for (let index = 0; index < restAmount; index++) {
697
- const fillItem = fillItemsArray[index];
698
- if (fillItem) {
699
- resultItemsArray.push(fillItem);
700
- }
701
- }
702
- resultItemsArray.unshift(...this);
703
- return new ListCollection(resultItemsArray);
373
+ const fillItemsArray = [...fillItems];
374
+ const size = this.size();
375
+ const repeat = Math.floor((maxLength - size) / fillItemsArray.length);
376
+ const resultItemsArray = [];
377
+ for (let index = 0; index < repeat; index++) {
378
+ resultItemsArray.push(...fillItemsArray);
704
379
  }
705
- catch (error) {
706
- if (error instanceof CollectionError) {
707
- throw error;
380
+ const restAmount = maxLength - (repeat * fillItemsArray.length + size);
381
+ for (let index = 0; index < restAmount; index++) {
382
+ const fillItem = fillItemsArray[index];
383
+ if (fillItem) {
384
+ resultItemsArray.push(fillItem);
708
385
  }
709
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
710
386
  }
387
+ resultItemsArray.unshift(...this);
388
+ return new ListCollection(resultItemsArray);
711
389
  }
712
390
  slice(start, end) {
713
- try {
714
- return new ListCollection(this.array.slice(start, end));
715
- }
716
- catch (error) {
717
- if (error instanceof CollectionError) {
718
- throw error;
719
- }
720
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
721
- }
391
+ return new ListCollection(this.array.slice(start, end));
722
392
  }
723
393
  prepend(iterable) {
724
- try {
725
- return new ListCollection([...iterable, ...this.array]);
726
- }
727
- catch (error) {
728
- if (error instanceof CollectionError) {
729
- throw error;
730
- }
731
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
732
- }
394
+ return new ListCollection([...iterable, ...this.array]);
733
395
  }
734
396
  append(iterable) {
735
- try {
736
- return new ListCollection([...this.array, ...iterable]);
737
- }
738
- catch (error) {
739
- if (error instanceof CollectionError) {
740
- throw error;
741
- }
742
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
743
- }
397
+ return new ListCollection([...this.array, ...iterable]);
744
398
  }
745
399
  insertBefore(predicateFn, iterable) {
746
- try {
747
- const index = this.array.findIndex((item, index) => predicateFn(item, index, this));
748
- if (index === -1) {
749
- return new ListCollection(this.array);
750
- }
751
- const newArray = [...this.array];
752
- newArray.splice(index, 0, ...iterable);
753
- return new ListCollection(newArray);
754
- }
755
- catch (error) {
756
- if (error instanceof CollectionError) {
757
- throw error;
758
- }
759
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
400
+ const index = this.array.findIndex((item, index) => predicateFn(item, index, this));
401
+ if (index === -1) {
402
+ return new ListCollection(this.array);
760
403
  }
404
+ const newArray = [...this.array];
405
+ newArray.splice(index, 0, ...iterable);
406
+ return new ListCollection(newArray);
761
407
  }
762
408
  insertAfter(predicateFn, iterable) {
763
- try {
764
- const index = this.array.findIndex((item, index) => predicateFn(item, index, this));
765
- if (index === -1) {
766
- return new ListCollection(this.array);
767
- }
768
- const firstPart = this.array.slice(0, index + 1), lastPart = this.array.slice(index + 1);
769
- return new ListCollection([
770
- ...firstPart,
771
- ...iterable,
772
- ...lastPart,
773
- ]);
774
- }
775
- catch (error) {
776
- if (error instanceof CollectionError) {
777
- throw error;
778
- }
779
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
409
+ const index = this.array.findIndex((item, index) => predicateFn(item, index, this));
410
+ if (index === -1) {
411
+ return new ListCollection(this.array);
780
412
  }
413
+ const firstPart = this.array.slice(0, index + 1), lastPart = this.array.slice(index + 1);
414
+ return new ListCollection([
415
+ ...firstPart,
416
+ ...iterable,
417
+ ...lastPart,
418
+ ]);
781
419
  }
782
420
  crossJoin(iterable) {
783
- try {
784
- const array = [
785
- [...this],
786
- [...iterable],
787
- ]
788
- .reduce((a, b) => {
789
- return a
790
- .map((x) => {
791
- return b.map((y) => {
792
- return [...x, y];
793
- });
794
- })
795
- .reduce((c, b) => [...c, ...b], []);
796
- }, [[]])
797
- .map((combination) => {
798
- return combination.reduce((a, b) => {
799
- return [
800
- ...a,
801
- ...(isIterable(b) ? b : [b]),
802
- ];
803
- }, []);
804
- });
805
- return new ListCollection(array);
806
- }
807
- catch (error) {
808
- if (error instanceof CollectionError) {
809
- throw error;
810
- }
811
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
812
- }
421
+ const array = [
422
+ [...this],
423
+ [...iterable],
424
+ ]
425
+ .reduce((a, b) => {
426
+ return a
427
+ .map((x) => {
428
+ return b.map((y) => {
429
+ return [...x, y];
430
+ });
431
+ })
432
+ .reduce((c, b) => [...c, ...b], []);
433
+ }, [[]])
434
+ .map((combination) => {
435
+ return combination.reduce((a, b) => {
436
+ return [...a, ...(isIterable(b) ? b : [b])];
437
+ }, []);
438
+ });
439
+ return new ListCollection(array);
813
440
  }
814
441
  zip(iterable) {
815
- try {
816
- const iterableArray = [...iterable];
817
- let size = iterableArray.length;
818
- if (size > this.size()) {
819
- size = this.size();
820
- }
821
- const items = [];
822
- for (let index = 0; index < size; index++) {
823
- const itemA = this.array[index], itemB = iterableArray[index];
824
- if (itemA === undefined || itemB === undefined) {
825
- continue;
826
- }
827
- items.push([itemA, itemB]);
828
- }
829
- return new ListCollection(items);
442
+ const iterableArray = [...iterable];
443
+ let size = iterableArray.length;
444
+ if (size > this.size()) {
445
+ size = this.size();
830
446
  }
831
- catch (error) {
832
- if (error instanceof CollectionError) {
833
- throw error;
447
+ const items = [];
448
+ for (let index = 0; index < size; index++) {
449
+ const itemA = this.array[index], itemB = iterableArray[index];
450
+ if (itemA === undefined || itemB === undefined) {
451
+ continue;
834
452
  }
835
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
453
+ items.push([itemA, itemB]);
836
454
  }
455
+ return new ListCollection(items);
837
456
  }
838
457
  sort(comparator) {
839
- try {
840
- return new ListCollection(this.array.sort(comparator));
841
- }
842
- catch (error) {
843
- if (error instanceof CollectionError) {
844
- throw error;
845
- }
846
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
847
- }
458
+ return new ListCollection(this.array.sort(comparator));
848
459
  }
849
460
  reverse(_chunkSize) {
850
- try {
851
- return new ListCollection([...this.array].reverse());
852
- }
853
- catch (error) {
854
- if (error instanceof CollectionError) {
855
- throw error;
856
- }
857
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
858
- }
461
+ return new ListCollection([...this.array].reverse());
859
462
  }
860
463
  shuffle(mathRandom = Math.random) {
861
- try {
862
- const newArray = [...this.array];
863
- for (let i = newArray.length - 1; i > 0; i--) {
864
- const j = Math.floor(mathRandom() * (i + 1));
865
- const temp = newArray[i];
866
- if (newArray[j] !== undefined) {
867
- newArray[i] = newArray[j];
868
- }
869
- if (temp !== undefined) {
870
- newArray[j] = temp;
871
- }
464
+ const newArray = [...this.array];
465
+ for (let i = newArray.length - 1; i > 0; i--) {
466
+ const j = Math.floor(mathRandom() * (i + 1));
467
+ const temp = newArray[i];
468
+ if (newArray[j] !== undefined) {
469
+ newArray[i] = newArray[j];
872
470
  }
873
- return new ListCollection(newArray);
874
- }
875
- catch (error) {
876
- if (error instanceof CollectionError) {
877
- throw error;
471
+ if (temp !== undefined) {
472
+ newArray[j] = temp;
878
473
  }
879
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
880
474
  }
475
+ return new ListCollection(newArray);
881
476
  }
882
477
  first(predicateFn) {
883
- try {
884
- return this.firstOr(null, predicateFn);
885
- }
886
- catch (error) {
887
- if (error instanceof CollectionError) {
888
- throw error;
889
- }
890
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
891
- }
478
+ return this.firstOr(null, predicateFn);
892
479
  }
893
480
  firstOr(defaultValue, predicateFn) {
894
- try {
895
- if (predicateFn) {
896
- for (const [index, item] of this.array.entries()) {
897
- if (predicateFn(item, index, this)) {
898
- return item;
899
- }
900
- }
901
- }
902
- else {
903
- const firstItem = this.array[0];
904
- if (firstItem) {
905
- return firstItem;
481
+ if (predicateFn) {
482
+ for (const [index, item] of this.array.entries()) {
483
+ if (predicateFn(item, index, this)) {
484
+ return item;
906
485
  }
907
486
  }
908
- return simplifyLazyable(defaultValue);
909
487
  }
910
- catch (error) {
911
- if (error instanceof CollectionError) {
912
- throw error;
488
+ else {
489
+ const firstItem = this.array[0];
490
+ if (firstItem) {
491
+ return firstItem;
913
492
  }
914
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
915
493
  }
494
+ return simplifyLazyable(defaultValue);
916
495
  }
917
496
  firstOrFail(predicateFn) {
918
- try {
919
- const item = this.first(predicateFn);
920
- if (item === null) {
921
- throw new ItemNotFoundCollectionError("Item was not found");
922
- }
923
- return item;
924
- }
925
- catch (error) {
926
- if (error instanceof CollectionError) {
927
- throw error;
928
- }
929
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
497
+ const item = this.first(predicateFn);
498
+ if (item === null) {
499
+ throw new ItemNotFoundCollectionError("Item was not found");
930
500
  }
501
+ return item;
931
502
  }
932
503
  last(predicateFn) {
933
- try {
934
- return this.lastOr(null, predicateFn);
935
- }
936
- catch (error) {
937
- if (error instanceof CollectionError) {
938
- throw error;
939
- }
940
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
941
- }
504
+ return this.lastOr(null, predicateFn);
942
505
  }
943
506
  lastOr(defaultValue, predicateFn) {
944
- try {
945
- if (predicateFn) {
946
- let matchedItem = null;
947
- for (const [index, item] of this.array.entries()) {
948
- if (predicateFn(item, index, this)) {
949
- matchedItem = item;
950
- }
951
- }
952
- if (matchedItem) {
953
- return matchedItem;
507
+ if (predicateFn) {
508
+ let matchedItem = null;
509
+ for (const [index, item] of this.array.entries()) {
510
+ if (predicateFn(item, index, this)) {
511
+ matchedItem = item;
954
512
  }
955
513
  }
956
- else {
957
- const lastItem = this.array.at(-1);
958
- if (lastItem) {
959
- return lastItem;
960
- }
514
+ if (matchedItem) {
515
+ return matchedItem;
961
516
  }
962
- return simplifyLazyable(defaultValue);
963
517
  }
964
- catch (error) {
965
- if (error instanceof CollectionError) {
966
- throw error;
518
+ else {
519
+ const lastItem = this.array.at(-1);
520
+ if (lastItem) {
521
+ return lastItem;
967
522
  }
968
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
969
523
  }
524
+ return simplifyLazyable(defaultValue);
970
525
  }
971
526
  lastOrFail(predicateFn) {
972
- try {
973
- const item = this.last(predicateFn);
974
- if (item === null) {
975
- throw new ItemNotFoundCollectionError("Item was not found");
976
- }
977
- return item;
978
- }
979
- catch (error) {
980
- if (error instanceof CollectionError) {
981
- throw error;
982
- }
983
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
527
+ const item = this.last(predicateFn);
528
+ if (item === null) {
529
+ throw new ItemNotFoundCollectionError("Item was not found");
984
530
  }
531
+ return item;
985
532
  }
986
533
  before(predicateFn) {
987
- try {
988
- return this.beforeOr(null, predicateFn);
989
- }
990
- catch (error) {
991
- if (error instanceof CollectionError) {
992
- throw error;
993
- }
994
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
995
- }
534
+ return this.beforeOr(null, predicateFn);
996
535
  }
997
536
  beforeOr(defaultValue, predicateFn) {
998
- try {
999
- for (const [index, item] of this.array.entries()) {
1000
- const beforeItem = this.array[index - 1];
1001
- if (predicateFn(item, index, this) &&
1002
- beforeItem !== undefined) {
1003
- return beforeItem;
1004
- }
537
+ for (const [index, item] of this.array.entries()) {
538
+ const beforeItem = this.array[index - 1];
539
+ if (predicateFn(item, index, this) && beforeItem !== undefined) {
540
+ return beforeItem;
1005
541
  }
1006
- return simplifyLazyable(defaultValue);
1007
- }
1008
- catch (error) {
1009
- if (error instanceof CollectionError) {
1010
- throw error;
1011
- }
1012
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1013
542
  }
543
+ return simplifyLazyable(defaultValue);
1014
544
  }
1015
545
  beforeOrFail(predicateFn) {
1016
- try {
1017
- const item = this.before(predicateFn);
1018
- if (item === null) {
1019
- throw new ItemNotFoundCollectionError("Item was not found");
1020
- }
1021
- return item;
1022
- }
1023
- catch (error) {
1024
- if (error instanceof CollectionError) {
1025
- throw error;
1026
- }
1027
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
546
+ const item = this.before(predicateFn);
547
+ if (item === null) {
548
+ throw new ItemNotFoundCollectionError("Item was not found");
1028
549
  }
550
+ return item;
1029
551
  }
1030
552
  after(predicateFn) {
1031
- try {
1032
- return this.afterOr(null, predicateFn);
1033
- }
1034
- catch (error) {
1035
- if (error instanceof CollectionError) {
1036
- throw error;
1037
- }
1038
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1039
- }
553
+ return this.afterOr(null, predicateFn);
1040
554
  }
1041
555
  afterOr(defaultValue, predicateFn) {
1042
- try {
1043
- for (const [index, item] of this.array.entries()) {
1044
- const beforeItem = this.array[index + 1];
1045
- if (predicateFn(item, index, this) &&
1046
- beforeItem !== undefined) {
1047
- return beforeItem;
1048
- }
1049
- }
1050
- return simplifyLazyable(defaultValue);
1051
- }
1052
- catch (error) {
1053
- if (error instanceof CollectionError) {
1054
- throw error;
556
+ for (const [index, item] of this.array.entries()) {
557
+ const beforeItem = this.array[index + 1];
558
+ if (predicateFn(item, index, this) && beforeItem !== undefined) {
559
+ return beforeItem;
1055
560
  }
1056
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1057
561
  }
562
+ return simplifyLazyable(defaultValue);
1058
563
  }
1059
564
  afterOrFail(predicateFn) {
1060
- try {
1061
- const item = this.after(predicateFn);
1062
- if (item === null) {
1063
- throw new ItemNotFoundCollectionError("Item was not found");
1064
- }
1065
- return item;
1066
- }
1067
- catch (error) {
1068
- if (error instanceof CollectionError) {
1069
- throw error;
1070
- }
1071
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
565
+ const item = this.after(predicateFn);
566
+ if (item === null) {
567
+ throw new ItemNotFoundCollectionError("Item was not found");
1072
568
  }
569
+ return item;
1073
570
  }
1074
571
  sole(predicateFn) {
1075
- try {
1076
- const matchedItems = [];
1077
- for (const [index, item] of this.array.entries()) {
1078
- if (predicateFn(item, index, this)) {
1079
- matchedItems.push(item);
1080
- }
1081
- if (matchedItems.length > 1) {
1082
- throw new MultipleItemsFoundCollectionError("Multiple items were found");
1083
- }
572
+ const matchedItems = [];
573
+ for (const [index, item] of this.array.entries()) {
574
+ if (predicateFn(item, index, this)) {
575
+ matchedItems.push(item);
1084
576
  }
1085
- const [matchedItem] = matchedItems;
1086
- if (matchedItem === undefined) {
1087
- throw new ItemNotFoundCollectionError("Item was not found");
577
+ if (matchedItems.length > 1) {
578
+ throw new MultipleItemsFoundCollectionError("Multiple items were found");
1088
579
  }
1089
- return matchedItem;
1090
580
  }
1091
- catch (error) {
1092
- if (error instanceof CollectionError) {
1093
- throw error;
1094
- }
1095
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
581
+ const [matchedItem] = matchedItems;
582
+ if (matchedItem === undefined) {
583
+ throw new ItemNotFoundCollectionError("Item was not found");
1096
584
  }
585
+ return matchedItem;
1097
586
  }
1098
587
  nth(step) {
1099
- try {
1100
- return this.filter((_item, index) => index % step === 0);
1101
- }
1102
- catch (error) {
1103
- if (error instanceof CollectionError) {
1104
- throw error;
1105
- }
1106
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1107
- }
588
+ return this.filter((_item, index) => index % step === 0);
1108
589
  }
1109
590
  count(predicateFn) {
1110
- try {
1111
- return this.filter(predicateFn).size();
1112
- }
1113
- catch (error) {
1114
- if (error instanceof CollectionError) {
1115
- throw error;
1116
- }
1117
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1118
- }
591
+ return this.filter(predicateFn).size();
1119
592
  }
1120
593
  size() {
1121
- try {
1122
- return this.array.length;
1123
- }
1124
- catch (error) {
1125
- if (error instanceof CollectionError) {
1126
- throw error;
1127
- }
1128
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1129
- }
594
+ return this.array.length;
1130
595
  }
1131
596
  isEmpty() {
1132
- try {
1133
- return this.array.length === 0;
1134
- }
1135
- catch (error) {
1136
- if (error instanceof CollectionError) {
1137
- throw error;
1138
- }
1139
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1140
- }
597
+ return this.array.length === 0;
1141
598
  }
1142
599
  isNotEmpty() {
1143
- try {
1144
- return this.array.length !== 0;
1145
- }
1146
- catch (error) {
1147
- if (error instanceof CollectionError) {
1148
- throw error;
1149
- }
1150
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1151
- }
600
+ return this.array.length !== 0;
1152
601
  }
1153
602
  searchFirst(predicateFn) {
1154
- try {
1155
- return this.array.findIndex((item, index) => predicateFn(item, index, this));
1156
- }
1157
- catch (error) {
1158
- if (error instanceof CollectionError) {
1159
- throw error;
1160
- }
1161
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1162
- }
603
+ return this.array.findIndex((item, index) => predicateFn(item, index, this));
1163
604
  }
1164
605
  searchLast(predicateFn) {
1165
- try {
1166
- let matchedIndex = -1;
1167
- for (const [index, item] of this.array.entries()) {
1168
- if (predicateFn(item, index, this)) {
1169
- matchedIndex = index;
1170
- }
606
+ let matchedIndex = -1;
607
+ for (const [index, item] of this.array.entries()) {
608
+ if (predicateFn(item, index, this)) {
609
+ matchedIndex = index;
1171
610
  }
1172
- return matchedIndex;
1173
- }
1174
- catch (error) {
1175
- if (error instanceof CollectionError) {
1176
- throw error;
1177
- }
1178
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1179
611
  }
612
+ return matchedIndex;
1180
613
  }
1181
614
  forEach(callback) {
1182
- try {
1183
- for (const [index, item] of this.array.entries()) {
1184
- callback(item, index, this);
1185
- }
1186
- }
1187
- catch (error) {
1188
- if (error instanceof CollectionError) {
1189
- throw error;
1190
- }
1191
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
615
+ for (const [index, item] of this.array.entries()) {
616
+ callback(item, index, this);
1192
617
  }
1193
618
  }
1194
619
  toArray() {
1195
- try {
1196
- return [...this.array];
1197
- }
1198
- catch (error) {
1199
- if (error instanceof CollectionError) {
1200
- throw error;
1201
- }
1202
- throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
1203
- }
620
+ return [...this.array];
1204
621
  }
1205
622
  }
1206
623
  //# sourceMappingURL=list-collection.js.map