@daiso-tech/core 0.1.0 → 0.1.1
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/CHANGELOG.md +6 -0
- package/dist/cjs/_module.js +19 -0
- package/dist/cjs/_module.js.map +1 -0
- package/dist/cjs/collection/_module.js +21 -0
- package/dist/cjs/collection/_module.js.map +1 -0
- package/dist/cjs/collection/_shared.js +28 -0
- package/dist/cjs/collection/_shared.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/_module.js +18 -0
- package/dist/cjs/collection/async-iterable-collection/_module.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js +678 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/_module.js +52 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/_module.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-abort-iterable.js +25 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-abort-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-chunk-iterable.js +43 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-chunk-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-chunk-whilte-iterable.js +43 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-chunk-whilte-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-collapse-iterable.js +32 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-collapse-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-count-by-iterable.js +39 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-count-by-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-cross-join-iterable.js +43 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-cross-join-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-delay-iterable.js +19 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-delay-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-entries-iterable.js +24 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-entries-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-filter-iterable.js +32 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-filter-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-flat-map-iterable.js +30 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-flat-map-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-group-by-iterable.js +30 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-group-by-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-insert-after-iterable.js +43 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-insert-after-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-insert-before-iterable.js +43 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-insert-before-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-map-iterable.js +30 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-map-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-merge-iterable.js +27 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-merge-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-pad-end-iterable.js +34 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-pad-end-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-pad-start-iterable.js +34 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-pad-start-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-partion-iterable.js +45 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-partion-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-repeat-iterable.js +32 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-repeat-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-reverse-iterable.js +28 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-reverse-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-shuffle-iterable.js +25 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-shuffle-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-skip-iterable.js +33 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-skip-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-skip-until-iterable.js +41 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-skip-until-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-slice-iterable.js +36 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-slice-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-sliding-iterable.js +45 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-sliding-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-sort-iterable.js +16 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-sort-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-split-iterable.js +49 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-split-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-take-iterable.js +33 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-take-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-take-until-iterable.js +33 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-take-until-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-tap-iterable.js +27 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-tap-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-timeout-iterable.js +21 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-timeout-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-unique-iterable.js +35 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-unique-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-update-iterable.js +37 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-update-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-when-iterable.js +32 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-when-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-zip-iterable.js +37 -0
- package/dist/cjs/collection/async-iterable-collection/async-iterable-helpers/async-zip-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/_module.js +18 -0
- package/dist/cjs/collection/iterable-collection/_module.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-collection.js +758 -0
- package/dist/cjs/collection/iterable-collection/iterable-collection.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/_module.js +49 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/_module.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/chunk-iterable.js +43 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/chunk-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/chunk-whilte-iterable.js +43 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/chunk-whilte-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/collapse-iterable.js +32 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/collapse-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/count-by-iterable.js +39 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/count-by-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/cross-join-iterable.js +43 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/cross-join-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/entries-iterable.js +34 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/entries-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/filter-iterable.js +32 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/filter-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/flat-map-iterable.js +30 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/flat-map-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/group-by-iterable.js +40 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/group-by-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/insert-after-iterable.js +37 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/insert-after-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/insert-before-iterable.js +37 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/insert-before-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/map-iterable.js +30 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/map-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/merge-iterable.js +27 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/merge-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/pad-end-iterable.js +44 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/pad-end-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/pad-start-iterable.js +44 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/pad-start-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/partion-iterable.js +40 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/partion-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/repeat-iterable.js +32 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/repeat-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/reverse-iterable.js +38 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/reverse-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/shuffle-iterable.js +35 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/shuffle-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/skip-iterable.js +32 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/skip-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/skip-until-iterable.js +36 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/skip-until-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/slice-iterable.js +46 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/slice-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/sliding-iterable.js +45 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/sliding-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/sort-iterable.js +26 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/sort-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/split-iterable.js +49 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/split-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/take-iterable.js +32 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/take-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/take-until-iterable.js +33 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/take-until-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/tap-iterable.js +27 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/tap-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/unique-iterable.js +35 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/unique-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/update-iterable.js +37 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/update-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/when-iterable.js +32 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/when-iterable.js.map +1 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/zip-iterable.js +33 -0
- package/dist/cjs/collection/iterable-collection/iterable-helpers/zip-iterable.js.map +1 -0
- package/dist/cjs/collection/list-collection/_module.js +18 -0
- package/dist/cjs/collection/list-collection/_module.js.map +1 -0
- package/dist/cjs/collection/list-collection/list-collection.js +1264 -0
- package/dist/cjs/collection/list-collection/list-collection.js.map +1 -0
- package/dist/cjs/contracts/_module.js +18 -0
- package/dist/cjs/contracts/_module.js.map +1 -0
- package/dist/cjs/contracts/collection/_module.js +20 -0
- package/dist/cjs/contracts/collection/_module.js.map +1 -0
- package/dist/cjs/contracts/collection/_shared.js +39 -0
- package/dist/cjs/contracts/collection/_shared.js.map +1 -0
- package/dist/cjs/contracts/collection/async-collection.contract.js +3 -0
- package/dist/cjs/contracts/collection/async-collection.contract.js.map +1 -0
- package/dist/cjs/contracts/collection/collection.contract.js +3 -0
- package/dist/cjs/contracts/collection/collection.contract.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/_module.js +3 -0
- package/dist/esm/_module.js.map +1 -0
- package/dist/esm/collection/_module.js +5 -0
- package/dist/esm/collection/_module.js.map +1 -0
- package/dist/esm/collection/_shared.js +23 -0
- package/dist/esm/collection/_shared.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/_module.js +2 -0
- package/dist/esm/collection/async-iterable-collection/_module.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js +674 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/_module.js +36 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/_module.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-abort-iterable.js +21 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-abort-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-chunk-iterable.js +39 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-chunk-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-chunk-whilte-iterable.js +39 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-chunk-whilte-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-collapse-iterable.js +28 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-collapse-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-count-by-iterable.js +35 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-count-by-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-cross-join-iterable.js +39 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-cross-join-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-delay-iterable.js +15 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-delay-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-entries-iterable.js +20 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-entries-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-filter-iterable.js +28 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-filter-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-flat-map-iterable.js +26 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-flat-map-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-group-by-iterable.js +26 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-group-by-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-insert-after-iterable.js +39 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-insert-after-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-insert-before-iterable.js +39 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-insert-before-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-map-iterable.js +26 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-map-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-merge-iterable.js +23 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-merge-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-pad-end-iterable.js +30 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-pad-end-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-pad-start-iterable.js +30 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-pad-start-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-partion-iterable.js +41 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-partion-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-repeat-iterable.js +28 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-repeat-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-reverse-iterable.js +24 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-reverse-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-shuffle-iterable.js +21 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-shuffle-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-skip-iterable.js +29 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-skip-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-skip-until-iterable.js +37 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-skip-until-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-slice-iterable.js +32 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-slice-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-sliding-iterable.js +41 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-sliding-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-sort-iterable.js +12 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-sort-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-split-iterable.js +45 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-split-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-take-iterable.js +29 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-take-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-take-until-iterable.js +29 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-take-until-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-tap-iterable.js +23 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-tap-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-timeout-iterable.js +17 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-timeout-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-unique-iterable.js +31 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-unique-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-update-iterable.js +33 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-update-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-when-iterable.js +28 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-when-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-zip-iterable.js +33 -0
- package/dist/esm/collection/async-iterable-collection/async-iterable-helpers/async-zip-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/_module.js +2 -0
- package/dist/esm/collection/iterable-collection/_module.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-collection.js +754 -0
- package/dist/esm/collection/iterable-collection/iterable-collection.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/_module.js +33 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/_module.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/chunk-iterable.js +39 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/chunk-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/chunk-whilte-iterable.js +39 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/chunk-whilte-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/collapse-iterable.js +28 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/collapse-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/count-by-iterable.js +35 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/count-by-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/cross-join-iterable.js +39 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/cross-join-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/entries-iterable.js +30 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/entries-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/filter-iterable.js +28 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/filter-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/flat-map-iterable.js +26 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/flat-map-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/group-by-iterable.js +36 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/group-by-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/insert-after-iterable.js +33 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/insert-after-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/insert-before-iterable.js +33 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/insert-before-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/map-iterable.js +26 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/map-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/merge-iterable.js +23 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/merge-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/pad-end-iterable.js +40 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/pad-end-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/pad-start-iterable.js +40 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/pad-start-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/partion-iterable.js +36 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/partion-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/repeat-iterable.js +28 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/repeat-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/reverse-iterable.js +34 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/reverse-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/shuffle-iterable.js +31 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/shuffle-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/skip-iterable.js +28 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/skip-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/skip-until-iterable.js +32 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/skip-until-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/slice-iterable.js +42 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/slice-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/sliding-iterable.js +41 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/sliding-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/sort-iterable.js +22 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/sort-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/split-iterable.js +45 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/split-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/take-iterable.js +28 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/take-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/take-until-iterable.js +29 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/take-until-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/tap-iterable.js +23 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/tap-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/unique-iterable.js +31 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/unique-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/update-iterable.js +33 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/update-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/when-iterable.js +28 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/when-iterable.js.map +1 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/zip-iterable.js +29 -0
- package/dist/esm/collection/iterable-collection/iterable-helpers/zip-iterable.js.map +1 -0
- package/dist/esm/collection/list-collection/_module.js +2 -0
- package/dist/esm/collection/list-collection/_module.js.map +1 -0
- package/dist/esm/collection/list-collection/list-collection.js +1260 -0
- package/dist/esm/collection/list-collection/list-collection.js.map +1 -0
- package/dist/esm/contracts/_module.js +2 -0
- package/dist/esm/contracts/_module.js.map +1 -0
- package/dist/esm/contracts/collection/_module.js +4 -0
- package/dist/esm/contracts/collection/_module.js.map +1 -0
- package/dist/esm/contracts/collection/_shared.js +31 -0
- package/dist/esm/contracts/collection/_shared.js.map +1 -0
- package/dist/esm/contracts/collection/async-collection.contract.js +1 -0
- package/dist/esm/contracts/collection/async-collection.contract.js.map +1 -0
- package/dist/esm/contracts/collection/collection.contract.js +1 -0
- package/dist/esm/contracts/collection/collection.contract.js.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/_module.d.ts +2 -0
- package/dist/types/collection/_module.d.ts +4 -0
- package/dist/types/collection/_shared.d.ts +16 -0
- package/dist/types/collection/async-iterable-collection/_module.d.ts +1 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-collection.d.ts +92 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/_module.d.ts +35 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-abort-iterable.d.ts +10 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-chunk-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-chunk-whilte-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-collapse-iterable.d.ts +9 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-count-by-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-cross-join-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-delay-iterable.d.ts +10 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-entries-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-filter-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-flat-map-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-group-by-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-insert-after-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-insert-before-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-map-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-merge-iterable.d.ts +10 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-pad-end-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-pad-start-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-partion-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-repeat-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-reverse-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-shuffle-iterable.d.ts +9 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-skip-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-skip-until-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-slice-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-sliding-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-sort-iterable.d.ts +10 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-split-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-take-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-take-until-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-tap-iterable.d.ts +10 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-timeout-iterable.d.ts +10 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-unique-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-update-iterable.d.ts +12 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-when-iterable.d.ts +11 -0
- package/dist/types/collection/async-iterable-collection/async-iterable-helpers/async-zip-iterable.d.ts +10 -0
- package/dist/types/collection/iterable-collection/_module.d.ts +1 -0
- package/dist/types/collection/iterable-collection/iterable-collection.d.ts +89 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/_module.d.ts +32 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/chunk-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/chunk-whilte-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/collapse-iterable.d.ts +6 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/count-by-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/cross-join-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/entries-iterable.d.ts +7 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/filter-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/flat-map-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/group-by-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/insert-after-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/insert-before-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/map-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/merge-iterable.d.ts +6 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/pad-end-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/pad-start-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/partion-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/repeat-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/reverse-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/shuffle-iterable.d.ts +5 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/skip-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/skip-until-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/slice-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/sliding-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/sort-iterable.d.ts +7 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/split-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/take-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/take-until-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/tap-iterable.d.ts +7 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/unique-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/update-iterable.d.ts +9 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/when-iterable.d.ts +8 -0
- package/dist/types/collection/iterable-collection/iterable-helpers/zip-iterable.d.ts +7 -0
- package/dist/types/collection/list-collection/_module.d.ts +1 -0
- package/dist/types/collection/list-collection/list-collection.d.ts +86 -0
- package/dist/types/contracts/_module.d.ts +1 -0
- package/dist/types/contracts/collection/_module.d.ts +3 -0
- package/dist/types/contracts/collection/_shared.d.ts +259 -0
- package/dist/types/contracts/collection/async-collection.contract.d.ts +731 -0
- package/dist/types/contracts/collection/collection.contract.d.ts +723 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncIterableCollection = void 0;
|
|
4
|
+
const _module_1 = require("../../contracts/collection/_module");
|
|
5
|
+
const _module_2 = require("../../collection/async-iterable-collection/async-iterable-helpers/_module");
|
|
6
|
+
class AsyncIterableCollection {
|
|
7
|
+
iterable;
|
|
8
|
+
static THROW_ON_NUMBER_LIMIT = false;
|
|
9
|
+
static DEFAULT_CHUNK_SIZE = 1024;
|
|
10
|
+
static makeCollection = (iterable) => {
|
|
11
|
+
return new AsyncIterableCollection(iterable);
|
|
12
|
+
};
|
|
13
|
+
constructor(iterable) {
|
|
14
|
+
this.iterable = iterable;
|
|
15
|
+
}
|
|
16
|
+
async *[Symbol.asyncIterator]() {
|
|
17
|
+
yield* this.iterable;
|
|
18
|
+
}
|
|
19
|
+
iterator() {
|
|
20
|
+
return this[Symbol.asyncIterator]();
|
|
21
|
+
}
|
|
22
|
+
entries(throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
23
|
+
return new AsyncIterableCollection(new _module_2.AsyncEntriesIterable(this, throwOnNumberLimit));
|
|
24
|
+
}
|
|
25
|
+
keys(throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
26
|
+
return this.entries(throwOnNumberLimit).map(([key]) => key);
|
|
27
|
+
}
|
|
28
|
+
values() {
|
|
29
|
+
return this.entries().map(([_key, value]) => value);
|
|
30
|
+
}
|
|
31
|
+
filter(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
32
|
+
return new AsyncIterableCollection(new _module_2.AsyncFilterIterable(this, filter, throwOnNumberLimit));
|
|
33
|
+
}
|
|
34
|
+
map(map, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
35
|
+
return new AsyncIterableCollection(new _module_2.AsyncMapIterable(this, map, throwOnNumberLimit));
|
|
36
|
+
}
|
|
37
|
+
async reduce(settings) {
|
|
38
|
+
const { reduceFn: reduce, initialValue, throwOnNumberLimit } = settings;
|
|
39
|
+
if (initialValue === undefined && (await this.empty())) {
|
|
40
|
+
throw new TypeError("Reduce of empty array must be inputed a initial value");
|
|
41
|
+
}
|
|
42
|
+
if (initialValue !== undefined) {
|
|
43
|
+
let output = initialValue;
|
|
44
|
+
for await (const [index, item] of this.entries()) {
|
|
45
|
+
output = await reduce(output, item, index, this);
|
|
46
|
+
}
|
|
47
|
+
return output;
|
|
48
|
+
}
|
|
49
|
+
let output = (await this.firstOrFail()), index = 0, isFirstIteration = true;
|
|
50
|
+
for await (const item of this) {
|
|
51
|
+
if (!isFirstIteration) {
|
|
52
|
+
if (throwOnNumberLimit && index === Number.MAX_SAFE_INTEGER) {
|
|
53
|
+
throw new _module_1.IndexOverflowError("Index has overflowed");
|
|
54
|
+
}
|
|
55
|
+
output = await reduce(output, item, index, this);
|
|
56
|
+
}
|
|
57
|
+
isFirstIteration = false;
|
|
58
|
+
index++;
|
|
59
|
+
}
|
|
60
|
+
return output;
|
|
61
|
+
}
|
|
62
|
+
async join(settings) {
|
|
63
|
+
return this.reduce({
|
|
64
|
+
reduceFn(str, item) {
|
|
65
|
+
if (typeof item !== "string") {
|
|
66
|
+
throw new TypeError("Item type is invalid must be string");
|
|
67
|
+
}
|
|
68
|
+
const separator = settings?.seperator ?? ",";
|
|
69
|
+
return str + separator + item;
|
|
70
|
+
},
|
|
71
|
+
throwOnNumberLimit: settings?.throwOnNumberLimit ??
|
|
72
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
collapse() {
|
|
76
|
+
return new AsyncIterableCollection(new _module_2.AsyncCollapseIterable(this));
|
|
77
|
+
}
|
|
78
|
+
flatMap(map, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
79
|
+
return new AsyncIterableCollection(new _module_2.AsyncFlatMapIterable(this, map, throwOnNumberLimit));
|
|
80
|
+
}
|
|
81
|
+
update(filter, map, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
82
|
+
return new AsyncIterableCollection(new _module_2.AsyncUpdateIterable(this, filter, map, throwOnNumberLimit));
|
|
83
|
+
}
|
|
84
|
+
page(settings) {
|
|
85
|
+
const { page, pageSize, throwOnNumberLimit } = settings;
|
|
86
|
+
if (page < 0) {
|
|
87
|
+
return this.skip(page * pageSize, throwOnNumberLimit).take(pageSize, throwOnNumberLimit);
|
|
88
|
+
}
|
|
89
|
+
return this.skip((page - 1) * pageSize, throwOnNumberLimit).take(page * pageSize, throwOnNumberLimit);
|
|
90
|
+
}
|
|
91
|
+
async sum(throwOnNumberLimit) {
|
|
92
|
+
try {
|
|
93
|
+
let sum = 0;
|
|
94
|
+
for await (const item of this) {
|
|
95
|
+
if (throwOnNumberLimit && sum === Number.MAX_SAFE_INTEGER) {
|
|
96
|
+
throw new _module_1.IndexOverflowError("Sum has overflowed");
|
|
97
|
+
}
|
|
98
|
+
if (typeof item !== "number") {
|
|
99
|
+
throw new TypeError("Item type is invalid must be number");
|
|
100
|
+
}
|
|
101
|
+
sum += item;
|
|
102
|
+
}
|
|
103
|
+
return sum;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof _module_1.CollectionError ||
|
|
107
|
+
error instanceof TypeError) {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async average(throwOnNumberLimit) {
|
|
114
|
+
try {
|
|
115
|
+
let size = 0, sum = 0;
|
|
116
|
+
for await (const item of this) {
|
|
117
|
+
if (throwOnNumberLimit && sum === Number.MAX_SAFE_INTEGER) {
|
|
118
|
+
throw new _module_1.IndexOverflowError("The sum has overflowed");
|
|
119
|
+
}
|
|
120
|
+
if (throwOnNumberLimit && size === Number.MAX_SAFE_INTEGER) {
|
|
121
|
+
throw new _module_1.IndexOverflowError("The size has overflowed");
|
|
122
|
+
}
|
|
123
|
+
if (typeof item !== "number") {
|
|
124
|
+
throw new TypeError("Item type is invalid must be number");
|
|
125
|
+
}
|
|
126
|
+
size++;
|
|
127
|
+
sum += item;
|
|
128
|
+
}
|
|
129
|
+
return (sum / size);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (error instanceof _module_1.CollectionError ||
|
|
133
|
+
error instanceof TypeError) {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async median(throwOnNumberLimit) {
|
|
140
|
+
if (await this.empty()) {
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
const size = await this.size(throwOnNumberLimit);
|
|
144
|
+
if (size === 0) {
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
const isEven = size % 2 === 0, items = await this.map((item) => {
|
|
148
|
+
if (typeof item !== "number") {
|
|
149
|
+
throw new TypeError("Item type is invalid must be number");
|
|
150
|
+
}
|
|
151
|
+
return item;
|
|
152
|
+
}, throwOnNumberLimit)
|
|
153
|
+
.filter((_item, index) => {
|
|
154
|
+
if (isEven) {
|
|
155
|
+
return index === size / 2 || index === size / 2 - 1;
|
|
156
|
+
}
|
|
157
|
+
return index === Math.floor(size / 2);
|
|
158
|
+
}, throwOnNumberLimit)
|
|
159
|
+
.toArray();
|
|
160
|
+
if (isEven) {
|
|
161
|
+
const [a, b] = items;
|
|
162
|
+
if (a === undefined) {
|
|
163
|
+
throw new _module_1.UnexpectedCollectionError("Is in invalid state");
|
|
164
|
+
}
|
|
165
|
+
if (b === undefined) {
|
|
166
|
+
throw new _module_1.UnexpectedCollectionError("Is in invalid state");
|
|
167
|
+
}
|
|
168
|
+
return ((a + b) / 2);
|
|
169
|
+
}
|
|
170
|
+
const [median] = items;
|
|
171
|
+
if (median === undefined) {
|
|
172
|
+
throw new _module_1.UnexpectedCollectionError("Is in invalid state");
|
|
173
|
+
}
|
|
174
|
+
return median;
|
|
175
|
+
}
|
|
176
|
+
async min() {
|
|
177
|
+
try {
|
|
178
|
+
let min = 0;
|
|
179
|
+
for await (const item of this) {
|
|
180
|
+
if (typeof item !== "number") {
|
|
181
|
+
throw new TypeError("Item type is invalid must be number");
|
|
182
|
+
}
|
|
183
|
+
if (min === 0) {
|
|
184
|
+
min = item;
|
|
185
|
+
}
|
|
186
|
+
else if (min > item) {
|
|
187
|
+
min = item;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return min;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
if (error instanceof _module_1.CollectionError ||
|
|
194
|
+
error instanceof TypeError) {
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async max() {
|
|
201
|
+
try {
|
|
202
|
+
let max = 0;
|
|
203
|
+
for await (const item of this) {
|
|
204
|
+
if (typeof item !== "number") {
|
|
205
|
+
throw new TypeError("Item type is invalid must be number");
|
|
206
|
+
}
|
|
207
|
+
if (max === 0) {
|
|
208
|
+
max = item;
|
|
209
|
+
}
|
|
210
|
+
else if (max < item) {
|
|
211
|
+
max = item;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return max;
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
if (error instanceof _module_1.CollectionError ||
|
|
218
|
+
error instanceof TypeError) {
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async percentage(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
225
|
+
try {
|
|
226
|
+
if (await this.empty()) {
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
229
|
+
let part = 0, total = 0;
|
|
230
|
+
for await (const item of this) {
|
|
231
|
+
if (throwOnNumberLimit && total === Number.MAX_SAFE_INTEGER) {
|
|
232
|
+
throw new _module_1.IndexOverflowError("The total amount has overflowed");
|
|
233
|
+
}
|
|
234
|
+
if (await filter(item, total, this)) {
|
|
235
|
+
part++;
|
|
236
|
+
}
|
|
237
|
+
total++;
|
|
238
|
+
}
|
|
239
|
+
return (part / total) * 100;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
if (error instanceof _module_1.CollectionError ||
|
|
243
|
+
error instanceof TypeError) {
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async some(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
250
|
+
try {
|
|
251
|
+
for await (const [index, item] of this.entries(throwOnNumberLimit)) {
|
|
252
|
+
if (await filter(item, index, this)) {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
if (error instanceof _module_1.CollectionError ||
|
|
260
|
+
error instanceof TypeError) {
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async every(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
267
|
+
try {
|
|
268
|
+
let isTrue = true;
|
|
269
|
+
for await (const [index, item] of this.entries(throwOnNumberLimit)) {
|
|
270
|
+
isTrue &&= await filter(item, index, this);
|
|
271
|
+
if (!isTrue) {
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return isTrue;
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
if (error instanceof _module_1.CollectionError ||
|
|
279
|
+
error instanceof TypeError) {
|
|
280
|
+
throw error;
|
|
281
|
+
}
|
|
282
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
take(limit, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
286
|
+
return new AsyncIterableCollection(new _module_2.AsyncTakeIterable(this, limit, throwOnNumberLimit));
|
|
287
|
+
}
|
|
288
|
+
takeUntil(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
289
|
+
return new AsyncIterableCollection(new _module_2.AsyncTakeUntilIterable(this, filter, throwOnNumberLimit));
|
|
290
|
+
}
|
|
291
|
+
takeWhile(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
292
|
+
return this.takeUntil(async (...arguments_) => !(await filter(...arguments_)), throwOnNumberLimit);
|
|
293
|
+
}
|
|
294
|
+
skip(offset, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
295
|
+
return new AsyncIterableCollection(new _module_2.AsyncSkipIterable(this, offset, throwOnNumberLimit));
|
|
296
|
+
}
|
|
297
|
+
skipUntil(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
298
|
+
return new AsyncIterableCollection(new _module_2.AsyncSkipUntilIterable(this, filter, throwOnNumberLimit));
|
|
299
|
+
}
|
|
300
|
+
skipWhile(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
301
|
+
return this.skipUntil(async (...arguments_) => !(await filter(...arguments_)), throwOnNumberLimit);
|
|
302
|
+
}
|
|
303
|
+
when(condition, callback) {
|
|
304
|
+
return new AsyncIterableCollection(new _module_2.AsyncWhenIterable(this, () => condition, callback));
|
|
305
|
+
}
|
|
306
|
+
whenEmpty(callback) {
|
|
307
|
+
return new AsyncIterableCollection(new _module_2.AsyncWhenIterable(this, () => this.empty(), callback));
|
|
308
|
+
}
|
|
309
|
+
whenNot(condition, callback) {
|
|
310
|
+
return new AsyncIterableCollection(new _module_2.AsyncWhenIterable(this, () => !condition, callback));
|
|
311
|
+
}
|
|
312
|
+
whenNotEmpty(callback) {
|
|
313
|
+
return new AsyncIterableCollection(new _module_2.AsyncWhenIterable(this, () => this.notEmpty(), callback));
|
|
314
|
+
}
|
|
315
|
+
async pipe(callback) {
|
|
316
|
+
try {
|
|
317
|
+
return await callback(this);
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
if (error instanceof _module_1.CollectionError ||
|
|
321
|
+
error instanceof TypeError) {
|
|
322
|
+
throw error;
|
|
323
|
+
}
|
|
324
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
tap(callback) {
|
|
328
|
+
return new AsyncIterableCollection(new _module_2.AsyncTapIterable(this, callback));
|
|
329
|
+
}
|
|
330
|
+
chunk(chunkSize) {
|
|
331
|
+
return new AsyncIterableCollection(new _module_2.AsyncChunkIterable(this, chunkSize, AsyncIterableCollection.makeCollection));
|
|
332
|
+
}
|
|
333
|
+
chunkWhile(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
334
|
+
return new AsyncIterableCollection(new _module_2.AsyncChunkWhileIterable(this, filter, throwOnNumberLimit, AsyncIterableCollection.makeCollection));
|
|
335
|
+
}
|
|
336
|
+
split(chunkAmount, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
337
|
+
return new AsyncIterableCollection(new _module_2.AsyncSplitIterable(this, chunkAmount, throwOnNumberLimit, AsyncIterableCollection.makeCollection));
|
|
338
|
+
}
|
|
339
|
+
partition(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
340
|
+
return new AsyncIterableCollection(new _module_2.AsyncPartionIterable(this, filter, throwOnNumberLimit, AsyncIterableCollection.makeCollection));
|
|
341
|
+
}
|
|
342
|
+
sliding(settings) {
|
|
343
|
+
const { chunkSize, step = chunkSize - 1, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT, } = settings;
|
|
344
|
+
return new AsyncIterableCollection(new _module_2.AsyncSlidingIteralbe(this, chunkSize, step, throwOnNumberLimit));
|
|
345
|
+
}
|
|
346
|
+
groupBy(settings) {
|
|
347
|
+
return new AsyncIterableCollection(new _module_2.AsyncGroupByIterable(this, settings?.mapFn, settings?.throwOnNumberLimit ??
|
|
348
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT, AsyncIterableCollection.makeCollection));
|
|
349
|
+
}
|
|
350
|
+
countBy(settings) {
|
|
351
|
+
return new AsyncIterableCollection(new _module_2.AsyncCountByIterable(this, settings?.mapFn, settings?.throwOnNumberLimit ??
|
|
352
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT));
|
|
353
|
+
}
|
|
354
|
+
unique(settings) {
|
|
355
|
+
return new AsyncIterableCollection(new _module_2.AsyncUniqueIterable(this, settings?.mapFn, settings?.throwOnNumberLimit ??
|
|
356
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT));
|
|
357
|
+
}
|
|
358
|
+
difference(iterable, map = (item) => item) {
|
|
359
|
+
const differenceCollection = new AsyncIterableCollection(iterable);
|
|
360
|
+
return this.filter(async (item, index, collection) => {
|
|
361
|
+
return !(await differenceCollection.some(async (matchItem, matchIndex, matchCollection) => {
|
|
362
|
+
return ((await map(item, index, collection)) ===
|
|
363
|
+
(await map(matchItem, matchIndex, matchCollection)));
|
|
364
|
+
}));
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
repeat(amount) {
|
|
368
|
+
return new AsyncIterableCollection(new _module_2.AsyncRepeatIterable(this, amount, AsyncIterableCollection.makeCollection));
|
|
369
|
+
}
|
|
370
|
+
padStart(maxLength, fillItems) {
|
|
371
|
+
return new AsyncIterableCollection(new _module_2.AsyncPadStartIterable(this, maxLength, fillItems, AsyncIterableCollection.makeCollection));
|
|
372
|
+
}
|
|
373
|
+
padEnd(maxLength, fillItems) {
|
|
374
|
+
return new AsyncIterableCollection(new _module_2.AsyncPadEndIterable(this, maxLength, fillItems, AsyncIterableCollection.makeCollection));
|
|
375
|
+
}
|
|
376
|
+
slice(settings) {
|
|
377
|
+
return new AsyncIterableCollection(new _module_2.AsyncSliceIterable(this, settings?.start, settings?.end, settings?.throwOnNumberLimit ??
|
|
378
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT));
|
|
379
|
+
}
|
|
380
|
+
prepend(iterable) {
|
|
381
|
+
return new AsyncIterableCollection(new _module_2.AsyncMergeIterable(iterable, this));
|
|
382
|
+
}
|
|
383
|
+
append(iterable) {
|
|
384
|
+
return new AsyncIterableCollection(new _module_2.AsyncMergeIterable(this, iterable));
|
|
385
|
+
}
|
|
386
|
+
insertBefore(filter, iterable, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
387
|
+
return new AsyncIterableCollection(new _module_2.AsyncInsertBeforeIterable(this, filter, iterable, throwOnNumberLimit));
|
|
388
|
+
}
|
|
389
|
+
insertAfter(filter, iterable, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
390
|
+
return new AsyncIterableCollection(new _module_2.AsyncInsertAfterIterable(this, filter, iterable, throwOnNumberLimit));
|
|
391
|
+
}
|
|
392
|
+
crossJoin(...iterables) {
|
|
393
|
+
return new AsyncIterableCollection(new _module_2.AsyncCrossJoinIterable(this, iterables, AsyncIterableCollection.makeCollection));
|
|
394
|
+
}
|
|
395
|
+
zip(iterable) {
|
|
396
|
+
return new AsyncIterableCollection(new _module_2.AsyncZipIterable(this, iterable));
|
|
397
|
+
}
|
|
398
|
+
sort(compare) {
|
|
399
|
+
return new AsyncIterableCollection(new _module_2.AsyncSortIterable(this, compare));
|
|
400
|
+
}
|
|
401
|
+
reverse(settings) {
|
|
402
|
+
return new AsyncIterableCollection(new _module_2.AsyncReverseIterable(this, settings?.chunkSize ??
|
|
403
|
+
AsyncIterableCollection.DEFAULT_CHUNK_SIZE, settings?.throwOnNumberLimit ??
|
|
404
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT, AsyncIterableCollection.makeCollection));
|
|
405
|
+
}
|
|
406
|
+
shuffle() {
|
|
407
|
+
return new AsyncIterableCollection(new _module_2.AsyncShuffleIterable(this));
|
|
408
|
+
}
|
|
409
|
+
async first(settings) {
|
|
410
|
+
return this.firstOr({
|
|
411
|
+
...settings,
|
|
412
|
+
defaultValue: null,
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
async firstOr(settings) {
|
|
416
|
+
try {
|
|
417
|
+
const throwOnNumberLimit = settings.throwOnNumberLimit ??
|
|
418
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT;
|
|
419
|
+
const filter = settings.filterFn ?? (() => true);
|
|
420
|
+
for await (const [index, item] of this.entries(throwOnNumberLimit)) {
|
|
421
|
+
if (await filter(item, index, this)) {
|
|
422
|
+
return item;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (typeof settings.defaultValue === "function") {
|
|
426
|
+
const defaultFn = settings.defaultValue;
|
|
427
|
+
return defaultFn();
|
|
428
|
+
}
|
|
429
|
+
return settings.defaultValue;
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
if (error instanceof _module_1.CollectionError ||
|
|
433
|
+
error instanceof TypeError) {
|
|
434
|
+
throw error;
|
|
435
|
+
}
|
|
436
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
async firstOrFail(settings) {
|
|
440
|
+
const item = await this.first(settings);
|
|
441
|
+
if (item === null) {
|
|
442
|
+
throw new _module_1.ItemNotFoundError("Item was not found");
|
|
443
|
+
}
|
|
444
|
+
return item;
|
|
445
|
+
}
|
|
446
|
+
async last(settings) {
|
|
447
|
+
return this.lastOr({
|
|
448
|
+
...settings,
|
|
449
|
+
defaultValue: null,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
async lastOr(settings) {
|
|
453
|
+
try {
|
|
454
|
+
const throwOnNumberLimit = settings.throwOnNumberLimit ??
|
|
455
|
+
AsyncIterableCollection.THROW_ON_NUMBER_LIMIT;
|
|
456
|
+
const filter = settings.filterFn ?? (() => true);
|
|
457
|
+
let matchedItem = null;
|
|
458
|
+
for await (const [index, item] of this.entries(throwOnNumberLimit)) {
|
|
459
|
+
if (await filter(item, index, this)) {
|
|
460
|
+
matchedItem = item;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (matchedItem) {
|
|
464
|
+
return matchedItem;
|
|
465
|
+
}
|
|
466
|
+
if (typeof settings.defaultValue === "function") {
|
|
467
|
+
const defaultFn = settings.defaultValue;
|
|
468
|
+
return defaultFn();
|
|
469
|
+
}
|
|
470
|
+
return settings.defaultValue;
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
if (error instanceof _module_1.CollectionError ||
|
|
474
|
+
error instanceof TypeError) {
|
|
475
|
+
throw error;
|
|
476
|
+
}
|
|
477
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
async lastOrFail(settings) {
|
|
481
|
+
const item = await this.last(settings);
|
|
482
|
+
if (item === null) {
|
|
483
|
+
throw new _module_1.ItemNotFoundError("Item was not found");
|
|
484
|
+
}
|
|
485
|
+
return item;
|
|
486
|
+
}
|
|
487
|
+
async before(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
488
|
+
return this.beforeOr(null, filter, throwOnNumberLimit);
|
|
489
|
+
}
|
|
490
|
+
async beforeOr(defaultValue, filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
491
|
+
try {
|
|
492
|
+
let beforeItem = null, index = 0;
|
|
493
|
+
for await (const item of this) {
|
|
494
|
+
if (throwOnNumberLimit && index === Number.MAX_SAFE_INTEGER) {
|
|
495
|
+
throw new _module_1.IndexOverflowError("Index has overflowed");
|
|
496
|
+
}
|
|
497
|
+
if ((await filter(item, index, this)) && beforeItem) {
|
|
498
|
+
return beforeItem;
|
|
499
|
+
}
|
|
500
|
+
index++;
|
|
501
|
+
beforeItem = item;
|
|
502
|
+
}
|
|
503
|
+
if (typeof defaultValue === "function") {
|
|
504
|
+
const defaultFn = defaultValue;
|
|
505
|
+
return defaultFn();
|
|
506
|
+
}
|
|
507
|
+
return defaultValue;
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
if (error instanceof _module_1.CollectionError ||
|
|
511
|
+
error instanceof TypeError) {
|
|
512
|
+
throw error;
|
|
513
|
+
}
|
|
514
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
async beforeOrFail(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
518
|
+
const item = await this.before(filter, throwOnNumberLimit);
|
|
519
|
+
if (item === null) {
|
|
520
|
+
throw new _module_1.ItemNotFoundError("Item was not found");
|
|
521
|
+
}
|
|
522
|
+
return item;
|
|
523
|
+
}
|
|
524
|
+
async after(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
525
|
+
return this.afterOr(null, filter, throwOnNumberLimit);
|
|
526
|
+
}
|
|
527
|
+
async afterOr(defaultValue, filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
528
|
+
try {
|
|
529
|
+
let hasMatched = false, index = 0;
|
|
530
|
+
for await (const item of this) {
|
|
531
|
+
if (hasMatched) {
|
|
532
|
+
return item;
|
|
533
|
+
}
|
|
534
|
+
if (throwOnNumberLimit && index === Number.MAX_SAFE_INTEGER) {
|
|
535
|
+
throw new _module_1.IndexOverflowError("Index has overflowed");
|
|
536
|
+
}
|
|
537
|
+
hasMatched = await filter(item, index, this);
|
|
538
|
+
index++;
|
|
539
|
+
}
|
|
540
|
+
if (typeof defaultValue === "function") {
|
|
541
|
+
const defaultFn = defaultValue;
|
|
542
|
+
return defaultFn();
|
|
543
|
+
}
|
|
544
|
+
return defaultValue;
|
|
545
|
+
}
|
|
546
|
+
catch (error) {
|
|
547
|
+
if (error instanceof _module_1.CollectionError) {
|
|
548
|
+
throw error;
|
|
549
|
+
}
|
|
550
|
+
throw new _module_1.UnexpectedCollectionError("!!__messge__!!", error);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
async afterOrFail(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
554
|
+
const item = await this.after(filter, throwOnNumberLimit);
|
|
555
|
+
if (item === null) {
|
|
556
|
+
throw new _module_1.ItemNotFoundError("Item was not found");
|
|
557
|
+
}
|
|
558
|
+
return item;
|
|
559
|
+
}
|
|
560
|
+
async sole(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
561
|
+
try {
|
|
562
|
+
let matchedItem = null;
|
|
563
|
+
for await (const [index, item] of this.entries(throwOnNumberLimit)) {
|
|
564
|
+
if (await filter(item, index, this)) {
|
|
565
|
+
if (matchedItem !== null) {
|
|
566
|
+
throw new _module_1.MultipleItemsFoundError("Multiple items were found");
|
|
567
|
+
}
|
|
568
|
+
matchedItem = item;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (matchedItem === null) {
|
|
572
|
+
throw new _module_1.ItemNotFoundError("Item was not found");
|
|
573
|
+
}
|
|
574
|
+
return matchedItem;
|
|
575
|
+
}
|
|
576
|
+
catch (error) {
|
|
577
|
+
if (error instanceof _module_1.CollectionError ||
|
|
578
|
+
error instanceof TypeError) {
|
|
579
|
+
throw error;
|
|
580
|
+
}
|
|
581
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
nth(step) {
|
|
585
|
+
return this.filter((_item, index) => index % step === 0);
|
|
586
|
+
}
|
|
587
|
+
delay(timeInMs) {
|
|
588
|
+
return new AsyncIterableCollection(new _module_2.AsyncDelayIterable(this, timeInMs));
|
|
589
|
+
}
|
|
590
|
+
abort(signal) {
|
|
591
|
+
return new AsyncIterableCollection(new _module_2.AsyncAbortIterable(this, signal));
|
|
592
|
+
}
|
|
593
|
+
timeout(timeInMs) {
|
|
594
|
+
return new AsyncIterableCollection(new _module_2.AsyncTimeoutIterable(this, timeInMs));
|
|
595
|
+
}
|
|
596
|
+
async count(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
597
|
+
try {
|
|
598
|
+
let size = 0;
|
|
599
|
+
for await (const item of this) {
|
|
600
|
+
if (throwOnNumberLimit && size === Number.MAX_SAFE_INTEGER) {
|
|
601
|
+
throw new _module_1.IndexOverflowError("Size has overflowed");
|
|
602
|
+
}
|
|
603
|
+
if (await filter(item, size, this)) {
|
|
604
|
+
size++;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return size;
|
|
608
|
+
}
|
|
609
|
+
catch (error) {
|
|
610
|
+
if (error instanceof _module_1.CollectionError ||
|
|
611
|
+
error instanceof TypeError) {
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
async size(throwOnNumberLimit) {
|
|
618
|
+
return this.count(() => true, throwOnNumberLimit);
|
|
619
|
+
}
|
|
620
|
+
async empty() {
|
|
621
|
+
try {
|
|
622
|
+
for await (const _ of this) {
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
return true;
|
|
626
|
+
}
|
|
627
|
+
catch (error) {
|
|
628
|
+
if (error instanceof _module_1.CollectionError ||
|
|
629
|
+
error instanceof TypeError) {
|
|
630
|
+
throw error;
|
|
631
|
+
}
|
|
632
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
async notEmpty() {
|
|
636
|
+
return !(await this.empty());
|
|
637
|
+
}
|
|
638
|
+
async search(filter, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
639
|
+
try {
|
|
640
|
+
for await (const [index, item] of this.entries(throwOnNumberLimit)) {
|
|
641
|
+
if (await filter(item, index, this)) {
|
|
642
|
+
return index;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return -1;
|
|
646
|
+
}
|
|
647
|
+
catch (error) {
|
|
648
|
+
if (error instanceof _module_1.CollectionError ||
|
|
649
|
+
error instanceof TypeError) {
|
|
650
|
+
throw error;
|
|
651
|
+
}
|
|
652
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
async forEach(callback, throwOnNumberLimit = AsyncIterableCollection.THROW_ON_NUMBER_LIMIT) {
|
|
656
|
+
for await (const [index, item] of this.entries(throwOnNumberLimit)) {
|
|
657
|
+
await callback(item, index, this);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
async toArray() {
|
|
661
|
+
try {
|
|
662
|
+
const items = [];
|
|
663
|
+
for await (const item of this) {
|
|
664
|
+
items.push(item);
|
|
665
|
+
}
|
|
666
|
+
return items;
|
|
667
|
+
}
|
|
668
|
+
catch (error) {
|
|
669
|
+
if (error instanceof _module_1.CollectionError ||
|
|
670
|
+
error instanceof TypeError) {
|
|
671
|
+
throw error;
|
|
672
|
+
}
|
|
673
|
+
throw new _module_1.UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
exports.AsyncIterableCollection = AsyncIterableCollection;
|
|
678
|
+
//# sourceMappingURL=async-iterable-collection.js.map
|