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