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