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