@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,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Collections
|
|
3
3
|
*/
|
|
4
|
-
import { type
|
|
5
|
-
import { type EnsureType } from "../../_shared/types";
|
|
6
|
-
export type AsyncIterableValue<TInput> = Iterable<TInput> | AsyncIterable<TInput>;
|
|
4
|
+
import { type AsyncPredicate, type AsyncForEach, type AsyncMap, type AsyncModifier, type AsyncTap, type AsyncTransform, type Comparator, type ChangendItem, AsyncReduce, CrossJoinResult } from "../../contracts/collection/_shared";
|
|
5
|
+
import { type RecordItem, type AsyncLazyable, type EnsureType, type AsyncIterableValue } from "../../_shared/types";
|
|
7
6
|
export type AsyncCollapse<TValue> = TValue extends Array<infer TItem> | Iterable<infer TItem> | IAsyncCollection<infer TItem> ? TItem : TValue;
|
|
8
7
|
/**
|
|
9
|
-
* <i>IAsyncCollection</i> is immutable. The <i>throwOnIndexOverflow</i> parameter in the <i>
|
|
10
|
-
* @throws {CollectionError}
|
|
8
|
+
* <i>IAsyncCollection</i> is immutable. The <i>throwOnIndexOverflow</i> parameter in the <i>IAsyncCollection</i> methods is used for preventing the index to overflow by throwing an error.
|
|
9
|
+
* @throws {CollectionError} {@link CollectionError}
|
|
11
10
|
* @throws {UnexpectedCollectionError}
|
|
12
|
-
* @throws {
|
|
13
|
-
* @throws {
|
|
14
|
-
* @throws {
|
|
15
|
-
* @throws {
|
|
11
|
+
* @throws {ItemNotFoundCollectionError}
|
|
12
|
+
* @throws {MultipleItemsFoundCollectionError}
|
|
13
|
+
* @throws {TypeCollectionError}
|
|
14
|
+
* @throws {EmptyCollectionError}
|
|
16
15
|
* @group Contracts
|
|
17
16
|
*/
|
|
18
17
|
export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
@@ -23,11 +22,11 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
23
22
|
/**
|
|
24
23
|
* The <i>entries</i> returns an IAsyncCollection of key, value pairs for every entry in the collection.
|
|
25
24
|
*/
|
|
26
|
-
entries(
|
|
25
|
+
entries(): IAsyncCollection<RecordItem<number, TInput>>;
|
|
27
26
|
/**
|
|
28
27
|
* The <i>keys</i> method returns an IAsyncCollection of keys in the collection.
|
|
29
28
|
*/
|
|
30
|
-
keys(
|
|
29
|
+
keys(): IAsyncCollection<number>;
|
|
31
30
|
/**
|
|
32
31
|
* The <i>values</i> method returns a copy of the collection.
|
|
33
32
|
*/
|
|
@@ -35,70 +34,84 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
35
34
|
/**
|
|
36
35
|
* The <i>filter</i> method filters the collection using <i>predicateFn</i>, keeping only those items that pass <i>predicateFn</i>.
|
|
37
36
|
* @example
|
|
37
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
38
|
+
*
|
|
38
39
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6]);
|
|
39
40
|
* const filtered = collection.filter(item => 2 < item && item < 5);
|
|
40
41
|
* await filtered.toArray();
|
|
41
42
|
* // [3, 4]
|
|
42
43
|
*/
|
|
43
|
-
filter<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput
|
|
44
|
+
filter<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TOutput>;
|
|
44
45
|
/**
|
|
45
46
|
* The <i>reject</i> method filters the collection using <i>predicateFn</i>, keeping only those items that not pass <i>predicateFn</i>.
|
|
46
47
|
* @example
|
|
48
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
49
|
+
*
|
|
47
50
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6]);
|
|
48
51
|
* const filtered = collection.reject(item => 2 < item && item < 5);
|
|
49
52
|
* await filtered.toArray();
|
|
50
53
|
* // [1, 2, 5, 6]
|
|
51
54
|
*/
|
|
52
|
-
reject<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput
|
|
55
|
+
reject<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<Exclude<TInput, TOutput>>;
|
|
53
56
|
/**
|
|
54
57
|
* The <i>map</i> method iterates through the collection and passes each item to <i>mapFn</i>.
|
|
55
58
|
* The <i>mapFn</i> is free to modify the item and return it, thus forming a new collection of modified items.
|
|
56
59
|
* @example
|
|
60
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
61
|
+
*
|
|
57
62
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5]);
|
|
58
63
|
* const mapped = collection.map(item => item * 2);
|
|
59
64
|
* await mapped.toArray();
|
|
60
65
|
* // [2, 4, 6, 8, 10]
|
|
61
66
|
*/
|
|
62
|
-
map<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput
|
|
67
|
+
map<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TOutput>;
|
|
63
68
|
/**
|
|
64
|
-
* The <i>reduce</i> method executes <i>
|
|
69
|
+
* The <i>reduce</i> method executes <i> reduceFn </i> function on each item of the array, passing in the return value from the calculation on the preceding item.
|
|
65
70
|
* The final result of running the reducer across all items of the array is a single value.
|
|
66
71
|
* @example
|
|
72
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
73
|
+
*
|
|
67
74
|
* const collection = new AsyncIterableCollection([1, 2, 3]);
|
|
68
|
-
* await collection.reduce(
|
|
69
|
-
* reduceFn: (sum, item) => sum + item
|
|
70
|
-
* });
|
|
75
|
+
* await collection.reduce((sum, item) => sum + item);
|
|
71
76
|
* // 6
|
|
72
77
|
* @example
|
|
78
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
79
|
+
*
|
|
73
80
|
* const collection = new AsyncIterableCollection(["a", "b", "c"]);
|
|
74
|
-
* await collection.entries().reduce(
|
|
75
|
-
*
|
|
81
|
+
* await collection.entries().reduce(
|
|
82
|
+
* (record, [key, value]) => ({
|
|
76
83
|
* ...record,
|
|
77
84
|
* [key]: value
|
|
78
85
|
* }),
|
|
79
|
-
*
|
|
80
|
-
*
|
|
86
|
+
* {} as Record<number, string>
|
|
87
|
+
* );
|
|
81
88
|
* // { 0: "a", 1: "b", 2: "c" }
|
|
82
89
|
*/
|
|
83
|
-
reduce
|
|
90
|
+
reduce(reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TInput>): Promise<TInput>;
|
|
91
|
+
reduce(reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TInput>, initialValue: TInput): Promise<TInput>;
|
|
92
|
+
reduce<TOutput>(reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TOutput>, initialValue: TOutput): Promise<TOutput>;
|
|
84
93
|
/**
|
|
85
|
-
* The <i>join</i> method joins the collection's items with
|
|
86
|
-
* @throws {
|
|
94
|
+
* The <i>join</i> method joins the collection's items with <i> separator </i>. An error will be thrown when if a none string item is encounterd.
|
|
95
|
+
* @throws {TypeCollectionError}
|
|
87
96
|
* @example
|
|
97
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
98
|
+
*
|
|
88
99
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
89
100
|
* await collection.map(item => item.toString()).join();
|
|
90
101
|
* // "1,2,3,4"
|
|
91
102
|
* @example
|
|
103
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
104
|
+
*
|
|
92
105
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
93
|
-
* await collection.map(item => item.toString()).join(
|
|
94
|
-
* seperator: "_"
|
|
95
|
-
* });
|
|
106
|
+
* await collection.map(item => item.toString()).join("_");
|
|
96
107
|
* // "1_2_3_4"
|
|
97
108
|
*/
|
|
98
|
-
join(
|
|
109
|
+
join(separator?: string): Promise<EnsureType<TInput, string>>;
|
|
99
110
|
/**
|
|
100
111
|
* The <i>collapse</i> method collapses a collection of iterables into a single, flat collection.
|
|
101
112
|
* @example
|
|
113
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
114
|
+
*
|
|
102
115
|
* const collection = new AsyncIterableCollection([[1, 2], [3, 4]]);
|
|
103
116
|
* const collapsed = collection.collapse();
|
|
104
117
|
* await collapsed.toArray();
|
|
@@ -109,180 +122,217 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
109
122
|
* The <i>flatMap</i> method returns a new array formed by applying <i>mapFn</i> to each item of the array, and then collapses the result by one level.
|
|
110
123
|
* It is identical to a <i>map</i> method followed by a <i>collapse</i> method.
|
|
111
124
|
* @example
|
|
125
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
126
|
+
*
|
|
112
127
|
* const collection = new AsyncIterableCollection([["a", "b"], ["c", "d"]]).flatMap(item => [item.length, ...item]);
|
|
113
128
|
* await collection.toArray();
|
|
114
129
|
* // [2, "a", "b", 2, "c", "d"]
|
|
115
130
|
*/
|
|
116
|
-
flatMap<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, Iterable<TOutput
|
|
131
|
+
flatMap<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, Iterable<TOutput>>): IAsyncCollection<TOutput>;
|
|
117
132
|
/**
|
|
118
|
-
* The <i>
|
|
133
|
+
* The <i>change</i> method changes only the items that passes <i>predicateFn</i> using <i>mapFn</i>.
|
|
119
134
|
* @example
|
|
135
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
136
|
+
*
|
|
120
137
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5]);
|
|
121
|
-
* const
|
|
122
|
-
* await
|
|
138
|
+
* const newCollection = collection.change(item => item % 2 === 0, item => item * 2);
|
|
139
|
+
* await newCollection.toArray();
|
|
123
140
|
* // [1, 4, 3, 8, 5]
|
|
124
141
|
*/
|
|
125
|
-
|
|
142
|
+
change<TFilterOutput extends TInput, TMapOutput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TFilterOutput>, mapFn: AsyncMap<TFilterOutput, IAsyncCollection<TInput>, TMapOutput>): IAsyncCollection<ChangendItem<TInput, TFilterOutput, TMapOutput>>;
|
|
126
143
|
/**
|
|
127
|
-
* The <i>page</i> method returns a new collection containing the items that would be present on <i>
|
|
144
|
+
* The <i>page</i> method returns a new collection containing the items that would be present on <i> page </i> with custom <i> pageSize </i>.
|
|
128
145
|
* @example
|
|
146
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
147
|
+
*
|
|
129
148
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
|
130
|
-
* const page = collection.page(
|
|
131
|
-
* page: 2,
|
|
132
|
-
* pageSize: 3
|
|
133
|
-
* });
|
|
149
|
+
* const page = collection.page(2, 3);
|
|
134
150
|
* await page.toArray();
|
|
135
151
|
* // [4, 5, 6]
|
|
136
152
|
*/
|
|
137
|
-
page(
|
|
153
|
+
page(page: number, pageSize: number): IAsyncCollection<TInput>;
|
|
138
154
|
/**
|
|
139
155
|
* The <i>sum</i> method returns the sum of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
140
156
|
* @example
|
|
157
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
158
|
+
*
|
|
141
159
|
* const collection = new AsyncIterableCollection([1, 2, 3]);
|
|
142
160
|
* await collection.sum();
|
|
143
161
|
* // 6
|
|
144
162
|
* @throws {CollectionError} {@link CollectionError}
|
|
145
163
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
146
|
-
* @throws {
|
|
164
|
+
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
165
|
+
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
147
166
|
*/
|
|
148
167
|
sum(): Promise<EnsureType<TInput, number>>;
|
|
149
168
|
/**
|
|
150
169
|
* The <i>average</i> method returns the average of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
151
170
|
* @example
|
|
171
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
172
|
+
*
|
|
152
173
|
* const collection = new AsyncIterableCollection([1, 2, 3]);
|
|
153
174
|
* await collection.average();
|
|
154
175
|
* // 2
|
|
155
176
|
* @throws {CollectionError} {@link CollectionError}
|
|
156
177
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
157
|
-
* @throws {
|
|
178
|
+
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
179
|
+
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
158
180
|
*/
|
|
159
181
|
average(): Promise<EnsureType<TInput, number>>;
|
|
160
182
|
/**
|
|
161
183
|
* The <i>median</i> method returns the median of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
162
184
|
* @example
|
|
185
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
186
|
+
*
|
|
163
187
|
* const collection = new AsyncIterableCollection([1, 2, 3]);
|
|
164
188
|
* await collection.median();
|
|
165
189
|
* // 2
|
|
166
190
|
* @throws {CollectionError} {@link CollectionError}
|
|
167
191
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
168
|
-
* @throws {
|
|
169
|
-
* @throws {
|
|
192
|
+
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
193
|
+
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
170
194
|
*/
|
|
171
|
-
median(
|
|
195
|
+
median(): Promise<EnsureType<TInput, number>>;
|
|
172
196
|
/**
|
|
173
197
|
* The <i>min</i> method returns the min of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
174
198
|
* @example
|
|
199
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
200
|
+
*
|
|
175
201
|
* const collection = new AsyncIterableCollection([1, 2, 3]);
|
|
176
202
|
* await collection.min();
|
|
177
203
|
* // 1
|
|
178
204
|
* @throws {CollectionError} {@link CollectionError}
|
|
179
205
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
180
|
-
* @throws {
|
|
206
|
+
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
207
|
+
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
181
208
|
*/
|
|
182
209
|
min(): Promise<EnsureType<TInput, number>>;
|
|
183
210
|
/**
|
|
184
211
|
* The <i>max</i> method returns the max of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
185
212
|
* @example
|
|
213
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
214
|
+
*
|
|
186
215
|
* const collection = new AsyncIterableCollection([1, 2, 3]);
|
|
187
216
|
* await collection.max();
|
|
188
217
|
* // 3
|
|
189
218
|
* @throws {CollectionError} {@link CollectionError}
|
|
190
219
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
191
|
-
* @throws {
|
|
220
|
+
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
221
|
+
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
192
222
|
*/
|
|
193
223
|
max(): Promise<EnsureType<TInput, number>>;
|
|
194
224
|
/**
|
|
195
225
|
* The <i>percentage</i> method may be used to quickly determine the percentage of items in the collection that pass <i>predicateFn</i>.
|
|
196
226
|
* @example
|
|
227
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
228
|
+
*
|
|
197
229
|
* const collection = new AsyncIterableCollection([1, 1, 2, 2, 2, 3]);
|
|
198
230
|
* await collection.percentage(value => value === 1);
|
|
199
231
|
* // 33.333
|
|
200
232
|
* @throws {CollectionError} {@link CollectionError}
|
|
201
233
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
202
|
-
* @throws {
|
|
234
|
+
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
203
235
|
*/
|
|
204
|
-
percentage(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
236
|
+
percentage(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<number>;
|
|
205
237
|
/**
|
|
206
238
|
* The <i>some</i> method determines whether at least one item in the collection matches <i>predicateFn</i>.
|
|
207
239
|
* @example
|
|
240
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
241
|
+
*
|
|
208
242
|
* const collection = new AsyncIterableCollection([0, 1, 2, 3, 4, 5]);
|
|
209
243
|
* await collection.some(item => item === 1);
|
|
210
244
|
* // true
|
|
211
245
|
* @throws {CollectionError} {@link CollectionError}
|
|
212
246
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
213
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
214
247
|
*/
|
|
215
|
-
some<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput
|
|
248
|
+
some<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<boolean>;
|
|
216
249
|
/**
|
|
217
250
|
* The <i>every</i> method determines whether all items in the collection matches <i>predicateFn</i>.
|
|
218
251
|
* @example
|
|
252
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
253
|
+
*
|
|
219
254
|
* const collection = new AsyncIterableCollection([0, 1, 2, 3, 4, 5]);
|
|
220
255
|
* await collection.every(item => item < 6);
|
|
221
256
|
* // true
|
|
222
257
|
* @throws {CollectionError} {@link CollectionError}
|
|
223
258
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
224
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
225
259
|
*/
|
|
226
|
-
every<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput
|
|
260
|
+
every<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<boolean>;
|
|
227
261
|
/**
|
|
228
262
|
* The <i>take</i> method takes the first <i>limit</i> items.
|
|
229
263
|
* @example
|
|
264
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
265
|
+
*
|
|
230
266
|
* const collection = new AsyncIterableCollection([0, 1, 2, 3, 4, 5]);
|
|
231
267
|
* const chunk = collection.take(3);
|
|
232
268
|
* await chunk.toArray();
|
|
233
269
|
* // [0, 1, 2]
|
|
234
270
|
* @example
|
|
271
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
272
|
+
*
|
|
235
273
|
* const collection = new AsyncIterableCollection([0, 1, 2, 3, 4, 5]);
|
|
236
274
|
* const chunk = collection.take(-2);
|
|
237
275
|
* await chunk.toArray();
|
|
238
|
-
* // [
|
|
276
|
+
* // [0, 1, 2, 3]
|
|
239
277
|
*/
|
|
240
|
-
take(limit: number
|
|
278
|
+
take(limit: number): IAsyncCollection<TInput>;
|
|
241
279
|
/**
|
|
242
280
|
* The <i>takeUntil</i> method takes items until <i>predicateFn</i> returns true.
|
|
243
281
|
* @example
|
|
282
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
283
|
+
*
|
|
244
284
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
245
285
|
* const chunk = collection.takeUntil(item => item >= 3);
|
|
246
286
|
* await chunk.toArray();
|
|
247
287
|
* // [1, 2]
|
|
248
288
|
*/
|
|
249
|
-
takeUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
289
|
+
takeUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
250
290
|
/**
|
|
251
291
|
* The <i>takeWhile</i> method takes items until <i>predicateFn</i> returns false.
|
|
252
292
|
* @example
|
|
293
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
294
|
+
*
|
|
253
295
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
254
296
|
* const chunk = collection.takeWhile(item => item < 4);
|
|
255
297
|
* await chunk.toArray();
|
|
256
298
|
* // [1, 2, 3]
|
|
257
299
|
*/
|
|
258
|
-
takeWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
300
|
+
takeWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
259
301
|
/**
|
|
260
302
|
* The <i>skip</i> method skips the first <i>offset</i> items.
|
|
261
303
|
* @example
|
|
304
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
305
|
+
*
|
|
262
306
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).skip(4);
|
|
263
307
|
* await collection.toArray();
|
|
264
308
|
* // [5, 6, 7, 8, 9, 10]
|
|
265
309
|
*/
|
|
266
|
-
skip(offset: number
|
|
310
|
+
skip(offset: number): IAsyncCollection<TInput>;
|
|
267
311
|
/**
|
|
268
312
|
* The <i>skipUntil</i> method skips items until <i>predicateFn</i> returns true.
|
|
269
313
|
* @example
|
|
314
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
315
|
+
*
|
|
270
316
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]).skipUntil(item => item >= 3);
|
|
271
317
|
* await collection.toArray();
|
|
272
318
|
* // [3, 4]
|
|
273
319
|
*/
|
|
274
|
-
skipUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
320
|
+
skipUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
275
321
|
/**
|
|
276
322
|
* The <i>skipWhile</i> method skips items until <i>predicateFn</i> returns false.
|
|
277
323
|
* @example
|
|
324
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
325
|
+
*
|
|
278
326
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]).skipWhile(item => item <= 3);
|
|
279
327
|
* await collection.toArray();
|
|
280
328
|
* // [4]
|
|
281
329
|
*/
|
|
282
|
-
skipWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
330
|
+
skipWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
283
331
|
/**
|
|
284
332
|
* The <i>when</i> method will execute <i>callback</i> when <i>condition</i> evaluates to true.
|
|
285
333
|
* @example
|
|
334
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
335
|
+
*
|
|
286
336
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4])
|
|
287
337
|
* .when(true, collection => collection.append([-3]))
|
|
288
338
|
* .when(false, collection => collection.append([20]));
|
|
@@ -293,11 +343,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
293
343
|
/**
|
|
294
344
|
* The <i>whenEmpty</i> method will execute <i>callback</i> when the collection is empty.
|
|
295
345
|
* @example
|
|
346
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
347
|
+
*
|
|
296
348
|
* const collection = new AsyncIterableCollection([])
|
|
297
349
|
* .whenEmpty(collection => collection.append([-3]))
|
|
298
350
|
* await collection.toArray();
|
|
299
351
|
* // [-3]
|
|
300
352
|
* @example
|
|
353
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
354
|
+
*
|
|
301
355
|
* const collection = new AsyncIterableCollection([1])
|
|
302
356
|
* .whenEmpty(collection => collection.append([-3]))
|
|
303
357
|
* await collection.toArray();
|
|
@@ -307,6 +361,8 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
307
361
|
/**
|
|
308
362
|
* The <i>whenNot</i> method will execute <i>callback</i> when <i>condition</i> evaluates to false.
|
|
309
363
|
* @example
|
|
364
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
365
|
+
*
|
|
310
366
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4])
|
|
311
367
|
* .whenNot(true, collection => collection.append([-3]))
|
|
312
368
|
* .whenNot(false, collection => collection.append([20]));
|
|
@@ -317,11 +373,15 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
317
373
|
/**
|
|
318
374
|
* The <i>whenNotEmpty</i> method will execute <i>callback</i> when the collection is not empty.
|
|
319
375
|
* @example
|
|
376
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
377
|
+
*
|
|
320
378
|
* const collection = new AsyncIterableCollection([])
|
|
321
379
|
* .whenNotEmpty(collection => collection.append([-3]))
|
|
322
380
|
* await collection.toArray();
|
|
323
381
|
* // []
|
|
324
382
|
* @example
|
|
383
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
384
|
+
*
|
|
325
385
|
* const collection = new AsyncIterableCollection([1])
|
|
326
386
|
* .whenNotEmpty(collection => collection.append([-3]))
|
|
327
387
|
* await collection.toArray();
|
|
@@ -332,31 +392,36 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
332
392
|
* The <i>pipe</i> method passes the orignal collection to <i>callback</i> and returns the result from <i>callback</i>.
|
|
333
393
|
* This method is useful when you want compose multiple smaller functions.
|
|
334
394
|
* @example
|
|
335
|
-
*
|
|
395
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
336
396
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
397
|
+
* const collection = new AsyncIterableCollection([1, "2", "a", 1, 3, {}]);
|
|
398
|
+
* function toNbrs<TInput>(
|
|
399
|
+
* collection: IAsyncCollection<TInput>,
|
|
400
|
+
* ): IAsyncCollection<number> {
|
|
401
|
+
* return collection
|
|
402
|
+
* .map((item) => Number(item))
|
|
403
|
+
* .reject((nbr) => Number.isNaN(nbr));
|
|
339
404
|
* }
|
|
340
|
-
* function nbrToStr(collection: IAsyncCollection<number>):
|
|
341
|
-
* return collection.
|
|
405
|
+
* function nbrToStr(collection: IAsyncCollection<number>): number[] {
|
|
406
|
+
* return collection.repeat(2).toArray();
|
|
342
407
|
* }
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
* .then(nbrToStr);
|
|
347
|
-
* // "\x01_\x02_\x01_\x03_\x01_\x02_\x01_\x03"
|
|
408
|
+
* const piped = await collection.pipe(toNbrs).then(nbrToStr);
|
|
409
|
+
* console.log(piped);
|
|
410
|
+
* // [ 1, 2, 1, 3 ]
|
|
348
411
|
*/
|
|
349
412
|
pipe<TOutput = TInput>(callback: AsyncTransform<IAsyncCollection<TInput>, TOutput>): Promise<TOutput>;
|
|
350
413
|
/**
|
|
351
414
|
* The <i>tap</i> method passes a copy of the original collection to <i>callback</i>, allowing you to do something with the items while not affecting the original collection.
|
|
352
415
|
* @example
|
|
353
|
-
*
|
|
416
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
417
|
+
*
|
|
418
|
+
* const collection = await new AsyncIterableCollection([1, 2, 3, 4, 5, 6])
|
|
354
419
|
* .tap(collection => {
|
|
355
420
|
* collection
|
|
356
421
|
* .filter(value => value % 2 === 0)
|
|
357
422
|
* .forEach(value => console.log(value))
|
|
358
|
-
* })
|
|
359
|
-
*
|
|
423
|
+
* })
|
|
424
|
+
* .toArray();
|
|
360
425
|
* // [1, 2, 3, 4, 5, 6]
|
|
361
426
|
*/
|
|
362
427
|
tap(callback: AsyncTap<IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
@@ -364,9 +429,11 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
364
429
|
* The <i>chunk</i> method breaks the collection into multiple, smaller collections of size <i>chunkSize</i>.
|
|
365
430
|
* If <i>chunkSize</i> is not divisible with total number of items then the last chunk will contain the remaining items.
|
|
366
431
|
* @example
|
|
432
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
433
|
+
*
|
|
367
434
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6, 7]);
|
|
368
435
|
* const chunks = collection.chunk(4);
|
|
369
|
-
* await chunks.toArray();
|
|
436
|
+
* await chunks.map(chunk => chunk.toArray()).toArray();
|
|
370
437
|
* // [[1, 2, 3, 4], [5, 6, 7]]
|
|
371
438
|
*/
|
|
372
439
|
chunk(chunkSize: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
@@ -374,54 +441,69 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
374
441
|
* The <i>chunkWhile</i> method breaks the collection into multiple, smaller collections based on the evaluation of <i>predicateFn</i>.
|
|
375
442
|
* The chunk variable passed to the <i>predicateFn</i> may be used to inspect the previous item.
|
|
376
443
|
* @example
|
|
444
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
445
|
+
*
|
|
377
446
|
* const collection = new AsyncIterableCollection("AABBCCCD");
|
|
378
447
|
* const chunks = collection.chunkWhile((value, index, chunk) => {
|
|
379
448
|
* return value === chunk.last();
|
|
380
449
|
* });
|
|
381
|
-
* await chunks.toArray();
|
|
450
|
+
* await chunks.map(chunk => chunk.toArray()).toArray();
|
|
382
451
|
* // [["A", "A"], ["B", "B"], ["C", "C", "C"], ["D"]]
|
|
383
452
|
*/
|
|
384
|
-
chunkWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
453
|
+
chunkWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
385
454
|
/**
|
|
386
455
|
* The <i>split</i> method breaks a collection evenly into <i>chunkAmount</i> of chunks.
|
|
387
456
|
* @example
|
|
457
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
458
|
+
*
|
|
388
459
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5]);
|
|
389
460
|
* const chunks = collection.split(3);
|
|
390
|
-
* await chunks.toArray();
|
|
461
|
+
* await chunks.map(chunk => chunk.toArray()).toArray();
|
|
391
462
|
* // [[1, 2], [3, 4], [5]]
|
|
392
463
|
* @example
|
|
464
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
465
|
+
*
|
|
393
466
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6]);
|
|
394
467
|
* const chunks = collection.split(3);
|
|
395
|
-
* await chunks.toArray();
|
|
468
|
+
* await chunks.map(chunk => chunk.toArray()).toArray();
|
|
396
469
|
* // [[1, 2], [3, 4], [5, 6]]
|
|
397
470
|
* @example
|
|
471
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
472
|
+
*
|
|
398
473
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6, 7]);
|
|
399
474
|
* const chunks = collection.split(3);
|
|
400
|
-
* await chunks.toArray();
|
|
475
|
+
* await chunks.map(chunk => chunk.toArray()).toArray();
|
|
401
476
|
* // [[1, 2, 7], [3, 4], [5, 6]]
|
|
402
477
|
*/
|
|
403
|
-
split(chunkAmount: number
|
|
478
|
+
split(chunkAmount: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
404
479
|
/**
|
|
405
480
|
* The <i>partition</i> method is used to separate items that pass <i>predicateFn</i> from those that do not.
|
|
406
481
|
* @example
|
|
482
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
483
|
+
*
|
|
407
484
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6]);
|
|
408
|
-
* collection.partition(item => item < 3);
|
|
409
|
-
* await
|
|
485
|
+
* const chunks = collection.partition(item => item < 3);
|
|
486
|
+
* await chunks.map(chunk => chunk.toArray()).toArray();
|
|
410
487
|
* // [[1, 2], [3, 4, 5, 6]]
|
|
411
488
|
*/
|
|
412
|
-
partition(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
489
|
+
partition(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
413
490
|
/**
|
|
414
491
|
* The <i>sliding</i> method returns a new collection of chunks representing a "sliding window" view of the items in the collection.
|
|
415
492
|
* @example
|
|
416
|
-
*
|
|
417
|
-
*
|
|
493
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
494
|
+
*
|
|
495
|
+
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5])
|
|
496
|
+
* const chunks = collection.sliding(2);
|
|
497
|
+
* await chunks.map(chunk => chunk.toArray()).toArray();
|
|
418
498
|
* // [[1, 2], [2, 3], [3, 4], [4, 5]]
|
|
419
499
|
*/
|
|
420
|
-
sliding(
|
|
500
|
+
sliding(chunkSize: number, step?: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
421
501
|
/**
|
|
422
|
-
* The <i>groupBy</i> method groups the collection's items by
|
|
502
|
+
* The <i>groupBy</i> method groups the collection's items by <i> selectFn </i>.
|
|
423
503
|
* By default the equality check occurs on the item.
|
|
424
504
|
* @example
|
|
505
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
506
|
+
*
|
|
425
507
|
* const collection = new AsyncIterableCollection(["a", "a", "a", "b", "b", "c"]);
|
|
426
508
|
* const group = await collection
|
|
427
509
|
* .groupBy()
|
|
@@ -442,11 +524,11 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
442
524
|
* // ]
|
|
443
525
|
* // ]
|
|
444
526
|
* @example
|
|
527
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
528
|
+
*
|
|
445
529
|
* const collection = new AsyncIterableCollection(["alice@gmail.com", "bob@yahoo.com", "carlos@gmail.com"]);
|
|
446
530
|
* const group = await collection
|
|
447
|
-
* .groupBy(
|
|
448
|
-
* selectFn: item => item.split("@")[1]
|
|
449
|
-
* })
|
|
531
|
+
* .groupBy(item => item.split("@")[1])
|
|
450
532
|
* .map(([key, collection]) => [key, collection.toArray()])
|
|
451
533
|
* .toArray();
|
|
452
534
|
* // [
|
|
@@ -460,11 +542,13 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
460
542
|
* // ]
|
|
461
543
|
* // ]
|
|
462
544
|
*/
|
|
463
|
-
groupBy<TOutput = TInput>(
|
|
545
|
+
groupBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<RecordItem<TOutput, IAsyncCollection<TInput>>>;
|
|
464
546
|
/**
|
|
465
|
-
* The <i>countBy</i> method counts the occurrences of values in the collection by
|
|
547
|
+
* The <i>countBy</i> method counts the occurrences of values in the collection by <i> selectFn </i>.
|
|
466
548
|
* By default the equality check occurs on the item.
|
|
467
549
|
* @example
|
|
550
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
551
|
+
*
|
|
468
552
|
* const collection = new AsyncIterableCollection(["a", "a", "a", "b", "b", "c"]);
|
|
469
553
|
* const count = await collection
|
|
470
554
|
* .countBy()
|
|
@@ -476,27 +560,30 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
476
560
|
* // ["c", 1]
|
|
477
561
|
* // ]
|
|
478
562
|
* @example
|
|
563
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
564
|
+
*
|
|
479
565
|
* const collection = new AsyncIterableCollection(["alice@gmail.com", "bob@yahoo.com", "carlos@gmail.com"]);
|
|
480
566
|
* const count = await collection
|
|
481
|
-
* .countBy(
|
|
482
|
-
* selectFn: item => item.split("@")[1]
|
|
483
|
-
* })
|
|
484
|
-
* .map(([key, collection]) => [key, collection.toArray()])
|
|
567
|
+
* .countBy(item => item.split("@")[1])
|
|
485
568
|
* .toArray();
|
|
486
569
|
* // [
|
|
487
570
|
* // ["gmail.com", 2],
|
|
488
571
|
* // ["yahoo.com", 1]
|
|
489
572
|
* // ]
|
|
490
573
|
*/
|
|
491
|
-
countBy<TOutput = TInput>(
|
|
574
|
+
countBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<RecordItem<TOutput, number>>;
|
|
492
575
|
/**
|
|
493
|
-
* The <i>unique</i> method removes all duplicate values from the collection by
|
|
576
|
+
* The <i>unique</i> method removes all duplicate values from the collection by <i> selectFn </i>.
|
|
494
577
|
* By default the equality check occurs on the item.
|
|
495
578
|
* @example
|
|
579
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
580
|
+
*
|
|
496
581
|
* const collection = new AsyncIterableCollection([1, 1, 2, 2, 3, 4, 2]);
|
|
497
582
|
* await collection.unique().toArray();
|
|
498
583
|
* // [1, 2, 3, 4]
|
|
499
584
|
* @example
|
|
585
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
586
|
+
*
|
|
500
587
|
* const collection = new AsyncIterableCollection([
|
|
501
588
|
* { name: "iPhone 6", brand: "Apple", type: "phone" },
|
|
502
589
|
* { name: "iPhone 5", brand: "Apple", type: "phone" },
|
|
@@ -512,16 +599,20 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
512
599
|
* // { name: "Galaxy S6", brand: "Samsung", type: "phone" },
|
|
513
600
|
* // ]
|
|
514
601
|
*/
|
|
515
|
-
unique<TOutput = TInput>(
|
|
602
|
+
unique<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TInput>;
|
|
516
603
|
/**
|
|
517
604
|
* The <i>difference</i> method will return the values in the original collection that are not present in <i>iterable</i>.
|
|
518
605
|
* By default the equality check occurs on the item.
|
|
519
606
|
* @example
|
|
607
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
608
|
+
*
|
|
520
609
|
* const collection = new AsyncIterableCollection([1, 2, 2, 3, 4, 5]);
|
|
521
610
|
* const difference = collection.difference([2, 4, 6, 8]);
|
|
522
611
|
* await difference.toArray();
|
|
523
612
|
* // [1, 3, 5]
|
|
524
613
|
* @example
|
|
614
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
615
|
+
*
|
|
525
616
|
* const collection = new AsyncIterableCollection([
|
|
526
617
|
* { name: "iPhone 6", brand: "Apple", type: "phone" },
|
|
527
618
|
* { name: "iPhone 5", brand: "Apple", type: "phone" },
|
|
@@ -546,6 +637,8 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
546
637
|
/**
|
|
547
638
|
* The <i>repeat</i> method will repeat the original collection <i>amount</i> times.
|
|
548
639
|
* @example
|
|
640
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
641
|
+
*
|
|
549
642
|
* const collection = new AsyncIterableCollection([1, 2, 3]);
|
|
550
643
|
* const newCollection = collection.repeat(3);
|
|
551
644
|
* await newCollection.toArray();
|
|
@@ -556,90 +649,86 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
556
649
|
* The <i>padStart</i> method pads this collection with <i>fillItems</i> until the resulting collection size reaches <i>maxLength</i>.
|
|
557
650
|
* The padding is applied from the start of this collection.
|
|
558
651
|
* @example
|
|
559
|
-
*
|
|
560
|
-
*
|
|
652
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
653
|
+
*
|
|
654
|
+
* await new AsyncIterableCollection("abc").padStart(10, "foo").join("");
|
|
561
655
|
* // "foofoofabc"
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
* await collection.join({ seperator: ""});
|
|
656
|
+
*
|
|
657
|
+
* await new AsyncIterableCollection("abc").padStart(6, "123465").join("");
|
|
565
658
|
* // "123abc"
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
* await collection.join({ seperator: ""});
|
|
659
|
+
*
|
|
660
|
+
* await new AsyncIterableCollection("abc").padStart(8, "0").join("");
|
|
569
661
|
* // "00000abc"
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* await collection.join({ seperator: ""});
|
|
662
|
+
*
|
|
663
|
+
* await new AsyncIterableCollection("abc").padStart(1, "_").join("");
|
|
573
664
|
* // "abc"
|
|
574
665
|
*/
|
|
575
|
-
padStart<TExtended = TInput>(maxLength: number, fillItems:
|
|
666
|
+
padStart<TExtended = TInput>(maxLength: number, fillItems: AsyncIterableValue<TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
576
667
|
/**
|
|
577
668
|
* The <i>padEnd</i> method pads this collection with <i>fillItems</i> until the resulting collection size reaches <i>maxLength</i>.
|
|
578
669
|
* The padding is applied from the end of this collection.
|
|
579
670
|
* @example
|
|
580
|
-
*
|
|
581
|
-
*
|
|
671
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
672
|
+
*
|
|
673
|
+
* await new AsyncIterableCollection("abc").padEnd(10, "foo").join("");
|
|
582
674
|
* // "abcfoofoof"
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* await collection.join({ seperator: ""});
|
|
675
|
+
*
|
|
676
|
+
* await new AsyncIterableCollection("abc").padEnd(6, "123465").join("");
|
|
586
677
|
* // "abc123"
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
* await collection.join({ seperator: ""});
|
|
678
|
+
*
|
|
679
|
+
* await new AsyncIterableCollection("abc").padEnd(8, "0").join("");
|
|
590
680
|
* // "abc00000"
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
* await collection.join({ seperator: ""});
|
|
681
|
+
*
|
|
682
|
+
* await new AsyncIterableCollection("abc").padEnd(1, "_").join("");
|
|
594
683
|
* // "abc"
|
|
595
684
|
*/
|
|
596
|
-
padEnd<TExtended = TInput>(maxLength: number, fillItems:
|
|
685
|
+
padEnd<TExtended = TInput>(maxLength: number, fillItems: AsyncIterableValue<TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
597
686
|
/**
|
|
598
|
-
* The <i>slice</i> method creates porition of the original collection selected from
|
|
599
|
-
* where
|
|
687
|
+
* The <i>slice</i> method creates porition of the original collection selected from <i>start</i> and <i>end</i>
|
|
688
|
+
* where <i>start</i> and <i>end</i> (end not included) represent the index of items in the collection.
|
|
600
689
|
* @example
|
|
690
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
691
|
+
*
|
|
601
692
|
* const collection = new AsyncIterableCollection(["a", "b", "c", "d", "e", "f"]);
|
|
602
|
-
* await collection.slice(
|
|
603
|
-
* start: 3
|
|
604
|
-
* }).toArray();
|
|
693
|
+
* await collection.slice(3).toArray();
|
|
605
694
|
* // ["d", "e", "f"]
|
|
606
695
|
* @example
|
|
696
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
697
|
+
*
|
|
607
698
|
* const collection = new AsyncIterableCollection(["a", "b", "c", "d", "e", "f"]);
|
|
608
|
-
* await collection.slice(
|
|
609
|
-
* end: 2,
|
|
610
|
-
* }).toArray();
|
|
699
|
+
* await collection.slice(undefined, 2).toArray();
|
|
611
700
|
* // ["a", "b"]
|
|
612
701
|
* @example
|
|
702
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
703
|
+
*
|
|
613
704
|
* const collection = new AsyncIterableCollection(["a", "b", "c", "d", "e", "f"]);
|
|
614
|
-
* await collection.slice(
|
|
615
|
-
* start: 2
|
|
616
|
-
* end: 5,
|
|
617
|
-
* }).toArray();
|
|
705
|
+
* await collection.slice(2, 5).toArray();
|
|
618
706
|
* // ["c", "d", "e"]
|
|
619
707
|
* @example
|
|
708
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
709
|
+
*
|
|
620
710
|
* const collection = new AsyncIterableCollection(["a", "b", "c", "d", "e", "f"]);
|
|
621
|
-
* await collection.slice(
|
|
622
|
-
* start: -2
|
|
623
|
-
* }).toArray();
|
|
711
|
+
* await collection.slice(-2).toArray();
|
|
624
712
|
* // ["e", "f"]
|
|
625
713
|
* @example
|
|
714
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
715
|
+
*
|
|
626
716
|
* const collection = new AsyncIterableCollection(["a", "b", "c", "d", "e", "f"]);
|
|
627
|
-
* await collection.slice(
|
|
628
|
-
* end: -2
|
|
629
|
-
* }).toArray();
|
|
717
|
+
* await collection.slice(undefined, -2).toArray();
|
|
630
718
|
* // ["a", "b", "c", "d"]
|
|
631
719
|
* @example
|
|
720
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
721
|
+
*
|
|
632
722
|
* const collection = new AsyncIterableCollection(["a", "b", "c", "d", "e", "f"]);
|
|
633
|
-
* await collection.slice(
|
|
634
|
-
* start: -4,
|
|
635
|
-
* end: -2
|
|
636
|
-
* }).toArray();
|
|
723
|
+
* await collection.slice(-4, -2).toArray();
|
|
637
724
|
* // ["c", "d"]
|
|
638
725
|
*/
|
|
639
|
-
slice(
|
|
726
|
+
slice(start?: number, end?: number): IAsyncCollection<TInput>;
|
|
640
727
|
/**
|
|
641
728
|
* The <i>prepend</i> method adds <i>iterable</i> to the beginning of the collection.
|
|
642
729
|
* @example
|
|
730
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
731
|
+
*
|
|
643
732
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5]).prepend([-1, 20]);
|
|
644
733
|
* await collection.toArray();
|
|
645
734
|
* // [-1, 20, 1, 2, 3, 4, 5]
|
|
@@ -648,6 +737,8 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
648
737
|
/**
|
|
649
738
|
* The <i>append</i> method adds <i>iterable</i> to the end of the collection.
|
|
650
739
|
* @example
|
|
740
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
741
|
+
*
|
|
651
742
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5]).append([-1, -2]);
|
|
652
743
|
* await collection.toArray();
|
|
653
744
|
* // [1, 2, 3, 4, 5, -1, -2,]
|
|
@@ -656,25 +747,31 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
656
747
|
/**
|
|
657
748
|
* The <i>insertBefore</i> method adds <i>iterable</i> before the first item that matches <i>predicateFn</i>.
|
|
658
749
|
* @example
|
|
750
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
751
|
+
*
|
|
659
752
|
* const collection = new AsyncIterableCollection([1, 2, 2, 3, 4, 5]).insertBefore(item => item === 2, [-1, 20]);
|
|
660
753
|
* await collection.toArray();
|
|
661
754
|
* // [1, -1, 20, 2, 2, 3, 4, 5]
|
|
662
755
|
*/
|
|
663
|
-
insertBefore<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended
|
|
756
|
+
insertBefore<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
664
757
|
/**
|
|
665
758
|
* The <i>insertAfter</i> method adds <i>iterable</i> after the first item that matches <i>predicateFn</i>.
|
|
666
759
|
* @example
|
|
760
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
761
|
+
*
|
|
667
762
|
* const collection = new AsyncIterableCollection([1, 2, 2, 3, 4, 5]).insertAfter(item => item === 2, [-1, 20]);
|
|
668
763
|
* await collection.toArray();
|
|
669
764
|
* // [1, 2, -1, 20, 2, 3, 4, 5]
|
|
670
765
|
*/
|
|
671
|
-
insertAfter<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended
|
|
766
|
+
insertAfter<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
672
767
|
/**
|
|
673
768
|
* The <i>crossJoin</i> method cross joins the collection's values among <i>iterables</i>, returning a Cartesian product with all possible permutations.
|
|
674
769
|
* @example
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
770
|
+
* import { ListCollection } from "@daiso-tech/core";;
|
|
771
|
+
*
|
|
772
|
+
* const collection = new ListCollection([1, 2]);
|
|
773
|
+
* const matrix = collection.cross(["a", "b"]);
|
|
774
|
+
* await matrix.toArray();
|
|
678
775
|
* // [
|
|
679
776
|
* // [1, "a"],
|
|
680
777
|
* // [1, "b"],
|
|
@@ -682,9 +779,11 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
682
779
|
* // [2, "b"],
|
|
683
780
|
* // ]
|
|
684
781
|
* @example
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
782
|
+
* import { ListCollection } from "@daiso-tech/core";;
|
|
783
|
+
*
|
|
784
|
+
* const collection = new ListCollection([1, 2]);
|
|
785
|
+
* const matrix = collection.cross(["a", "b"]).cross(["I", "II"]);
|
|
786
|
+
* await matrix.toArray();
|
|
688
787
|
* // [
|
|
689
788
|
* // [1, "a", "I"],
|
|
690
789
|
* // [1, "a", "II"],
|
|
@@ -696,34 +795,44 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
696
795
|
* // [2, "b", "II"],
|
|
697
796
|
* // ]
|
|
698
797
|
*/
|
|
699
|
-
crossJoin<TExtended
|
|
798
|
+
crossJoin<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<CrossJoinResult<TInput, TExtended>>;
|
|
700
799
|
/**
|
|
701
800
|
* The <i>zip</i> method merges together the values of <i>iterable</i> with the values of the collection at their corresponding index.
|
|
702
801
|
* The returned collection has size of the shortest collection.
|
|
703
802
|
* @example
|
|
803
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
804
|
+
*
|
|
704
805
|
* const collection = new AsyncIterableCollection(["Chair", "Desk"]);
|
|
705
806
|
* const zipped = collection.zip([100, 200]);
|
|
706
807
|
* await zipped.toArray();
|
|
707
|
-
* // [["
|
|
808
|
+
* // [["Chair", 100], ["Desk", 200]]
|
|
708
809
|
* @example
|
|
810
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
811
|
+
*
|
|
709
812
|
* const collection = new AsyncIterableCollection(["Chair", "Desk", "Couch"]);
|
|
710
813
|
* const zipped = collection.zip([100, 200]);
|
|
711
814
|
* await zipped.toArray();
|
|
712
|
-
* // [["
|
|
815
|
+
* // [["Chair", 100], ["Desk", 200]]
|
|
713
816
|
* @example
|
|
817
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
818
|
+
*
|
|
714
819
|
* const collection = new AsyncIterableCollection(["Chair", "Desk"]);
|
|
715
820
|
* const zipped = collection.zip([100, 200, 300]);
|
|
716
821
|
* await zipped.toArray();
|
|
717
|
-
* // [["
|
|
822
|
+
* // [["Chair", 100], ["Desk", 200]]
|
|
718
823
|
*/
|
|
719
824
|
zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<RecordItem<TInput, TExtended>>;
|
|
720
825
|
/**
|
|
721
826
|
* The <i>sort</i> method sorts the collection. You can provide a <i>comparator</i> function.
|
|
722
827
|
* @example
|
|
828
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
829
|
+
*
|
|
723
830
|
* const collection = new AsyncIterableCollection([-1, 2, 4, 3]);
|
|
724
831
|
* await collection.sort().toArray();
|
|
725
832
|
* // [-1, 2, 3, 4]
|
|
726
833
|
* @example
|
|
834
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
835
|
+
*
|
|
727
836
|
* const collection = new AsyncIterableCollection([
|
|
728
837
|
* { name: "Anders", age: 30 },
|
|
729
838
|
* { name: "Joe", age: 20 },
|
|
@@ -741,310 +850,345 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
741
850
|
sort(comparator?: Comparator<TInput>): IAsyncCollection<TInput>;
|
|
742
851
|
/**
|
|
743
852
|
* The <i>reverse</i> method will reverse the order of the collection.
|
|
744
|
-
* The reversing of the collection will be applied in chunks that are the size of <i>
|
|
853
|
+
* The reversing of the collection will be applied in chunks that are the size of <i> chunkSize </i>.
|
|
745
854
|
* @example
|
|
855
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
856
|
+
*
|
|
746
857
|
* const collection = new AsyncIterableCollection([-1, 2, 4, 3]);
|
|
747
858
|
* await collection.reverse().toArray();
|
|
748
859
|
* // [3, 4, 2, -1]
|
|
749
860
|
*/
|
|
750
|
-
reverse(
|
|
861
|
+
reverse(chunkSize?: number): IAsyncCollection<TInput>;
|
|
751
862
|
/**
|
|
752
|
-
* The <i>shuffle</i> method randomly shuffles the items in the collection.
|
|
863
|
+
* The <i>shuffle</i> method randomly shuffles the items in the collection. You can provide a custom Math.random function by passing in <i>mathRandom</i>.
|
|
753
864
|
*/
|
|
754
|
-
shuffle(): IAsyncCollection<TInput>;
|
|
865
|
+
shuffle(mathRandom?: () => number): IAsyncCollection<TInput>;
|
|
755
866
|
/**
|
|
756
|
-
* The <i>first</i> method returns the first item in the collection that passes <i>
|
|
757
|
-
* By default it will get the first item. If the collection is empty or no items passes <i>
|
|
867
|
+
* The <i>first</i> method returns the first item in the collection that passes <i> predicateFn </i>.
|
|
868
|
+
* By default it will get the first item. If the collection is empty or no items passes <i> predicateFn </i> than null i returned.
|
|
758
869
|
* @example
|
|
870
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
871
|
+
*
|
|
759
872
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
760
873
|
* await collection.first();
|
|
761
874
|
* // 1
|
|
762
875
|
* @example
|
|
876
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
877
|
+
*
|
|
763
878
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
764
|
-
* await collection.first(
|
|
765
|
-
* predicateFn: item => item > 2
|
|
766
|
-
* });
|
|
879
|
+
* await collection.first(item => item > 2);
|
|
767
880
|
* // 3
|
|
768
881
|
* @example
|
|
882
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
883
|
+
*
|
|
769
884
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
770
|
-
* await collection.first(
|
|
771
|
-
* predicateFn: item => item > 10
|
|
772
|
-
* });
|
|
885
|
+
* await collection.first(item => item > 10);
|
|
773
886
|
* // null
|
|
774
887
|
* @throws {CollectionError} {@link CollectionError}
|
|
775
888
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
776
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
777
889
|
* // 3
|
|
778
890
|
*/
|
|
779
|
-
first<TOutput extends TInput>(
|
|
891
|
+
first<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput | null>;
|
|
780
892
|
/**
|
|
781
|
-
* The <i>firstOr</i> method returns the first item in the collection that passes <i>
|
|
782
|
-
* By default it will get the first item. If the collection is empty or no items passes <i>
|
|
893
|
+
* The <i>firstOr</i> method returns the first item in the collection that passes <i> predicateFn </i>
|
|
894
|
+
* By default it will get the first item. If the collection is empty or no items passes <i> predicateFn </i> than <i> defaultValue </i>.
|
|
783
895
|
* @example
|
|
896
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
897
|
+
*
|
|
784
898
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
785
|
-
* await collection.firstOr(
|
|
786
|
-
* defaultValue: -1
|
|
787
|
-
* });
|
|
899
|
+
* await collection.firstOr(-1);
|
|
788
900
|
* // 1
|
|
789
901
|
* @example
|
|
902
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
903
|
+
*
|
|
790
904
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
791
|
-
* await collection.firstOr(
|
|
792
|
-
* predicateFn: item => item > 2,
|
|
793
|
-
* defaultValue: -1
|
|
794
|
-
* });
|
|
905
|
+
* await collection.firstOr(-1, item => item > 2);
|
|
795
906
|
* // 3
|
|
796
907
|
* @example
|
|
908
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
909
|
+
*
|
|
797
910
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
798
|
-
* await collection.firstOr(
|
|
799
|
-
* predicateFn: item => item > 10,
|
|
800
|
-
* defaultValue: -1
|
|
801
|
-
* });
|
|
911
|
+
* await collection.firstOr(-1, item => item > 10);
|
|
802
912
|
* // -1
|
|
803
913
|
* @example
|
|
914
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
915
|
+
*
|
|
804
916
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
805
|
-
* await collection.firstOr(
|
|
806
|
-
* predicateFn: item => item > 10,
|
|
807
|
-
* defaultValue: () => -1
|
|
808
|
-
* });
|
|
917
|
+
* await collection.firstOr(() => -1, item => item > 10);
|
|
809
918
|
* // -1
|
|
810
919
|
* @throws {CollectionError} {@link CollectionError}
|
|
811
920
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
812
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
813
921
|
*/
|
|
814
|
-
firstOr<TOutput extends TInput, TExtended = TInput>(
|
|
922
|
+
firstOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput | TExtended>;
|
|
815
923
|
/**
|
|
816
|
-
* The <i>firstOrFail</i> method returns the first item in the collection that passes <i>
|
|
817
|
-
* By default it will get the first item. If the collection is empty or no items passes <i>
|
|
924
|
+
* The <i>firstOrFail</i> method returns the first item in the collection that passes <i> predicateFn </i>.
|
|
925
|
+
* By default it will get the first item. If the collection is empty or no items passes <i> predicateFn </i> than error is thrown.
|
|
818
926
|
* @example
|
|
927
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
928
|
+
*
|
|
819
929
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
820
930
|
* await collection.firstOrFail();
|
|
821
931
|
* // 1
|
|
822
932
|
* @example
|
|
933
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
934
|
+
*
|
|
823
935
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
824
|
-
* await collection.firstOrFail(
|
|
825
|
-
* predicateFn: item => item > 2
|
|
826
|
-
* });
|
|
936
|
+
* await collection.firstOrFail(item => item > 2);
|
|
827
937
|
* // 3
|
|
828
938
|
* @example
|
|
939
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
940
|
+
*
|
|
829
941
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
830
|
-
* await collection.firstOrFail(
|
|
831
|
-
* predicateFn: item => item > 10
|
|
832
|
-
* });
|
|
942
|
+
* await collection.firstOrFail(item => item > 10);
|
|
833
943
|
* // throws an error
|
|
834
944
|
* @throws {CollectionError} {@link CollectionError}
|
|
835
945
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
836
|
-
* @throws {
|
|
837
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
946
|
+
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
838
947
|
*/
|
|
839
|
-
firstOrFail<TOutput extends TInput>(
|
|
948
|
+
firstOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput>;
|
|
840
949
|
/**
|
|
841
|
-
* The <i>last</i> method returns the last item in the collection that passes <i>
|
|
842
|
-
* By default it will get the last item. If the collection is empty or no items passes <i>
|
|
950
|
+
* The <i>last</i> method returns the last item in the collection that passes <i> predicateFn </i>.
|
|
951
|
+
* By default it will get the last item. If the collection is empty or no items passes <i> predicateFn </i> than null i returned.
|
|
843
952
|
* @example
|
|
953
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
954
|
+
*
|
|
844
955
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
845
956
|
* await collection.last();
|
|
846
|
-
* //
|
|
957
|
+
* // 4
|
|
847
958
|
* @example
|
|
959
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
960
|
+
*
|
|
848
961
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
849
|
-
* await collection.last(
|
|
850
|
-
* predicateFn: item => item > 2
|
|
851
|
-
* });
|
|
962
|
+
* await collection.last(item => item < 4);
|
|
852
963
|
* // 3
|
|
853
964
|
* @example
|
|
965
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
966
|
+
*
|
|
854
967
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
855
|
-
* await collection.last(
|
|
856
|
-
* predicateFn: item => item > 10
|
|
857
|
-
* });
|
|
968
|
+
* await collection.last(item => item > 10);
|
|
858
969
|
* // null
|
|
859
970
|
* @throws {CollectionError} {@link CollectionError}
|
|
860
971
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
861
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
862
972
|
* // 3
|
|
863
973
|
*/
|
|
864
|
-
last<TOutput extends TInput>(
|
|
974
|
+
last<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput | null>;
|
|
865
975
|
/**
|
|
866
|
-
* The <i>lastOr</i> method returns the last item in the collection that passes <i>
|
|
867
|
-
* By default it will get the last item. If the collection is empty or no items passes <i>
|
|
976
|
+
* The <i>lastOr</i> method returns the last item in the collection that passes <i> predicateFn </i>.
|
|
977
|
+
* By default it will get the last item. If the collection is empty or no items passes <i> predicateFn </i> than <i> defaultValue </i>.
|
|
868
978
|
* @example
|
|
979
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
980
|
+
*
|
|
869
981
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
870
|
-
* await collection.lastOr(
|
|
871
|
-
*
|
|
872
|
-
* });
|
|
873
|
-
* // 1
|
|
982
|
+
* await collection.lastOr(-1);
|
|
983
|
+
* // 4
|
|
874
984
|
* @example
|
|
985
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
986
|
+
*
|
|
875
987
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
876
|
-
* await collection.lastOr(
|
|
877
|
-
* predicateFn: item => item > 2,
|
|
878
|
-
* defaultValue: -1
|
|
879
|
-
* });
|
|
988
|
+
* await collection.lastOr(-1, item => item < 4);
|
|
880
989
|
* // 3
|
|
881
990
|
* @example
|
|
991
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
992
|
+
*
|
|
882
993
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
883
|
-
* await collection.lastOr(
|
|
884
|
-
* predicateFn: item => item > 10,
|
|
885
|
-
* defaultValue: -1
|
|
886
|
-
* });
|
|
994
|
+
* await collection.lastOr(-1, item => item > 10);
|
|
887
995
|
* // -1
|
|
888
996
|
* @example
|
|
997
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
998
|
+
*
|
|
889
999
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
890
|
-
* await collection.lastOr(
|
|
891
|
-
* predicateFn: item => item > 10,
|
|
892
|
-
* defaultValue: () => -1
|
|
893
|
-
* });
|
|
1000
|
+
* await collection.lastOr(() => -1, item => item > 10);
|
|
894
1001
|
* // -1
|
|
895
1002
|
* @throws {CollectionError} {@link CollectionError}
|
|
896
1003
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
897
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
898
1004
|
*/
|
|
899
|
-
lastOr<TOutput extends TInput, TExtended = TInput>(
|
|
1005
|
+
lastOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput | TExtended>;
|
|
900
1006
|
/**
|
|
901
|
-
* The <i>lastOrFail</i> method returns the last item in the collection that passes <i>
|
|
902
|
-
* By default it will get the last item. If the collection is empty or no items passes <i>
|
|
1007
|
+
* The <i>lastOrFail</i> method returns the last item in the collection that passes <i> predicateFn </i>.
|
|
1008
|
+
* By default it will get the last item. If the collection is empty or no items passes <i> predicateFn </i> than error is thrown.
|
|
903
1009
|
* @example
|
|
1010
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1011
|
+
*
|
|
904
1012
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
905
1013
|
* await collection.lastOrFail();
|
|
906
|
-
* //
|
|
1014
|
+
* // 4
|
|
907
1015
|
* @example
|
|
1016
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1017
|
+
*
|
|
908
1018
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
909
|
-
* await collection.lastOrFail(
|
|
910
|
-
* predicateFn: item => item > 2
|
|
911
|
-
* });
|
|
1019
|
+
* await collection.lastOrFail(item => item < 4);
|
|
912
1020
|
* // 3
|
|
913
1021
|
* @example
|
|
1022
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1023
|
+
*
|
|
914
1024
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
915
|
-
* await collection.lastOrFail(
|
|
916
|
-
* predicateFn: item => item > 10
|
|
917
|
-
* });
|
|
1025
|
+
* await collection.lastOrFail(item => item > 10);
|
|
918
1026
|
* // throws an error
|
|
919
1027
|
* @throws {CollectionError} {@link CollectionError}
|
|
920
1028
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
921
|
-
* @throws {
|
|
922
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1029
|
+
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
923
1030
|
*/
|
|
924
|
-
lastOrFail<TOutput extends TInput>(
|
|
1031
|
+
lastOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput>;
|
|
925
1032
|
/**
|
|
926
1033
|
* The <i>before</i> method returns the item that comes before the first item that matches <i>predicateFn</i>.
|
|
927
1034
|
* If the <i>predicateFn</i> does not match or matches the first item then null is returned.
|
|
928
1035
|
* @example
|
|
1036
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1037
|
+
*
|
|
929
1038
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
930
1039
|
* await collection.before(item => item === 2);
|
|
931
1040
|
* // 1
|
|
932
1041
|
* @example
|
|
1042
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1043
|
+
*
|
|
933
1044
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
934
1045
|
* await collection.before(item => item === 1);
|
|
935
1046
|
* // null
|
|
936
1047
|
* @throws {CollectionError} {@link CollectionError}
|
|
937
1048
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
938
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
939
1049
|
*/
|
|
940
|
-
before(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1050
|
+
before(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<TInput | null>;
|
|
941
1051
|
/**
|
|
942
1052
|
* The <i>beforeOr</i> method returns the item that comes before the first item that matches <i>predicateFn</i>.
|
|
943
1053
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the first item then <i>defaultValue</i> is returned.
|
|
944
1054
|
* @example
|
|
1055
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1056
|
+
*
|
|
945
1057
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
946
1058
|
* await collection.beforeOr(-1, item => item === 2);
|
|
947
1059
|
* // 1
|
|
948
1060
|
* @example
|
|
1061
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1062
|
+
*
|
|
949
1063
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
950
1064
|
* await collection.beforeOr(-1, item => item === 1);
|
|
951
1065
|
* // -1
|
|
952
1066
|
* @example
|
|
1067
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1068
|
+
*
|
|
953
1069
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
954
1070
|
* await collection.beforeOr(() => -1, item => item === 1);
|
|
955
1071
|
* // -1
|
|
956
1072
|
* @throws {CollectionError} {@link CollectionError}
|
|
957
1073
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
958
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
959
1074
|
*/
|
|
960
|
-
beforeOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1075
|
+
beforeOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<TInput | TExtended>;
|
|
961
1076
|
/**
|
|
962
1077
|
* The <i>beforeOrFail</i> method returns the item that comes before the first item that matches <i>predicateFn</i>.
|
|
963
1078
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the first item then an error is thrown.
|
|
964
1079
|
* @example
|
|
1080
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1081
|
+
*
|
|
965
1082
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
966
1083
|
* await collection.beforeOrFail(item => item === 2);
|
|
967
1084
|
* // 1
|
|
968
1085
|
* @example
|
|
1086
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1087
|
+
*
|
|
969
1088
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
970
1089
|
* await collection.beforeOrFail(item => item === 1);
|
|
971
1090
|
* // error is thrown
|
|
972
1091
|
* @throws {CollectionError} {@link CollectionError}
|
|
973
1092
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
974
|
-
* @throws {
|
|
975
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1093
|
+
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
976
1094
|
*/
|
|
977
|
-
beforeOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1095
|
+
beforeOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<TInput>;
|
|
978
1096
|
/**
|
|
979
1097
|
* The <i>after</i> method returns the item that comes after the first item that matches <i>predicateFn</i>.
|
|
980
1098
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the last item then null is returned.
|
|
981
1099
|
* @example
|
|
1100
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1101
|
+
*
|
|
982
1102
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
983
1103
|
* await collection.after(item => item === 2);
|
|
984
|
-
* //
|
|
1104
|
+
* // 3
|
|
985
1105
|
* @example
|
|
1106
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1107
|
+
*
|
|
986
1108
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
987
|
-
* await collection.after(item => item ===
|
|
1109
|
+
* await collection.after(item => item === 4);
|
|
988
1110
|
* // null
|
|
989
1111
|
* @throws {CollectionError} {@link CollectionError}
|
|
990
1112
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
991
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
992
1113
|
*/
|
|
993
|
-
after(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1114
|
+
after(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<TInput | null>;
|
|
994
1115
|
/**
|
|
995
1116
|
* The <i>afterOr</i> method returns the item that comes after the first item that matches <i>predicateFn</i>.
|
|
996
1117
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the last item then <i>defaultValue</i> is returned.
|
|
997
1118
|
* @example
|
|
1119
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1120
|
+
*
|
|
998
1121
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
999
1122
|
* await collection.afterOr(-1, item => item === 2);
|
|
1000
|
-
* //
|
|
1123
|
+
* // 3
|
|
1001
1124
|
* @example
|
|
1125
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1126
|
+
*
|
|
1002
1127
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
1003
|
-
* await collection.afterOr(-1, item => item ===
|
|
1128
|
+
* await collection.afterOr(-1, item => item === 4);
|
|
1004
1129
|
* // -1
|
|
1005
1130
|
* @example
|
|
1131
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1132
|
+
*
|
|
1006
1133
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
1007
|
-
* await collection.afterOr(() => -1, item => item ===
|
|
1134
|
+
* await collection.afterOr(() => -1, item => item === 4);
|
|
1008
1135
|
* // -1
|
|
1009
1136
|
* @throws {CollectionError} {@link CollectionError}
|
|
1010
1137
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1011
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1012
1138
|
*/
|
|
1013
|
-
afterOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1139
|
+
afterOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<TInput | TExtended>;
|
|
1014
1140
|
/**
|
|
1015
1141
|
* The <i>afterOrFail</i> method returns the item that comes after the first item that matches <i>predicateFn</i>.
|
|
1016
1142
|
* If the collection is empty or the <i>predicateFn</i> does not match or matches the last item then an error is thrown.
|
|
1017
1143
|
* @example
|
|
1144
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1145
|
+
*
|
|
1018
1146
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
1019
1147
|
* await collection.afterOrFail(item => item === 2);
|
|
1020
|
-
* //
|
|
1148
|
+
* // 3
|
|
1021
1149
|
* @example
|
|
1150
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1151
|
+
*
|
|
1022
1152
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4]);
|
|
1023
|
-
* await collection.afterOrFail(item => item ===
|
|
1153
|
+
* await collection.afterOrFail(item => item === 4);
|
|
1024
1154
|
* // error is thrown
|
|
1025
1155
|
* @throws {CollectionError} {@link CollectionError}
|
|
1026
1156
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1027
|
-
* @throws {
|
|
1028
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1157
|
+
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1029
1158
|
*/
|
|
1030
|
-
afterOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1159
|
+
afterOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<TInput>;
|
|
1031
1160
|
/**
|
|
1032
1161
|
* The <i>sole</i> method returns the first item in the collection that passes <i>predicateFn</i>, but only if <i>predicateFn</i> matches exactly one item.
|
|
1033
1162
|
* If no items matches or multiple items are found an error will be thrown.
|
|
1034
1163
|
* @example
|
|
1164
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1165
|
+
*
|
|
1035
1166
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5]);
|
|
1036
1167
|
* await collection.sole(item => item === 4);
|
|
1037
1168
|
* // 4
|
|
1169
|
+
* @example
|
|
1170
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1171
|
+
*
|
|
1172
|
+
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 4, 5]);
|
|
1173
|
+
* await collection.sole(item => item === 4);
|
|
1174
|
+
* // error is thrown
|
|
1175
|
+
* @example
|
|
1176
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1177
|
+
*
|
|
1178
|
+
* const collection = new AsyncIterableCollection([1, 2, 3, 5]);
|
|
1179
|
+
* await collection.sole(item => item === 4);
|
|
1180
|
+
* // error is thrown
|
|
1038
1181
|
* @throws {CollectionError} {@link CollectionError}
|
|
1039
1182
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1040
|
-
* @throws {
|
|
1041
|
-
* @throws {
|
|
1042
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1183
|
+
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1184
|
+
* @throws {MultipleItemsFoundCollectionError} {@link MultipleItemsFoundCollectionError}
|
|
1043
1185
|
*/
|
|
1044
|
-
sole<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput
|
|
1186
|
+
sole<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput>;
|
|
1045
1187
|
/**
|
|
1046
1188
|
* The <i>nth</i> method creates a new collection consisting of every n-th item.
|
|
1047
1189
|
* @example
|
|
1190
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1191
|
+
*
|
|
1048
1192
|
* const collection = new AsyncIterableCollection(["a", "b", "c", "d", "e", "f"]).nth(4);
|
|
1049
1193
|
* await collection.toArray();
|
|
1050
1194
|
* // ["a", "e"]
|
|
@@ -1053,75 +1197,75 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1053
1197
|
/**
|
|
1054
1198
|
* The <i>count</i> method returns the total number of items in the collection that passes <i>predicateFn</i>.
|
|
1055
1199
|
* @example
|
|
1200
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1201
|
+
*
|
|
1056
1202
|
* const collection = new AsyncIterableCollection([1, 2, 3, 4, 5, 6]);
|
|
1057
1203
|
* await collection.count(value => value % 2 === 0);
|
|
1058
1204
|
* // 3
|
|
1059
1205
|
* @throws {CollectionError} {@link CollectionError}
|
|
1060
1206
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1061
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1062
1207
|
*/
|
|
1063
|
-
count(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1208
|
+
count(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<number>;
|
|
1064
1209
|
/**
|
|
1065
1210
|
* The <i>size</i> returns the size of the collection.
|
|
1066
1211
|
* @throws {CollectionError} {@link CollectionError}
|
|
1067
1212
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1068
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1069
1213
|
*/
|
|
1070
|
-
size(
|
|
1214
|
+
size(): Promise<number>;
|
|
1071
1215
|
/**
|
|
1072
1216
|
* The <i>isEmpty</i> returns true if the collection is empty.
|
|
1073
1217
|
* @throws {CollectionError} {@link CollectionError}
|
|
1074
1218
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1075
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1076
1219
|
*/
|
|
1077
1220
|
isEmpty(): Promise<boolean>;
|
|
1078
1221
|
/**
|
|
1079
1222
|
* The <i>isNotEmpty</i> returns true if the collection is not empty.
|
|
1080
1223
|
* @throws {CollectionError} {@link CollectionError}
|
|
1081
1224
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1082
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1083
1225
|
*/
|
|
1084
1226
|
isNotEmpty(): Promise<boolean>;
|
|
1085
1227
|
/**
|
|
1086
1228
|
* The <i>searchFirst</i> return the index of the first item that matches <i>predicateFn</i>.
|
|
1087
1229
|
* @example
|
|
1230
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1231
|
+
*
|
|
1088
1232
|
* const collection = new AsyncIterableCollection(["a", "b", "b", "c"]);
|
|
1089
1233
|
* await collection.searchFirst(item => item === "b");
|
|
1090
1234
|
* // 1
|
|
1091
1235
|
* @throws {CollectionError} {@link CollectionError}
|
|
1092
1236
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1093
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1094
1237
|
*/
|
|
1095
|
-
searchFirst(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1238
|
+
searchFirst(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<number>;
|
|
1096
1239
|
/**
|
|
1097
1240
|
* The <i>searchLast</i> return the index of the last item that matches <i>predicateFn</i>.
|
|
1098
1241
|
* @example
|
|
1242
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1243
|
+
*
|
|
1099
1244
|
* const collection = new AsyncIterableCollection(["a", "b", "b", "c"]);
|
|
1100
1245
|
* await collection.searchLast(item => item === "b");
|
|
1101
1246
|
* // 2
|
|
1102
1247
|
* @throws {CollectionError} {@link CollectionError}
|
|
1103
1248
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1104
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1105
1249
|
*/
|
|
1106
|
-
searchLast(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput
|
|
1250
|
+
searchLast(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): Promise<number>;
|
|
1107
1251
|
/**
|
|
1108
1252
|
* The <i>forEach</i> method iterates through all items in the collection.
|
|
1109
1253
|
* @throws {CollectionError} {@link CollectionError}
|
|
1110
1254
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1111
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1112
1255
|
*/
|
|
1113
|
-
forEach(callback: AsyncForEach<TInput, IAsyncCollection<TInput
|
|
1256
|
+
forEach(callback: AsyncForEach<TInput, IAsyncCollection<TInput>>): Promise<void>;
|
|
1114
1257
|
/**
|
|
1115
1258
|
* The <i>toArray</i> method converts the collection to a new array.
|
|
1116
1259
|
* @throws {CollectionError} {@link CollectionError}
|
|
1117
1260
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
1118
|
-
* @throws {IndexOverflowError} {@link IndexOverflowError}
|
|
1119
1261
|
*/
|
|
1120
1262
|
toArray(): Promise<TInput[]>;
|
|
1121
1263
|
/**
|
|
1122
1264
|
* The delay method will delay collection such that each value is returned after the specified number of seconds.
|
|
1123
1265
|
* This method is especially useful for situations where you may be interacting with external APIs that rate limit incoming requests:
|
|
1124
1266
|
* @example
|
|
1267
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1268
|
+
*
|
|
1125
1269
|
* // An iterator that will fetch all users from a specific api
|
|
1126
1270
|
* class ApiIterator implements AsyncIterable<IUser> { ... }
|
|
1127
1271
|
* const apiIterator = new ApiIterator();
|
|
@@ -1134,6 +1278,8 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1134
1278
|
* The timeout method returns a new collection that will iterate values until the specified time.
|
|
1135
1279
|
* After that time, the collection will then stop iterating:
|
|
1136
1280
|
* @example
|
|
1281
|
+
* import { AsyncIterableCollection } from "@daiso-tech/core";;
|
|
1282
|
+
*
|
|
1137
1283
|
* class AsyncInfiniteIterable implements AsyncIterable<number> {
|
|
1138
1284
|
* async *[Symbol.asyncIterator]() {
|
|
1139
1285
|
* while(true) {
|
|
@@ -1143,7 +1289,7 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
|
|
|
1143
1289
|
* }
|
|
1144
1290
|
* const asyncInfiniteIterable = new AsyncInfiniteIterable();
|
|
1145
1291
|
* const collection = new AsyncIterableCollection(asyncInfiniteIterable);
|
|
1146
|
-
* collection
|
|
1292
|
+
* await collection
|
|
1147
1293
|
* .timeout(1000)
|
|
1148
1294
|
* .forEach(nbr => console.log(nbr))
|
|
1149
1295
|
*/
|