@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.
- package/dist/cjs/async/_module.js +1 -0
- package/dist/cjs/async/_module.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/_module.js +1 -3
- package/dist/cjs/collection/async-iterable-collection/_shared/_module.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js +14 -23
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js +12 -21
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js +5 -14
- package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js +9 -18
- package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +18 -27
- package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-error-handler-iterable.js +31 -0
- package/dist/cjs/collection/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js +3 -12
- package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +8 -17
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +8 -17
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js +9 -18
- package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js +4 -13
- package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js +3 -12
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +7 -16
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js +9 -18
- package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js +17 -26
- package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js +3 -12
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js +4 -13
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js +6 -15
- package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js +5 -14
- package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js +4 -13
- package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js +177 -265
- package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js +14 -23
- package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/chunk-while-iterable.js +12 -21
- package/dist/cjs/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js +5 -14
- package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js +19 -31
- package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js +3 -12
- package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js +6 -16
- package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js +6 -16
- package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js +11 -20
- package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js +11 -20
- package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js +3 -12
- package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js +6 -15
- package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js +15 -24
- package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js +1 -10
- package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js +17 -26
- package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js +3 -12
- package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js +6 -15
- package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js +5 -14
- package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js +6 -15
- package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/iterable-collection.js +154 -346
- package/dist/cjs/collection/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/cjs/collection/list-collection/list-collection.js +348 -931
- package/dist/cjs/collection/list-collection/list-collection.js.map +1 -1
- package/dist/cjs/storage/memory-storage-adapter/memory-storage-adapter.js +23 -0
- package/dist/cjs/storage/memory-storage-adapter/memory-storage-adapter.js.map +1 -1
- package/dist/cjs/storage/mongodb-storage-adapter/mongodb-storage-adapter.js +0 -70
- package/dist/cjs/storage/mongodb-storage-adapter/mongodb-storage-adapter.js.map +1 -1
- package/dist/cjs/storage/namespace-storage-adapter.js +11 -21
- package/dist/cjs/storage/namespace-storage-adapter.js.map +1 -1
- package/dist/cjs/storage/redis-storage-adapter/redis-storage-adapter.js +0 -20
- package/dist/cjs/storage/redis-storage-adapter/redis-storage-adapter.js.map +1 -1
- package/dist/cjs/storage/sqlite/_shared/base-sqlite-storage-adapter.js +0 -34
- package/dist/cjs/storage/sqlite/_shared/base-sqlite-storage-adapter.js.map +1 -1
- package/dist/cjs/storage/storage.js +104 -188
- package/dist/cjs/storage/storage.js.map +1 -1
- package/dist/esm/async/_module.js +1 -0
- package/dist/esm/async/_module.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/_module.js +1 -3
- package/dist/esm/collection/async-iterable-collection/_shared/_module.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js +14 -23
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js +12 -21
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js +5 -14
- package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js +9 -18
- package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +17 -26
- package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-error-handler-iterable.js +27 -0
- package/dist/esm/collection/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js +3 -12
- package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +8 -17
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +8 -17
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js +9 -18
- package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js +4 -13
- package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js +3 -12
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +7 -16
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js +9 -18
- package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js +17 -26
- package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js +3 -12
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js +4 -13
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js +6 -15
- package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js +5 -14
- package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js +4 -13
- package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js +179 -267
- package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js +14 -23
- package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/chunk-while-iterable.js +12 -21
- package/dist/esm/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js +5 -14
- package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js +19 -31
- package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js +3 -12
- package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js +6 -16
- package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js +6 -16
- package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/map-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js +11 -20
- package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js +11 -20
- package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js +3 -12
- package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js +6 -15
- package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js +15 -24
- package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js +1 -10
- package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/split-iterable.js +17 -26
- package/dist/esm/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/take-iterable.js +3 -12
- package/dist/esm/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js +6 -15
- package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/update-iterable.js +5 -14
- package/dist/esm/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/when-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js +6 -15
- package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/iterable-collection.js +155 -347
- package/dist/esm/collection/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/esm/collection/list-collection/list-collection.js +349 -932
- package/dist/esm/collection/list-collection/list-collection.js.map +1 -1
- package/dist/esm/storage/memory-storage-adapter/memory-storage-adapter.js +23 -0
- package/dist/esm/storage/memory-storage-adapter/memory-storage-adapter.js.map +1 -1
- package/dist/esm/storage/mongodb-storage-adapter/mongodb-storage-adapter.js +0 -70
- package/dist/esm/storage/mongodb-storage-adapter/mongodb-storage-adapter.js.map +1 -1
- package/dist/esm/storage/namespace-storage-adapter.js +11 -21
- package/dist/esm/storage/namespace-storage-adapter.js.map +1 -1
- package/dist/esm/storage/redis-storage-adapter/redis-storage-adapter.js +0 -20
- package/dist/esm/storage/redis-storage-adapter/redis-storage-adapter.js.map +1 -1
- package/dist/esm/storage/sqlite/_shared/base-sqlite-storage-adapter.js +0 -34
- package/dist/esm/storage/sqlite/_shared/base-sqlite-storage-adapter.js.map +1 -1
- package/dist/esm/storage/storage.js +105 -189
- package/dist/esm/storage/storage.js.map +1 -1
- package/dist/types/_shared/types.d.ts +2 -6
- package/dist/types/async/_module.d.ts +1 -0
- package/dist/types/collection/async-iterable-collection/_shared/_module.d.ts +1 -3
- package/dist/types/collection/async-iterable-collection/_shared/async-error-handler-iterable.d.ts +6 -0
- package/dist/types/collection/async-iterable-collection/_shared/async-when-iterable.d.ts +1 -1
- package/dist/types/collection/async-iterable-collection/async-iterable-collection.d.ts +39 -37
- package/dist/types/contracts/collection/_shared.d.ts +7 -7
- package/dist/types/contracts/collection/async-collection.contract.d.ts +51 -39
- package/dist/types/contracts/storage/storage-adapter.contract.d.ts +7 -26
- package/dist/types/contracts/storage/storage.contract.d.ts +22 -22
- package/dist/types/storage/memory-storage-adapter/memory-storage-adapter.d.ts +2 -0
- package/dist/types/storage/mongodb-storage-adapter/mongodb-storage-adapter.d.ts +0 -3
- package/dist/types/storage/namespace-storage-adapter.d.ts +2 -7
- package/dist/types/storage/redis-storage-adapter/redis-storage-adapter.d.ts +0 -3
- package/dist/types/storage/sqlite/_shared/base-sqlite-storage-adapter.d.ts +0 -3
- package/dist/types/storage/storage.d.ts +24 -23
- package/package.json +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-abort-iterable.js +0 -25
- package/dist/cjs/collection/async-iterable-collection/_shared/async-abort-iterable.js.map +0 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-delay-iterable.js +0 -25
- package/dist/cjs/collection/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-timeout-iterable.js +0 -21
- package/dist/cjs/collection/async-iterable-collection/_shared/async-timeout-iterable.js.map +0 -1
- package/dist/cjs/storage/usable-storage-adapter.js +0 -102
- package/dist/cjs/storage/usable-storage-adapter.js.map +0 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-abort-iterable.js +0 -21
- package/dist/esm/collection/async-iterable-collection/_shared/async-abort-iterable.js.map +0 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-delay-iterable.js +0 -21
- package/dist/esm/collection/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-timeout-iterable.js +0 -17
- package/dist/esm/collection/async-iterable-collection/_shared/async-timeout-iterable.js.map +0 -1
- package/dist/esm/storage/usable-storage-adapter.js +0 -98
- package/dist/esm/storage/usable-storage-adapter.js.map +0 -1
- package/dist/types/collection/async-iterable-collection/_shared/async-abort-iterable.d.ts +0 -10
- package/dist/types/collection/async-iterable-collection/_shared/async-delay-iterable.d.ts +0 -10
- package/dist/types/collection/async-iterable-collection/_shared/async-timeout-iterable.d.ts +0 -10
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
78
|
-
|
|
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
|
-
|
|
90
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
|
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
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
120
|
+
return ((a + b) / 2);
|
|
212
121
|
}
|
|
122
|
+
return a;
|
|
213
123
|
}
|
|
214
124
|
min() {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
220
|
-
|
|
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
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
246
|
-
|
|
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
|
-
|
|
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
|
-
|
|
268
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
-
|
|
181
|
+
items.push(item);
|
|
329
182
|
}
|
|
183
|
+
return new ListCollection(items);
|
|
330
184
|
}
|
|
331
185
|
takeWhile(predicateFn) {
|
|
332
|
-
|
|
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
|
-
|
|
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
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
387
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
445
|
-
|
|
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
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
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
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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
|
-
|
|
535
|
-
|
|
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
|
-
|
|
548
|
-
|
|
549
|
-
|
|
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
|
-
|
|
563
|
-
|
|
564
|
-
|
|
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
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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
|
-
|
|
312
|
+
map.set(key, collection.append([item]));
|
|
588
313
|
}
|
|
314
|
+
return new ListCollection(map);
|
|
589
315
|
}
|
|
590
316
|
countBy(selectFn = (item) => item) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
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
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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
|
-
|
|
337
|
+
set.add(item_);
|
|
629
338
|
}
|
|
339
|
+
return new ListCollection(items);
|
|
630
340
|
}
|
|
631
341
|
difference(iterable, selectFn = (item) => item) {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
return
|
|
635
|
-
return
|
|
636
|
-
|
|
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
|
-
|
|
650
|
-
|
|
651
|
-
|
|
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
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
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
|
-
|
|
683
|
-
|
|
684
|
-
|
|
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
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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
|
-
|
|
767
|
-
|
|
768
|
-
|
|
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
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
return
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
return
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
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
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
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
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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
|
-
|
|
456
|
+
items.push([itemA, itemB]);
|
|
839
457
|
}
|
|
458
|
+
return new ListCollection(items);
|
|
840
459
|
}
|
|
841
460
|
sort(comparator) {
|
|
842
|
-
|
|
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
|
-
|
|
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
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
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
|
-
|
|
914
|
-
|
|
915
|
-
|
|
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
|
-
|
|
922
|
-
|
|
923
|
-
|
|
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
|
-
|
|
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
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
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
|
-
|
|
960
|
-
|
|
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
|
-
|
|
968
|
-
|
|
969
|
-
|
|
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
|
-
|
|
976
|
-
|
|
977
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
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
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
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
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
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
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
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
|
-
|
|
1089
|
-
|
|
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
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
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
|
-
|
|
1186
|
-
|
|
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
|
-
|
|
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;
|