@daiso-tech/core 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_module.js +2 -0
- package/dist/cjs/_module.js.map +1 -1
- package/dist/cjs/async/_module.js +30 -0
- package/dist/cjs/async/_module.js.map +1 -0
- package/dist/cjs/async/_shared.js +34 -0
- package/dist/cjs/async/_shared.js.map +1 -0
- package/dist/cjs/async/abortable/_module.js +18 -0
- package/dist/cjs/async/abortable/_module.js.map +1 -0
- package/dist/cjs/async/abortable/abortable.js +48 -0
- package/dist/cjs/async/abortable/abortable.js.map +1 -0
- package/dist/cjs/async/abortable-iterable/_module.js +18 -0
- package/dist/cjs/async/abortable-iterable/_module.js.map +1 -0
- package/dist/cjs/async/abortable-iterable/abortable-iterable.js +32 -0
- package/dist/cjs/async/abortable-iterable/abortable-iterable.js.map +1 -0
- package/dist/cjs/async/backof-policies/_module.js +21 -0
- package/dist/cjs/async/backof-policies/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/_shared.js +7 -0
- package/dist/cjs/async/backof-policies/_shared.js.map +1 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +19 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +23 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +23 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +23 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
- package/dist/cjs/async/delay/_module.js +18 -0
- package/dist/cjs/async/delay/_module.js.map +1 -0
- package/dist/cjs/async/delay/delay.js +24 -0
- package/dist/cjs/async/delay/delay.js.map +1 -0
- package/dist/cjs/async/delay-iterable/_module.js +18 -0
- package/dist/cjs/async/delay-iterable/_module.js.map +1 -0
- package/dist/cjs/async/delay-iterable/delay-iterable.js +36 -0
- package/dist/cjs/async/delay-iterable/delay-iterable.js.map +1 -0
- package/dist/cjs/async/lazy-promise/_module.js +18 -0
- package/dist/cjs/async/lazy-promise/_module.js.map +1 -0
- package/dist/cjs/async/lazy-promise/lazy-promise.js +22 -0
- package/dist/cjs/async/lazy-promise/lazy-promise.js.map +1 -0
- package/dist/cjs/async/retry/_module.js +18 -0
- package/dist/cjs/async/retry/_module.js.map +1 -0
- package/dist/cjs/async/retry/retry.js +43 -0
- package/dist/cjs/async/retry/retry.js.map +1 -0
- package/dist/cjs/async/retry-iterable/_module.js +18 -0
- package/dist/cjs/async/retry-iterable/_module.js.map +1 -0
- package/dist/cjs/async/retry-iterable/retry-iterable.js +32 -0
- package/dist/cjs/async/retry-iterable/retry-iterable.js.map +1 -0
- package/dist/cjs/async/timeout/_module.js +18 -0
- package/dist/cjs/async/timeout/_module.js.map +1 -0
- package/dist/cjs/async/timeout/timeout.js +28 -0
- package/dist/cjs/async/timeout/timeout.js.map +1 -0
- package/dist/cjs/async/timeout-iterable/_module.js +18 -0
- package/dist/cjs/async/timeout-iterable/_module.js.map +1 -0
- package/dist/cjs/async/timeout-iterable/timeout-iterable.js +11 -0
- package/dist/cjs/async/timeout-iterable/timeout-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/_shared/_module.js +1 -3
- package/dist/cjs/collection/async-iterable-collection/_shared/_module.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js +14 -23
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js +12 -21
- package/dist/cjs/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js +5 -14
- package/dist/cjs/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js +9 -18
- package/dist/cjs/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +18 -27
- package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-error-handler-iterable.js +31 -0
- package/dist/cjs/collection/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js +3 -12
- package/dist/cjs/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +8 -17
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +8 -17
- package/dist/cjs/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js +9 -18
- package/dist/cjs/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js +4 -13
- package/dist/cjs/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js +3 -12
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +7 -16
- package/dist/cjs/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js +9 -18
- package/dist/cjs/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js +17 -26
- package/dist/cjs/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js +3 -12
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js +4 -13
- package/dist/cjs/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js +2 -11
- package/dist/cjs/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js +6 -15
- package/dist/cjs/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js +5 -14
- package/dist/cjs/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js +4 -13
- package/dist/cjs/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js +177 -265
- package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js +14 -23
- package/dist/cjs/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/chunk-while-iterable.js +12 -21
- package/dist/cjs/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js +5 -14
- package/dist/cjs/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js +19 -31
- package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js +3 -12
- package/dist/cjs/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js +6 -16
- package/dist/cjs/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js +6 -16
- package/dist/cjs/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js +11 -20
- package/dist/cjs/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js +11 -20
- package/dist/cjs/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js +3 -12
- package/dist/cjs/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js +6 -15
- package/dist/cjs/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js +15 -24
- package/dist/cjs/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js +9 -18
- package/dist/cjs/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js +1 -10
- package/dist/cjs/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js +17 -26
- package/dist/cjs/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js +3 -12
- package/dist/cjs/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js +2 -11
- package/dist/cjs/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js +6 -15
- package/dist/cjs/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js +5 -14
- package/dist/cjs/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js +4 -13
- package/dist/cjs/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js +6 -15
- package/dist/cjs/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/iterable-collection.js +154 -346
- package/dist/cjs/collection/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/cjs/collection/list-collection/list-collection.js +348 -931
- package/dist/cjs/collection/list-collection/list-collection.js.map +1 -1
- package/dist/cjs/storage/storage.js +25 -15
- package/dist/cjs/storage/storage.js.map +1 -1
- package/dist/cjs/utilities/_module.js +18 -0
- package/dist/cjs/utilities/_module.js.map +1 -0
- package/dist/cjs/utilities/time-span/_module.js +18 -0
- package/dist/cjs/utilities/time-span/_module.js.map +1 -0
- package/dist/cjs/utilities/time-span/time-span.js +103 -0
- package/dist/cjs/utilities/time-span/time-span.js.map +1 -0
- package/dist/esm/_module.js +2 -0
- package/dist/esm/_module.js.map +1 -1
- package/dist/esm/async/_module.js +12 -0
- package/dist/esm/async/_module.js.map +1 -0
- package/dist/esm/async/_shared.js +27 -0
- package/dist/esm/async/_shared.js.map +1 -0
- package/dist/esm/async/abortable/_module.js +2 -0
- package/dist/esm/async/abortable/_module.js.map +1 -0
- package/dist/esm/async/abortable/abortable.js +45 -0
- package/dist/esm/async/abortable/abortable.js.map +1 -0
- package/dist/esm/async/abortable-iterable/_module.js +2 -0
- package/dist/esm/async/abortable-iterable/_module.js.map +1 -0
- package/dist/esm/async/abortable-iterable/abortable-iterable.js +29 -0
- package/dist/esm/async/abortable-iterable/abortable-iterable.js.map +1 -0
- package/dist/esm/async/backof-policies/_module.js +5 -0
- package/dist/esm/async/backof-policies/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/_shared.js +4 -0
- package/dist/esm/async/backof-policies/_shared.js.map +1 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +16 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +20 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +20 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +20 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
- package/dist/esm/async/delay/_module.js +2 -0
- package/dist/esm/async/delay/_module.js.map +1 -0
- package/dist/esm/async/delay/delay.js +21 -0
- package/dist/esm/async/delay/delay.js.map +1 -0
- package/dist/esm/async/delay-iterable/_module.js +2 -0
- package/dist/esm/async/delay-iterable/_module.js.map +1 -0
- package/dist/esm/async/delay-iterable/delay-iterable.js +33 -0
- package/dist/esm/async/delay-iterable/delay-iterable.js.map +1 -0
- package/dist/esm/async/lazy-promise/_module.js +2 -0
- package/dist/esm/async/lazy-promise/_module.js.map +1 -0
- package/dist/esm/async/lazy-promise/lazy-promise.js +17 -0
- package/dist/esm/async/lazy-promise/lazy-promise.js.map +1 -0
- package/dist/esm/async/retry/_module.js +2 -0
- package/dist/esm/async/retry/_module.js.map +1 -0
- package/dist/esm/async/retry/retry.js +40 -0
- package/dist/esm/async/retry/retry.js.map +1 -0
- package/dist/esm/async/retry-iterable/_module.js +2 -0
- package/dist/esm/async/retry-iterable/_module.js.map +1 -0
- package/dist/esm/async/retry-iterable/retry-iterable.js +29 -0
- package/dist/esm/async/retry-iterable/retry-iterable.js.map +1 -0
- package/dist/esm/async/timeout/_module.js +2 -0
- package/dist/esm/async/timeout/_module.js.map +1 -0
- package/dist/esm/async/timeout/timeout.js +25 -0
- package/dist/esm/async/timeout/timeout.js.map +1 -0
- package/dist/esm/async/timeout-iterable/_module.js +2 -0
- package/dist/esm/async/timeout-iterable/_module.js.map +1 -0
- package/dist/esm/async/timeout-iterable/timeout-iterable.js +8 -0
- package/dist/esm/async/timeout-iterable/timeout-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/_shared/_module.js +1 -3
- package/dist/esm/collection/async-iterable-collection/_shared/_module.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js +14 -23
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js +12 -21
- package/dist/esm/collection/async-iterable-collection/_shared/async-chunk-while-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js +5 -14
- package/dist/esm/collection/async-iterable-collection/_shared/async-collapse-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js +9 -18
- package/dist/esm/collection/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js +17 -26
- package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-error-handler-iterable.js +27 -0
- package/dist/esm/collection/async-iterable-collection/_shared/async-error-handler-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js +3 -12
- package/dist/esm/collection/async-iterable-collection/_shared/async-filter-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-flat-map-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js +8 -17
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-after-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js +8 -17
- package/dist/esm/collection/async-iterable-collection/_shared/async-insert-before-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-map-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-merge-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js +9 -18
- package/dist/esm/collection/async-iterable-collection/_shared/async-partion-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js +4 -13
- package/dist/esm/collection/async-iterable-collection/_shared/async-repeat-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js +3 -12
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js +7 -16
- package/dist/esm/collection/async-iterable-collection/_shared/async-skip-until-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js +9 -18
- package/dist/esm/collection/async-iterable-collection/_shared/async-sliding-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js +17 -26
- package/dist/esm/collection/async-iterable-collection/_shared/async-split-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js +3 -12
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js +4 -13
- package/dist/esm/collection/async-iterable-collection/_shared/async-take-until-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js +2 -11
- package/dist/esm/collection/async-iterable-collection/_shared/async-tap-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js +6 -15
- package/dist/esm/collection/async-iterable-collection/_shared/async-unique-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js +5 -14
- package/dist/esm/collection/async-iterable-collection/_shared/async-update-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js +4 -13
- package/dist/esm/collection/async-iterable-collection/_shared/async-when-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js +179 -267
- package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js +14 -23
- package/dist/esm/collection/iterable-collection/_shared/chunk-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/chunk-while-iterable.js +12 -21
- package/dist/esm/collection/iterable-collection/_shared/chunk-while-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js +5 -14
- package/dist/esm/collection/iterable-collection/_shared/collapse-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/count-by-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js +19 -31
- package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/entries-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js +3 -12
- package/dist/esm/collection/iterable-collection/_shared/filter-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/flat-map-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/group-by-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js +6 -16
- package/dist/esm/collection/iterable-collection/_shared/insert-after-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js +6 -16
- package/dist/esm/collection/iterable-collection/_shared/insert-before-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/map-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/map-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/merge-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js +11 -20
- package/dist/esm/collection/iterable-collection/_shared/pad-end-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js +11 -20
- package/dist/esm/collection/iterable-collection/_shared/pad-start-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/partion-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/repeat-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/reverse-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/shuffle-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js +3 -12
- package/dist/esm/collection/iterable-collection/_shared/skip-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js +6 -15
- package/dist/esm/collection/iterable-collection/_shared/skip-until-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js +15 -24
- package/dist/esm/collection/iterable-collection/_shared/slice-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js +9 -18
- package/dist/esm/collection/iterable-collection/_shared/sliding-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js +1 -10
- package/dist/esm/collection/iterable-collection/_shared/sort-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/split-iterable.js +17 -26
- package/dist/esm/collection/iterable-collection/_shared/split-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/take-iterable.js +3 -12
- package/dist/esm/collection/iterable-collection/_shared/take-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/take-until-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js +2 -11
- package/dist/esm/collection/iterable-collection/_shared/tap-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js +6 -15
- package/dist/esm/collection/iterable-collection/_shared/unique-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/update-iterable.js +5 -14
- package/dist/esm/collection/iterable-collection/_shared/update-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/when-iterable.js +4 -13
- package/dist/esm/collection/iterable-collection/_shared/when-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js +6 -15
- package/dist/esm/collection/iterable-collection/_shared/zip-iterable.js.map +1 -1
- package/dist/esm/collection/iterable-collection/iterable-collection.js +155 -347
- package/dist/esm/collection/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/esm/collection/list-collection/list-collection.js +349 -932
- package/dist/esm/collection/list-collection/list-collection.js.map +1 -1
- package/dist/esm/storage/storage.js +25 -15
- package/dist/esm/storage/storage.js.map +1 -1
- package/dist/esm/utilities/_module.js +2 -0
- package/dist/esm/utilities/_module.js.map +1 -0
- package/dist/esm/utilities/time-span/_module.js +2 -0
- package/dist/esm/utilities/time-span/_module.js.map +1 -0
- package/dist/esm/utilities/time-span/time-span.js +99 -0
- package/dist/esm/utilities/time-span/time-span.js.map +1 -0
- package/dist/types/_module.d.ts +2 -0
- package/dist/types/_shared/types.d.ts +2 -2
- package/dist/types/async/_module.d.ts +11 -0
- package/dist/types/async/_shared.d.ts +35 -0
- package/dist/types/async/abortable/_module.d.ts +1 -0
- package/dist/types/async/abortable/abortable.d.ts +39 -0
- package/dist/types/async/abortable-iterable/_module.d.ts +1 -0
- package/dist/types/async/abortable-iterable/abortable-iterable.d.ts +36 -0
- package/dist/types/async/backof-policies/_module.d.ts +5 -0
- package/dist/types/async/backof-policies/_shared.d.ts +12 -0
- package/dist/types/async/backof-policies/constant-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +28 -0
- package/dist/types/async/backof-policies/exponential-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +36 -0
- package/dist/types/async/backof-policies/linear-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +32 -0
- package/dist/types/async/backof-policies/polynomial-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +36 -0
- package/dist/types/async/delay/_module.d.ts +1 -0
- package/dist/types/async/delay/delay.d.ts +38 -0
- package/dist/types/async/delay-iterable/_module.d.ts +1 -0
- package/dist/types/async/delay-iterable/delay-iterable.d.ts +57 -0
- package/dist/types/async/lazy-promise/_module.d.ts +1 -0
- package/dist/types/async/lazy-promise/lazy-promise.d.ts +28 -0
- package/dist/types/async/retry/_module.d.ts +1 -0
- package/dist/types/async/retry/retry.d.ts +86 -0
- package/dist/types/async/retry-iterable/_module.d.ts +1 -0
- package/dist/types/async/retry-iterable/retry-iterable.d.ts +86 -0
- package/dist/types/async/timeout/_module.d.ts +1 -0
- package/dist/types/async/timeout/timeout.d.ts +40 -0
- package/dist/types/async/timeout-iterable/_module.d.ts +1 -0
- package/dist/types/async/timeout-iterable/timeout-iterable.d.ts +64 -0
- package/dist/types/collection/async-iterable-collection/_shared/_module.d.ts +1 -3
- package/dist/types/collection/async-iterable-collection/_shared/async-error-handler-iterable.d.ts +6 -0
- package/dist/types/collection/async-iterable-collection/_shared/async-when-iterable.d.ts +1 -1
- package/dist/types/collection/async-iterable-collection/async-iterable-collection.d.ts +39 -37
- package/dist/types/contracts/collection/_shared.d.ts +7 -7
- package/dist/types/contracts/collection/async-collection.contract.d.ts +51 -39
- package/dist/types/contracts/storage/storage.contract.d.ts +2 -1
- package/dist/types/storage/storage.d.ts +5 -3
- package/dist/types/utilities/_module.d.ts +1 -0
- package/dist/types/utilities/time-span/_module.d.ts +1 -0
- package/dist/types/utilities/time-span/time-span.d.ts +50 -0
- package/package.json +1 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-abort-iterable.js +0 -25
- package/dist/cjs/collection/async-iterable-collection/_shared/async-abort-iterable.js.map +0 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-delay-iterable.js +0 -25
- package/dist/cjs/collection/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
- package/dist/cjs/collection/async-iterable-collection/_shared/async-timeout-iterable.js +0 -21
- package/dist/cjs/collection/async-iterable-collection/_shared/async-timeout-iterable.js.map +0 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-abort-iterable.js +0 -21
- package/dist/esm/collection/async-iterable-collection/_shared/async-abort-iterable.js.map +0 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-delay-iterable.js +0 -21
- package/dist/esm/collection/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
- package/dist/esm/collection/async-iterable-collection/_shared/async-timeout-iterable.js +0 -17
- package/dist/esm/collection/async-iterable-collection/_shared/async-timeout-iterable.js.map +0 -1
- package/dist/types/collection/async-iterable-collection/_shared/async-abort-iterable.d.ts +0 -10
- package/dist/types/collection/async-iterable-collection/_shared/async-delay-iterable.d.ts +0 -10
- package/dist/types/collection/async-iterable-collection/_shared/async-timeout-iterable.d.ts +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isIterable } from "../../collection/_shared";
|
|
2
|
-
import {
|
|
2
|
+
import { ItemNotFoundCollectionError, MultipleItemsFoundCollectionError, UnexpectedCollectionError, TypeCollectionError, EmptyCollectionError, } from "../../contracts/collection/_module";
|
|
3
3
|
import { simplifyLazyable } from "../../_shared/utilities";
|
|
4
4
|
export class ListCollection {
|
|
5
5
|
array;
|
|
@@ -13,147 +13,65 @@ export class ListCollection {
|
|
|
13
13
|
return this[Symbol.iterator]();
|
|
14
14
|
}
|
|
15
15
|
entries() {
|
|
16
|
-
|
|
17
|
-
return new ListCollection(this.array.entries());
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
if (error instanceof CollectionError) {
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
24
|
-
}
|
|
16
|
+
return new ListCollection(this.array.entries());
|
|
25
17
|
}
|
|
26
18
|
keys() {
|
|
27
|
-
|
|
28
|
-
return new ListCollection(this.array.keys());
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (error instanceof CollectionError) {
|
|
32
|
-
throw error;
|
|
33
|
-
}
|
|
34
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
35
|
-
}
|
|
19
|
+
return new ListCollection(this.array.keys());
|
|
36
20
|
}
|
|
37
21
|
values() {
|
|
38
22
|
return new ListCollection(this);
|
|
39
23
|
}
|
|
40
24
|
filter(predicateFn) {
|
|
41
|
-
|
|
42
|
-
return new ListCollection(this.array.filter((item, index) => predicateFn(item, index, this)));
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
if (error instanceof CollectionError) {
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
48
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
49
|
-
}
|
|
25
|
+
return new ListCollection(this.array.filter((item, index) => predicateFn(item, index, this)));
|
|
50
26
|
}
|
|
51
27
|
reject(predicateFn) {
|
|
52
|
-
|
|
53
|
-
return new ListCollection(this.array.filter((item, index) => !predicateFn(item, index, this)));
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
if (error instanceof CollectionError) {
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
60
|
-
}
|
|
28
|
+
return new ListCollection(this.array.filter((item, index) => !predicateFn(item, index, this)));
|
|
61
29
|
}
|
|
62
30
|
map(mapFn) {
|
|
63
|
-
|
|
64
|
-
return new ListCollection(this.array.map((item, index) => mapFn(item, index, this)));
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (error instanceof CollectionError) {
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
71
|
-
}
|
|
31
|
+
return new ListCollection(this.array.map((item, index) => mapFn(item, index, this)));
|
|
72
32
|
}
|
|
73
33
|
reduce(reduceFn, initialValue) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throw new TypeCollectionError("Reduce of empty array must be inputed a initial value");
|
|
77
|
-
}
|
|
78
|
-
if (initialValue !== undefined) {
|
|
79
|
-
return this.array.reduce((initialValue, item, index) => reduceFn(initialValue, item, index, this), initialValue);
|
|
80
|
-
}
|
|
81
|
-
return this.array.reduce((initialValue, item, index) => {
|
|
82
|
-
const reduce = reduceFn;
|
|
83
|
-
return reduce(initialValue, item, index, this);
|
|
84
|
-
});
|
|
34
|
+
if (initialValue === undefined && this.isEmpty()) {
|
|
35
|
+
throw new TypeCollectionError("Reduce of empty array must be inputed a initial value");
|
|
85
36
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
37
|
+
if (initialValue !== undefined) {
|
|
38
|
+
return this.array.reduce((initialValue, item, index) => reduceFn(initialValue, item, index, this), initialValue);
|
|
91
39
|
}
|
|
40
|
+
return this.array.reduce((initialValue, item, index) => {
|
|
41
|
+
const reduce = reduceFn;
|
|
42
|
+
return reduce(initialValue, item, index, this);
|
|
43
|
+
});
|
|
92
44
|
}
|
|
93
45
|
join(separator = ",") {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
throw new TypeCollectionError("Item type is invalid must be string");
|
|
98
|
-
}
|
|
46
|
+
for (const item of this) {
|
|
47
|
+
if (typeof item !== "string") {
|
|
48
|
+
throw new TypeCollectionError("Item type is invalid must be string");
|
|
99
49
|
}
|
|
100
|
-
return this.array.join(separator);
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
if (error instanceof CollectionError) {
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
107
50
|
}
|
|
51
|
+
return this.array.join(separator);
|
|
108
52
|
}
|
|
109
53
|
collapse() {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
items.push(...item);
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
items.push(item);
|
|
118
|
-
}
|
|
54
|
+
const items = [];
|
|
55
|
+
for (const item of this.array) {
|
|
56
|
+
if (isIterable(item)) {
|
|
57
|
+
items.push(...item);
|
|
119
58
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
catch (error) {
|
|
123
|
-
if (error instanceof CollectionError) {
|
|
124
|
-
throw error;
|
|
59
|
+
else {
|
|
60
|
+
items.push(item);
|
|
125
61
|
}
|
|
126
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
127
62
|
}
|
|
63
|
+
return new ListCollection(items);
|
|
128
64
|
}
|
|
129
65
|
flatMap(mapFn) {
|
|
130
|
-
|
|
131
|
-
return new ListCollection(this.array.flatMap((item, index) => [
|
|
132
|
-
...mapFn(item, index, this),
|
|
133
|
-
]));
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
if (error instanceof CollectionError) {
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
140
|
-
}
|
|
66
|
+
return new ListCollection(this.array.flatMap((item, index) => [...mapFn(item, index, this)]));
|
|
141
67
|
}
|
|
142
68
|
change(predicateFn, mapFn) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return mapFn(item, index, this);
|
|
147
|
-
}
|
|
148
|
-
return item;
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
if (error instanceof CollectionError) {
|
|
153
|
-
throw error;
|
|
69
|
+
return new ListCollection(this.array.map((item, index) => {
|
|
70
|
+
if (predicateFn(item, index, this)) {
|
|
71
|
+
return mapFn(item, index, this);
|
|
154
72
|
}
|
|
155
|
-
|
|
156
|
-
}
|
|
73
|
+
return item;
|
|
74
|
+
}));
|
|
157
75
|
}
|
|
158
76
|
page(page, pageSize) {
|
|
159
77
|
if (page < 0) {
|
|
@@ -179,1028 +97,527 @@ export class ListCollection {
|
|
|
179
97
|
return (this.sum() / this.size());
|
|
180
98
|
}
|
|
181
99
|
median() {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
throw new TypeCollectionError("Item type is invalid must be number");
|
|
189
|
-
}
|
|
190
|
-
return item;
|
|
191
|
-
}), index = Math.floor(this.array.length / 2), isEven = this.array.length % 2 === 0, a = nbrs[index];
|
|
192
|
-
if (a === undefined) {
|
|
193
|
-
throw new UnexpectedCollectionError("Is in invalid state");
|
|
194
|
-
}
|
|
195
|
-
const b = nbrs[index - 1];
|
|
196
|
-
if (isEven) {
|
|
197
|
-
if (b === undefined) {
|
|
198
|
-
throw new UnexpectedCollectionError("Is in invalid state");
|
|
199
|
-
}
|
|
200
|
-
return ((a + b) / 2);
|
|
100
|
+
if (this.isEmpty()) {
|
|
101
|
+
throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
|
|
102
|
+
}
|
|
103
|
+
const nbrs = this.array.map((item) => {
|
|
104
|
+
if (typeof item !== "number") {
|
|
105
|
+
throw new TypeCollectionError("Item type is invalid must be number");
|
|
201
106
|
}
|
|
202
|
-
return
|
|
107
|
+
return item;
|
|
108
|
+
}), index = Math.floor(this.array.length / 2), isEven = this.array.length % 2 === 0, a = nbrs[index];
|
|
109
|
+
if (a === undefined) {
|
|
110
|
+
throw new UnexpectedCollectionError("Is in invalid state");
|
|
203
111
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
112
|
+
const b = nbrs[index - 1];
|
|
113
|
+
if (isEven) {
|
|
114
|
+
if (b === undefined) {
|
|
115
|
+
throw new UnexpectedCollectionError("Is in invalid state");
|
|
207
116
|
}
|
|
208
|
-
|
|
117
|
+
return ((a + b) / 2);
|
|
209
118
|
}
|
|
119
|
+
return a;
|
|
210
120
|
}
|
|
211
121
|
min() {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
122
|
+
if (this.isEmpty()) {
|
|
123
|
+
throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
|
|
124
|
+
}
|
|
125
|
+
let min = 0;
|
|
126
|
+
for (const item of this.array) {
|
|
127
|
+
if (typeof item !== "number") {
|
|
128
|
+
throw new TypeCollectionError("Item type is invalid must be number");
|
|
215
129
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (typeof item !== "number") {
|
|
219
|
-
throw new TypeCollectionError("Item type is invalid must be number");
|
|
220
|
-
}
|
|
221
|
-
if (min === 0) {
|
|
222
|
-
min = item;
|
|
223
|
-
}
|
|
224
|
-
else if (min > item) {
|
|
225
|
-
min = item;
|
|
226
|
-
}
|
|
130
|
+
if (min === 0) {
|
|
131
|
+
min = item;
|
|
227
132
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
catch (error) {
|
|
231
|
-
if (error instanceof CollectionError) {
|
|
232
|
-
throw error;
|
|
133
|
+
else if (min > item) {
|
|
134
|
+
min = item;
|
|
233
135
|
}
|
|
234
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
235
136
|
}
|
|
137
|
+
return min;
|
|
236
138
|
}
|
|
237
139
|
max() {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
140
|
+
if (this.isEmpty()) {
|
|
141
|
+
throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
|
|
142
|
+
}
|
|
143
|
+
let max = 0;
|
|
144
|
+
for (const item of this.array) {
|
|
145
|
+
if (typeof item !== "number") {
|
|
146
|
+
throw new TypeCollectionError("Item type is invalid must be number");
|
|
241
147
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (typeof item !== "number") {
|
|
245
|
-
throw new TypeCollectionError("Item type is invalid must be number");
|
|
246
|
-
}
|
|
247
|
-
if (max === 0) {
|
|
248
|
-
max = item;
|
|
249
|
-
}
|
|
250
|
-
else if (max < item) {
|
|
251
|
-
max = item;
|
|
252
|
-
}
|
|
148
|
+
if (max === 0) {
|
|
149
|
+
max = item;
|
|
253
150
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
catch (error) {
|
|
257
|
-
if (error instanceof CollectionError) {
|
|
258
|
-
throw error;
|
|
151
|
+
else if (max < item) {
|
|
152
|
+
max = item;
|
|
259
153
|
}
|
|
260
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
261
154
|
}
|
|
155
|
+
return max;
|
|
262
156
|
}
|
|
263
157
|
percentage(predicateFn) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
|
|
267
|
-
}
|
|
268
|
-
return (this.count(predicateFn) / this.size()) * 100;
|
|
269
|
-
}
|
|
270
|
-
catch (error) {
|
|
271
|
-
if (error instanceof CollectionError) {
|
|
272
|
-
throw error;
|
|
273
|
-
}
|
|
274
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
158
|
+
if (this.isEmpty()) {
|
|
159
|
+
throw new EmptyCollectionError("Collection is empty therby operation cannot be performed");
|
|
275
160
|
}
|
|
161
|
+
return (this.count(predicateFn) / this.size()) * 100;
|
|
276
162
|
}
|
|
277
163
|
some(predicateFn) {
|
|
278
|
-
|
|
279
|
-
return this.array.some((item, index) => predicateFn(item, index, this));
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
if (error instanceof CollectionError) {
|
|
283
|
-
throw error;
|
|
284
|
-
}
|
|
285
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
286
|
-
}
|
|
164
|
+
return this.array.some((item, index) => predicateFn(item, index, this));
|
|
287
165
|
}
|
|
288
166
|
every(predicateFn) {
|
|
289
|
-
|
|
290
|
-
return this.array.every((item, index) => predicateFn(item, index, this));
|
|
291
|
-
}
|
|
292
|
-
catch (error) {
|
|
293
|
-
if (error instanceof CollectionError) {
|
|
294
|
-
throw error;
|
|
295
|
-
}
|
|
296
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
297
|
-
}
|
|
167
|
+
return this.array.every((item, index) => predicateFn(item, index, this));
|
|
298
168
|
}
|
|
299
169
|
take(limit) {
|
|
300
|
-
|
|
301
|
-
return new ListCollection(this.array.slice(0, limit));
|
|
302
|
-
}
|
|
303
|
-
catch (error) {
|
|
304
|
-
if (error instanceof CollectionError) {
|
|
305
|
-
throw error;
|
|
306
|
-
}
|
|
307
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
308
|
-
}
|
|
170
|
+
return new ListCollection(this.array.slice(0, limit));
|
|
309
171
|
}
|
|
310
172
|
takeUntil(predicateFn) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
items.push(item);
|
|
318
|
-
}
|
|
319
|
-
return new ListCollection(items);
|
|
320
|
-
}
|
|
321
|
-
catch (error) {
|
|
322
|
-
if (error instanceof CollectionError) {
|
|
323
|
-
throw error;
|
|
173
|
+
const items = [];
|
|
174
|
+
for (const [index, item] of this.array.entries()) {
|
|
175
|
+
if (predicateFn(item, index, this)) {
|
|
176
|
+
break;
|
|
324
177
|
}
|
|
325
|
-
|
|
178
|
+
items.push(item);
|
|
326
179
|
}
|
|
180
|
+
return new ListCollection(items);
|
|
327
181
|
}
|
|
328
182
|
takeWhile(predicateFn) {
|
|
329
|
-
|
|
330
|
-
return this.takeUntil((...arguments_) => !predicateFn(...arguments_));
|
|
331
|
-
}
|
|
332
|
-
catch (error) {
|
|
333
|
-
if (error instanceof CollectionError) {
|
|
334
|
-
throw error;
|
|
335
|
-
}
|
|
336
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
337
|
-
}
|
|
183
|
+
return this.takeUntil((...arguments_) => !predicateFn(...arguments_));
|
|
338
184
|
}
|
|
339
185
|
skip(offset) {
|
|
340
|
-
|
|
341
|
-
return new ListCollection(this.array.slice(offset));
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
if (error instanceof CollectionError) {
|
|
345
|
-
throw error;
|
|
346
|
-
}
|
|
347
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
348
|
-
}
|
|
186
|
+
return new ListCollection(this.array.slice(offset));
|
|
349
187
|
}
|
|
350
188
|
skipUntil(predicateFn) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
hasMatched = predicateFn(item, index, this);
|
|
357
|
-
}
|
|
358
|
-
if (hasMatched) {
|
|
359
|
-
items.push(item);
|
|
360
|
-
}
|
|
189
|
+
let hasMatched = false;
|
|
190
|
+
const items = [];
|
|
191
|
+
for (const [index, item] of this.array.entries()) {
|
|
192
|
+
if (!hasMatched) {
|
|
193
|
+
hasMatched = predicateFn(item, index, this);
|
|
361
194
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
catch (error) {
|
|
365
|
-
if (error instanceof CollectionError) {
|
|
366
|
-
throw error;
|
|
195
|
+
if (hasMatched) {
|
|
196
|
+
items.push(item);
|
|
367
197
|
}
|
|
368
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
369
198
|
}
|
|
199
|
+
return new ListCollection(items);
|
|
370
200
|
}
|
|
371
201
|
skipWhile(predicateFn) {
|
|
372
|
-
|
|
373
|
-
return this.skipUntil((...arguments_) => !predicateFn(...arguments_));
|
|
374
|
-
}
|
|
375
|
-
catch (error) {
|
|
376
|
-
if (error instanceof CollectionError) {
|
|
377
|
-
throw error;
|
|
378
|
-
}
|
|
379
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
380
|
-
}
|
|
202
|
+
return this.skipUntil((...arguments_) => !predicateFn(...arguments_));
|
|
381
203
|
}
|
|
382
204
|
when(condition, callback) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return callback(this);
|
|
386
|
-
}
|
|
387
|
-
return this;
|
|
388
|
-
}
|
|
389
|
-
catch (error) {
|
|
390
|
-
if (error instanceof CollectionError) {
|
|
391
|
-
throw error;
|
|
392
|
-
}
|
|
393
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
205
|
+
if (condition) {
|
|
206
|
+
return callback(this);
|
|
394
207
|
}
|
|
208
|
+
return this;
|
|
395
209
|
}
|
|
396
210
|
whenEmpty(callback) {
|
|
397
|
-
|
|
398
|
-
return this.when(this.isEmpty(), callback);
|
|
399
|
-
}
|
|
400
|
-
catch (error) {
|
|
401
|
-
if (error instanceof CollectionError) {
|
|
402
|
-
throw error;
|
|
403
|
-
}
|
|
404
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
405
|
-
}
|
|
211
|
+
return this.when(this.isEmpty(), callback);
|
|
406
212
|
}
|
|
407
213
|
whenNot(condition, callback) {
|
|
408
|
-
|
|
409
|
-
return this.when(!condition, callback);
|
|
410
|
-
}
|
|
411
|
-
catch (error) {
|
|
412
|
-
if (error instanceof CollectionError) {
|
|
413
|
-
throw error;
|
|
414
|
-
}
|
|
415
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
416
|
-
}
|
|
214
|
+
return this.when(!condition, callback);
|
|
417
215
|
}
|
|
418
216
|
whenNotEmpty(callback) {
|
|
419
|
-
|
|
420
|
-
return this.when(this.isNotEmpty(), callback);
|
|
421
|
-
}
|
|
422
|
-
catch (error) {
|
|
423
|
-
if (error instanceof CollectionError) {
|
|
424
|
-
throw error;
|
|
425
|
-
}
|
|
426
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
427
|
-
}
|
|
217
|
+
return this.when(this.isNotEmpty(), callback);
|
|
428
218
|
}
|
|
429
219
|
pipe(callback) {
|
|
430
|
-
|
|
431
|
-
return callback(this);
|
|
432
|
-
}
|
|
433
|
-
catch (error) {
|
|
434
|
-
if (error instanceof CollectionError) {
|
|
435
|
-
throw error;
|
|
436
|
-
}
|
|
437
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
438
|
-
}
|
|
220
|
+
return callback(this);
|
|
439
221
|
}
|
|
440
222
|
tap(callback) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return new ListCollection(this);
|
|
444
|
-
}
|
|
445
|
-
catch (error) {
|
|
446
|
-
if (error instanceof CollectionError) {
|
|
447
|
-
throw error;
|
|
448
|
-
}
|
|
449
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
450
|
-
}
|
|
223
|
+
callback(this);
|
|
224
|
+
return new ListCollection(this);
|
|
451
225
|
}
|
|
452
226
|
chunk(chunkSize) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
chunks.push(new ListCollection(this.array.slice(index, index + chunkSize)));
|
|
457
|
-
}
|
|
458
|
-
return new ListCollection(chunks);
|
|
459
|
-
}
|
|
460
|
-
catch (error) {
|
|
461
|
-
if (error instanceof CollectionError) {
|
|
462
|
-
throw error;
|
|
463
|
-
}
|
|
464
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
227
|
+
const chunks = [];
|
|
228
|
+
for (let index = 0; index < this.size(); index += chunkSize) {
|
|
229
|
+
chunks.push(new ListCollection(this.array.slice(index, index + chunkSize)));
|
|
465
230
|
}
|
|
231
|
+
return new ListCollection(chunks);
|
|
466
232
|
}
|
|
467
233
|
chunkWhile(predicateFn) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
currentChunk = currentChunk.append([item]);
|
|
474
|
-
}
|
|
475
|
-
else if (predicateFn(item, index, currentChunk)) {
|
|
476
|
-
currentChunk = currentChunk.append([item]);
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
chunks.push(currentChunk);
|
|
480
|
-
currentChunk = new ListCollection([item]);
|
|
481
|
-
}
|
|
234
|
+
let currentChunk = new ListCollection([]);
|
|
235
|
+
const chunks = [];
|
|
236
|
+
for (const [index, item] of this.array.entries()) {
|
|
237
|
+
if (index === 0) {
|
|
238
|
+
currentChunk = currentChunk.append([item]);
|
|
482
239
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
240
|
+
else if (predicateFn(item, index, currentChunk)) {
|
|
241
|
+
currentChunk = currentChunk.append([item]);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
chunks.push(currentChunk);
|
|
245
|
+
currentChunk = new ListCollection([item]);
|
|
489
246
|
}
|
|
490
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
491
247
|
}
|
|
248
|
+
chunks.push(currentChunk);
|
|
249
|
+
return new ListCollection(chunks);
|
|
492
250
|
}
|
|
493
251
|
split(chunkAmount) {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
chunkSizes[chunkIndex] = chunkSizes[chunkIndex] + 1;
|
|
502
|
-
}
|
|
252
|
+
const size = this.size(), minChunkSize = Math.floor(size / chunkAmount), restSize = size % chunkAmount, chunkSizes = Array.from({
|
|
253
|
+
length: chunkAmount,
|
|
254
|
+
}).fill(minChunkSize);
|
|
255
|
+
for (let index = 1; index <= restSize; index++) {
|
|
256
|
+
const chunkIndex = (index - 1) % chunkAmount;
|
|
257
|
+
if (chunkSizes[chunkIndex]) {
|
|
258
|
+
chunkSizes[chunkIndex] = chunkSizes[chunkIndex] + 1;
|
|
503
259
|
}
|
|
504
|
-
let end = 0, start = 0;
|
|
505
|
-
const chunks = [];
|
|
506
|
-
for (const chunkSize of chunkSizes) {
|
|
507
|
-
end += chunkSize;
|
|
508
|
-
chunks.push(new ListCollection(this.array.slice(start, end)));
|
|
509
|
-
start += chunkSize;
|
|
510
|
-
}
|
|
511
|
-
return new ListCollection(chunks);
|
|
512
260
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
261
|
+
let end = 0, start = 0;
|
|
262
|
+
const chunks = [];
|
|
263
|
+
for (const chunkSize of chunkSizes) {
|
|
264
|
+
end += chunkSize;
|
|
265
|
+
chunks.push(new ListCollection(this.array.slice(start, end)));
|
|
266
|
+
start += chunkSize;
|
|
518
267
|
}
|
|
268
|
+
return new ListCollection(chunks);
|
|
519
269
|
}
|
|
520
270
|
partition(predicateFn) {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
chunkA.push(item);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
chunkB.push(item);
|
|
529
|
-
}
|
|
271
|
+
const chunkA = [], chunkB = [];
|
|
272
|
+
for (const [index, item] of this.array.entries()) {
|
|
273
|
+
if (predicateFn(item, index, this)) {
|
|
274
|
+
chunkA.push(item);
|
|
530
275
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
new ListCollection(chunkB),
|
|
534
|
-
]);
|
|
535
|
-
}
|
|
536
|
-
catch (error) {
|
|
537
|
-
if (error instanceof CollectionError) {
|
|
538
|
-
throw error;
|
|
276
|
+
else {
|
|
277
|
+
chunkB.push(item);
|
|
539
278
|
}
|
|
540
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
541
279
|
}
|
|
280
|
+
return new ListCollection([
|
|
281
|
+
new ListCollection(chunkA),
|
|
282
|
+
new ListCollection(chunkB),
|
|
283
|
+
]);
|
|
542
284
|
}
|
|
543
285
|
sliding(chunkSize, step = chunkSize - 1) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
return new ListCollection([]);
|
|
548
|
-
}
|
|
549
|
-
for (let index = 0; index < this.size(); index += step) {
|
|
550
|
-
const start = index;
|
|
551
|
-
const end = index + chunkSize;
|
|
552
|
-
chunks = chunks.append([this.slice(start, end)]);
|
|
553
|
-
if (end >= this.size()) {
|
|
554
|
-
break;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return chunks;
|
|
286
|
+
let chunks = new ListCollection([]);
|
|
287
|
+
if (step <= 0) {
|
|
288
|
+
return new ListCollection([]);
|
|
558
289
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
290
|
+
for (let index = 0; index < this.size(); index += step) {
|
|
291
|
+
const start = index;
|
|
292
|
+
const end = index + chunkSize;
|
|
293
|
+
chunks = chunks.append([this.slice(start, end)]);
|
|
294
|
+
if (end >= this.size()) {
|
|
295
|
+
break;
|
|
562
296
|
}
|
|
563
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
564
297
|
}
|
|
298
|
+
return chunks;
|
|
565
299
|
}
|
|
566
300
|
groupBy(selectFn = (item) => item) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
map.set(key, collection);
|
|
575
|
-
}
|
|
576
|
-
map.set(key, collection.append([item]));
|
|
577
|
-
}
|
|
578
|
-
return new ListCollection(map);
|
|
579
|
-
}
|
|
580
|
-
catch (error) {
|
|
581
|
-
if (error instanceof CollectionError) {
|
|
582
|
-
throw error;
|
|
301
|
+
const map = new Map();
|
|
302
|
+
for (const [index, item] of this.array.entries()) {
|
|
303
|
+
const key = selectFn(item, index, this);
|
|
304
|
+
let collection = map.get(key);
|
|
305
|
+
if (collection === undefined) {
|
|
306
|
+
collection = new ListCollection([]);
|
|
307
|
+
map.set(key, collection);
|
|
583
308
|
}
|
|
584
|
-
|
|
309
|
+
map.set(key, collection.append([item]));
|
|
585
310
|
}
|
|
311
|
+
return new ListCollection(map);
|
|
586
312
|
}
|
|
587
313
|
countBy(selectFn = (item) => item) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
map.set(key, 0);
|
|
594
|
-
}
|
|
595
|
-
const counter = map.get(key);
|
|
596
|
-
if (counter !== undefined) {
|
|
597
|
-
map.set(key, counter + 1);
|
|
598
|
-
}
|
|
314
|
+
const map = new Map();
|
|
315
|
+
for (const [index, item] of this.array.entries()) {
|
|
316
|
+
const key = selectFn(item, index, this);
|
|
317
|
+
if (!map.has(key)) {
|
|
318
|
+
map.set(key, 0);
|
|
599
319
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
if (error instanceof CollectionError) {
|
|
604
|
-
throw error;
|
|
320
|
+
const counter = map.get(key);
|
|
321
|
+
if (counter !== undefined) {
|
|
322
|
+
map.set(key, counter + 1);
|
|
605
323
|
}
|
|
606
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
607
324
|
}
|
|
325
|
+
return new ListCollection(map);
|
|
608
326
|
}
|
|
609
327
|
unique(selectFn = (item) => item) {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
items.push(item);
|
|
616
|
-
}
|
|
617
|
-
set.add(item_);
|
|
618
|
-
}
|
|
619
|
-
return new ListCollection(items);
|
|
620
|
-
}
|
|
621
|
-
catch (error) {
|
|
622
|
-
if (error instanceof CollectionError) {
|
|
623
|
-
throw error;
|
|
328
|
+
const set = new Set([]), items = [];
|
|
329
|
+
for (const [index, item] of this.array.entries()) {
|
|
330
|
+
const item_ = selectFn(item, index, this);
|
|
331
|
+
if (!set.has(item_)) {
|
|
332
|
+
items.push(item);
|
|
624
333
|
}
|
|
625
|
-
|
|
334
|
+
set.add(item_);
|
|
626
335
|
}
|
|
336
|
+
return new ListCollection(items);
|
|
627
337
|
}
|
|
628
338
|
difference(iterable, selectFn = (item) => item) {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return
|
|
632
|
-
return
|
|
633
|
-
|
|
634
|
-
selectFn(matchItem, matchIndex, matchCollection));
|
|
635
|
-
});
|
|
339
|
+
const differenceCollection = new ListCollection(iterable);
|
|
340
|
+
return this.filter((item, index, collection) => {
|
|
341
|
+
return !differenceCollection.some((matchItem, matchIndex, matchCollection) => {
|
|
342
|
+
return (selectFn(item, index, collection) ===
|
|
343
|
+
selectFn(matchItem, matchIndex, matchCollection));
|
|
636
344
|
});
|
|
637
|
-
}
|
|
638
|
-
catch (error) {
|
|
639
|
-
if (error instanceof CollectionError) {
|
|
640
|
-
throw error;
|
|
641
|
-
}
|
|
642
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
643
|
-
}
|
|
345
|
+
});
|
|
644
346
|
}
|
|
645
347
|
repeat(amount) {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
collection = collection.append(this);
|
|
650
|
-
}
|
|
651
|
-
return collection;
|
|
652
|
-
}
|
|
653
|
-
catch (error) {
|
|
654
|
-
if (error instanceof CollectionError) {
|
|
655
|
-
throw error;
|
|
656
|
-
}
|
|
657
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
348
|
+
let collection = new ListCollection([]);
|
|
349
|
+
for (let index = 0; index < amount; index++) {
|
|
350
|
+
collection = collection.append(this);
|
|
658
351
|
}
|
|
352
|
+
return collection;
|
|
659
353
|
}
|
|
660
354
|
padStart(maxLength, fillItems) {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
resultItemsArray.push(...fillItemsArray);
|
|
668
|
-
}
|
|
669
|
-
const restAmount = maxLength - (repeat * fillItemsArray.length + size);
|
|
670
|
-
for (let index = 0; index < restAmount; index++) {
|
|
671
|
-
const fillItem = fillItemsArray[index];
|
|
672
|
-
if (fillItem) {
|
|
673
|
-
resultItemsArray.push(fillItem);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
resultItemsArray.push(...this);
|
|
677
|
-
return new ListCollection(resultItemsArray);
|
|
355
|
+
const fillItemsArray = [...fillItems];
|
|
356
|
+
const size = this.size();
|
|
357
|
+
const repeat = Math.floor((maxLength - size) / fillItemsArray.length);
|
|
358
|
+
const resultItemsArray = [];
|
|
359
|
+
for (let index = 0; index < repeat; index++) {
|
|
360
|
+
resultItemsArray.push(...fillItemsArray);
|
|
678
361
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
362
|
+
const restAmount = maxLength - (repeat * fillItemsArray.length + size);
|
|
363
|
+
for (let index = 0; index < restAmount; index++) {
|
|
364
|
+
const fillItem = fillItemsArray[index];
|
|
365
|
+
if (fillItem) {
|
|
366
|
+
resultItemsArray.push(fillItem);
|
|
682
367
|
}
|
|
683
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
684
368
|
}
|
|
369
|
+
resultItemsArray.push(...this);
|
|
370
|
+
return new ListCollection(resultItemsArray);
|
|
685
371
|
}
|
|
686
372
|
padEnd(maxLength, fillItems) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
resultItemsArray.push(...fillItemsArray);
|
|
694
|
-
}
|
|
695
|
-
const restAmount = maxLength - (repeat * fillItemsArray.length + size);
|
|
696
|
-
for (let index = 0; index < restAmount; index++) {
|
|
697
|
-
const fillItem = fillItemsArray[index];
|
|
698
|
-
if (fillItem) {
|
|
699
|
-
resultItemsArray.push(fillItem);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
resultItemsArray.unshift(...this);
|
|
703
|
-
return new ListCollection(resultItemsArray);
|
|
373
|
+
const fillItemsArray = [...fillItems];
|
|
374
|
+
const size = this.size();
|
|
375
|
+
const repeat = Math.floor((maxLength - size) / fillItemsArray.length);
|
|
376
|
+
const resultItemsArray = [];
|
|
377
|
+
for (let index = 0; index < repeat; index++) {
|
|
378
|
+
resultItemsArray.push(...fillItemsArray);
|
|
704
379
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
380
|
+
const restAmount = maxLength - (repeat * fillItemsArray.length + size);
|
|
381
|
+
for (let index = 0; index < restAmount; index++) {
|
|
382
|
+
const fillItem = fillItemsArray[index];
|
|
383
|
+
if (fillItem) {
|
|
384
|
+
resultItemsArray.push(fillItem);
|
|
708
385
|
}
|
|
709
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
710
386
|
}
|
|
387
|
+
resultItemsArray.unshift(...this);
|
|
388
|
+
return new ListCollection(resultItemsArray);
|
|
711
389
|
}
|
|
712
390
|
slice(start, end) {
|
|
713
|
-
|
|
714
|
-
return new ListCollection(this.array.slice(start, end));
|
|
715
|
-
}
|
|
716
|
-
catch (error) {
|
|
717
|
-
if (error instanceof CollectionError) {
|
|
718
|
-
throw error;
|
|
719
|
-
}
|
|
720
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
721
|
-
}
|
|
391
|
+
return new ListCollection(this.array.slice(start, end));
|
|
722
392
|
}
|
|
723
393
|
prepend(iterable) {
|
|
724
|
-
|
|
725
|
-
return new ListCollection([...iterable, ...this.array]);
|
|
726
|
-
}
|
|
727
|
-
catch (error) {
|
|
728
|
-
if (error instanceof CollectionError) {
|
|
729
|
-
throw error;
|
|
730
|
-
}
|
|
731
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
732
|
-
}
|
|
394
|
+
return new ListCollection([...iterable, ...this.array]);
|
|
733
395
|
}
|
|
734
396
|
append(iterable) {
|
|
735
|
-
|
|
736
|
-
return new ListCollection([...this.array, ...iterable]);
|
|
737
|
-
}
|
|
738
|
-
catch (error) {
|
|
739
|
-
if (error instanceof CollectionError) {
|
|
740
|
-
throw error;
|
|
741
|
-
}
|
|
742
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
743
|
-
}
|
|
397
|
+
return new ListCollection([...this.array, ...iterable]);
|
|
744
398
|
}
|
|
745
399
|
insertBefore(predicateFn, iterable) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
return new ListCollection(this.array);
|
|
750
|
-
}
|
|
751
|
-
const newArray = [...this.array];
|
|
752
|
-
newArray.splice(index, 0, ...iterable);
|
|
753
|
-
return new ListCollection(newArray);
|
|
754
|
-
}
|
|
755
|
-
catch (error) {
|
|
756
|
-
if (error instanceof CollectionError) {
|
|
757
|
-
throw error;
|
|
758
|
-
}
|
|
759
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
400
|
+
const index = this.array.findIndex((item, index) => predicateFn(item, index, this));
|
|
401
|
+
if (index === -1) {
|
|
402
|
+
return new ListCollection(this.array);
|
|
760
403
|
}
|
|
404
|
+
const newArray = [...this.array];
|
|
405
|
+
newArray.splice(index, 0, ...iterable);
|
|
406
|
+
return new ListCollection(newArray);
|
|
761
407
|
}
|
|
762
408
|
insertAfter(predicateFn, iterable) {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
return new ListCollection(this.array);
|
|
767
|
-
}
|
|
768
|
-
const firstPart = this.array.slice(0, index + 1), lastPart = this.array.slice(index + 1);
|
|
769
|
-
return new ListCollection([
|
|
770
|
-
...firstPart,
|
|
771
|
-
...iterable,
|
|
772
|
-
...lastPart,
|
|
773
|
-
]);
|
|
774
|
-
}
|
|
775
|
-
catch (error) {
|
|
776
|
-
if (error instanceof CollectionError) {
|
|
777
|
-
throw error;
|
|
778
|
-
}
|
|
779
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
409
|
+
const index = this.array.findIndex((item, index) => predicateFn(item, index, this));
|
|
410
|
+
if (index === -1) {
|
|
411
|
+
return new ListCollection(this.array);
|
|
780
412
|
}
|
|
413
|
+
const firstPart = this.array.slice(0, index + 1), lastPart = this.array.slice(index + 1);
|
|
414
|
+
return new ListCollection([
|
|
415
|
+
...firstPart,
|
|
416
|
+
...iterable,
|
|
417
|
+
...lastPart,
|
|
418
|
+
]);
|
|
781
419
|
}
|
|
782
420
|
crossJoin(iterable) {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
return
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
return
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
];
|
|
803
|
-
}, []);
|
|
804
|
-
});
|
|
805
|
-
return new ListCollection(array);
|
|
806
|
-
}
|
|
807
|
-
catch (error) {
|
|
808
|
-
if (error instanceof CollectionError) {
|
|
809
|
-
throw error;
|
|
810
|
-
}
|
|
811
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
812
|
-
}
|
|
421
|
+
const array = [
|
|
422
|
+
[...this],
|
|
423
|
+
[...iterable],
|
|
424
|
+
]
|
|
425
|
+
.reduce((a, b) => {
|
|
426
|
+
return a
|
|
427
|
+
.map((x) => {
|
|
428
|
+
return b.map((y) => {
|
|
429
|
+
return [...x, y];
|
|
430
|
+
});
|
|
431
|
+
})
|
|
432
|
+
.reduce((c, b) => [...c, ...b], []);
|
|
433
|
+
}, [[]])
|
|
434
|
+
.map((combination) => {
|
|
435
|
+
return combination.reduce((a, b) => {
|
|
436
|
+
return [...a, ...(isIterable(b) ? b : [b])];
|
|
437
|
+
}, []);
|
|
438
|
+
});
|
|
439
|
+
return new ListCollection(array);
|
|
813
440
|
}
|
|
814
441
|
zip(iterable) {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
size = this.size();
|
|
820
|
-
}
|
|
821
|
-
const items = [];
|
|
822
|
-
for (let index = 0; index < size; index++) {
|
|
823
|
-
const itemA = this.array[index], itemB = iterableArray[index];
|
|
824
|
-
if (itemA === undefined || itemB === undefined) {
|
|
825
|
-
continue;
|
|
826
|
-
}
|
|
827
|
-
items.push([itemA, itemB]);
|
|
828
|
-
}
|
|
829
|
-
return new ListCollection(items);
|
|
442
|
+
const iterableArray = [...iterable];
|
|
443
|
+
let size = iterableArray.length;
|
|
444
|
+
if (size > this.size()) {
|
|
445
|
+
size = this.size();
|
|
830
446
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
447
|
+
const items = [];
|
|
448
|
+
for (let index = 0; index < size; index++) {
|
|
449
|
+
const itemA = this.array[index], itemB = iterableArray[index];
|
|
450
|
+
if (itemA === undefined || itemB === undefined) {
|
|
451
|
+
continue;
|
|
834
452
|
}
|
|
835
|
-
|
|
453
|
+
items.push([itemA, itemB]);
|
|
836
454
|
}
|
|
455
|
+
return new ListCollection(items);
|
|
837
456
|
}
|
|
838
457
|
sort(comparator) {
|
|
839
|
-
|
|
840
|
-
return new ListCollection(this.array.sort(comparator));
|
|
841
|
-
}
|
|
842
|
-
catch (error) {
|
|
843
|
-
if (error instanceof CollectionError) {
|
|
844
|
-
throw error;
|
|
845
|
-
}
|
|
846
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
847
|
-
}
|
|
458
|
+
return new ListCollection(this.array.sort(comparator));
|
|
848
459
|
}
|
|
849
460
|
reverse(_chunkSize) {
|
|
850
|
-
|
|
851
|
-
return new ListCollection([...this.array].reverse());
|
|
852
|
-
}
|
|
853
|
-
catch (error) {
|
|
854
|
-
if (error instanceof CollectionError) {
|
|
855
|
-
throw error;
|
|
856
|
-
}
|
|
857
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
858
|
-
}
|
|
461
|
+
return new ListCollection([...this.array].reverse());
|
|
859
462
|
}
|
|
860
463
|
shuffle(mathRandom = Math.random) {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
newArray[i] = newArray[j];
|
|
868
|
-
}
|
|
869
|
-
if (temp !== undefined) {
|
|
870
|
-
newArray[j] = temp;
|
|
871
|
-
}
|
|
464
|
+
const newArray = [...this.array];
|
|
465
|
+
for (let i = newArray.length - 1; i > 0; i--) {
|
|
466
|
+
const j = Math.floor(mathRandom() * (i + 1));
|
|
467
|
+
const temp = newArray[i];
|
|
468
|
+
if (newArray[j] !== undefined) {
|
|
469
|
+
newArray[i] = newArray[j];
|
|
872
470
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
catch (error) {
|
|
876
|
-
if (error instanceof CollectionError) {
|
|
877
|
-
throw error;
|
|
471
|
+
if (temp !== undefined) {
|
|
472
|
+
newArray[j] = temp;
|
|
878
473
|
}
|
|
879
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
880
474
|
}
|
|
475
|
+
return new ListCollection(newArray);
|
|
881
476
|
}
|
|
882
477
|
first(predicateFn) {
|
|
883
|
-
|
|
884
|
-
return this.firstOr(null, predicateFn);
|
|
885
|
-
}
|
|
886
|
-
catch (error) {
|
|
887
|
-
if (error instanceof CollectionError) {
|
|
888
|
-
throw error;
|
|
889
|
-
}
|
|
890
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
891
|
-
}
|
|
478
|
+
return this.firstOr(null, predicateFn);
|
|
892
479
|
}
|
|
893
480
|
firstOr(defaultValue, predicateFn) {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
return item;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
else {
|
|
903
|
-
const firstItem = this.array[0];
|
|
904
|
-
if (firstItem) {
|
|
905
|
-
return firstItem;
|
|
481
|
+
if (predicateFn) {
|
|
482
|
+
for (const [index, item] of this.array.entries()) {
|
|
483
|
+
if (predicateFn(item, index, this)) {
|
|
484
|
+
return item;
|
|
906
485
|
}
|
|
907
486
|
}
|
|
908
|
-
return simplifyLazyable(defaultValue);
|
|
909
487
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
488
|
+
else {
|
|
489
|
+
const firstItem = this.array[0];
|
|
490
|
+
if (firstItem) {
|
|
491
|
+
return firstItem;
|
|
913
492
|
}
|
|
914
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
915
493
|
}
|
|
494
|
+
return simplifyLazyable(defaultValue);
|
|
916
495
|
}
|
|
917
496
|
firstOrFail(predicateFn) {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
throw new ItemNotFoundCollectionError("Item was not found");
|
|
922
|
-
}
|
|
923
|
-
return item;
|
|
924
|
-
}
|
|
925
|
-
catch (error) {
|
|
926
|
-
if (error instanceof CollectionError) {
|
|
927
|
-
throw error;
|
|
928
|
-
}
|
|
929
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
497
|
+
const item = this.first(predicateFn);
|
|
498
|
+
if (item === null) {
|
|
499
|
+
throw new ItemNotFoundCollectionError("Item was not found");
|
|
930
500
|
}
|
|
501
|
+
return item;
|
|
931
502
|
}
|
|
932
503
|
last(predicateFn) {
|
|
933
|
-
|
|
934
|
-
return this.lastOr(null, predicateFn);
|
|
935
|
-
}
|
|
936
|
-
catch (error) {
|
|
937
|
-
if (error instanceof CollectionError) {
|
|
938
|
-
throw error;
|
|
939
|
-
}
|
|
940
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
941
|
-
}
|
|
504
|
+
return this.lastOr(null, predicateFn);
|
|
942
505
|
}
|
|
943
506
|
lastOr(defaultValue, predicateFn) {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
matchedItem = item;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
if (matchedItem) {
|
|
953
|
-
return matchedItem;
|
|
507
|
+
if (predicateFn) {
|
|
508
|
+
let matchedItem = null;
|
|
509
|
+
for (const [index, item] of this.array.entries()) {
|
|
510
|
+
if (predicateFn(item, index, this)) {
|
|
511
|
+
matchedItem = item;
|
|
954
512
|
}
|
|
955
513
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
if (lastItem) {
|
|
959
|
-
return lastItem;
|
|
960
|
-
}
|
|
514
|
+
if (matchedItem) {
|
|
515
|
+
return matchedItem;
|
|
961
516
|
}
|
|
962
|
-
return simplifyLazyable(defaultValue);
|
|
963
517
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
518
|
+
else {
|
|
519
|
+
const lastItem = this.array.at(-1);
|
|
520
|
+
if (lastItem) {
|
|
521
|
+
return lastItem;
|
|
967
522
|
}
|
|
968
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
969
523
|
}
|
|
524
|
+
return simplifyLazyable(defaultValue);
|
|
970
525
|
}
|
|
971
526
|
lastOrFail(predicateFn) {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
throw new ItemNotFoundCollectionError("Item was not found");
|
|
976
|
-
}
|
|
977
|
-
return item;
|
|
978
|
-
}
|
|
979
|
-
catch (error) {
|
|
980
|
-
if (error instanceof CollectionError) {
|
|
981
|
-
throw error;
|
|
982
|
-
}
|
|
983
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
527
|
+
const item = this.last(predicateFn);
|
|
528
|
+
if (item === null) {
|
|
529
|
+
throw new ItemNotFoundCollectionError("Item was not found");
|
|
984
530
|
}
|
|
531
|
+
return item;
|
|
985
532
|
}
|
|
986
533
|
before(predicateFn) {
|
|
987
|
-
|
|
988
|
-
return this.beforeOr(null, predicateFn);
|
|
989
|
-
}
|
|
990
|
-
catch (error) {
|
|
991
|
-
if (error instanceof CollectionError) {
|
|
992
|
-
throw error;
|
|
993
|
-
}
|
|
994
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
995
|
-
}
|
|
534
|
+
return this.beforeOr(null, predicateFn);
|
|
996
535
|
}
|
|
997
536
|
beforeOr(defaultValue, predicateFn) {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
beforeItem !== undefined) {
|
|
1003
|
-
return beforeItem;
|
|
1004
|
-
}
|
|
537
|
+
for (const [index, item] of this.array.entries()) {
|
|
538
|
+
const beforeItem = this.array[index - 1];
|
|
539
|
+
if (predicateFn(item, index, this) && beforeItem !== undefined) {
|
|
540
|
+
return beforeItem;
|
|
1005
541
|
}
|
|
1006
|
-
return simplifyLazyable(defaultValue);
|
|
1007
|
-
}
|
|
1008
|
-
catch (error) {
|
|
1009
|
-
if (error instanceof CollectionError) {
|
|
1010
|
-
throw error;
|
|
1011
|
-
}
|
|
1012
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1013
542
|
}
|
|
543
|
+
return simplifyLazyable(defaultValue);
|
|
1014
544
|
}
|
|
1015
545
|
beforeOrFail(predicateFn) {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
throw new ItemNotFoundCollectionError("Item was not found");
|
|
1020
|
-
}
|
|
1021
|
-
return item;
|
|
1022
|
-
}
|
|
1023
|
-
catch (error) {
|
|
1024
|
-
if (error instanceof CollectionError) {
|
|
1025
|
-
throw error;
|
|
1026
|
-
}
|
|
1027
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
546
|
+
const item = this.before(predicateFn);
|
|
547
|
+
if (item === null) {
|
|
548
|
+
throw new ItemNotFoundCollectionError("Item was not found");
|
|
1028
549
|
}
|
|
550
|
+
return item;
|
|
1029
551
|
}
|
|
1030
552
|
after(predicateFn) {
|
|
1031
|
-
|
|
1032
|
-
return this.afterOr(null, predicateFn);
|
|
1033
|
-
}
|
|
1034
|
-
catch (error) {
|
|
1035
|
-
if (error instanceof CollectionError) {
|
|
1036
|
-
throw error;
|
|
1037
|
-
}
|
|
1038
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1039
|
-
}
|
|
553
|
+
return this.afterOr(null, predicateFn);
|
|
1040
554
|
}
|
|
1041
555
|
afterOr(defaultValue, predicateFn) {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
beforeItem !== undefined) {
|
|
1047
|
-
return beforeItem;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
return simplifyLazyable(defaultValue);
|
|
1051
|
-
}
|
|
1052
|
-
catch (error) {
|
|
1053
|
-
if (error instanceof CollectionError) {
|
|
1054
|
-
throw error;
|
|
556
|
+
for (const [index, item] of this.array.entries()) {
|
|
557
|
+
const beforeItem = this.array[index + 1];
|
|
558
|
+
if (predicateFn(item, index, this) && beforeItem !== undefined) {
|
|
559
|
+
return beforeItem;
|
|
1055
560
|
}
|
|
1056
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1057
561
|
}
|
|
562
|
+
return simplifyLazyable(defaultValue);
|
|
1058
563
|
}
|
|
1059
564
|
afterOrFail(predicateFn) {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
throw new ItemNotFoundCollectionError("Item was not found");
|
|
1064
|
-
}
|
|
1065
|
-
return item;
|
|
1066
|
-
}
|
|
1067
|
-
catch (error) {
|
|
1068
|
-
if (error instanceof CollectionError) {
|
|
1069
|
-
throw error;
|
|
1070
|
-
}
|
|
1071
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
565
|
+
const item = this.after(predicateFn);
|
|
566
|
+
if (item === null) {
|
|
567
|
+
throw new ItemNotFoundCollectionError("Item was not found");
|
|
1072
568
|
}
|
|
569
|
+
return item;
|
|
1073
570
|
}
|
|
1074
571
|
sole(predicateFn) {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
matchedItems.push(item);
|
|
1080
|
-
}
|
|
1081
|
-
if (matchedItems.length > 1) {
|
|
1082
|
-
throw new MultipleItemsFoundCollectionError("Multiple items were found");
|
|
1083
|
-
}
|
|
572
|
+
const matchedItems = [];
|
|
573
|
+
for (const [index, item] of this.array.entries()) {
|
|
574
|
+
if (predicateFn(item, index, this)) {
|
|
575
|
+
matchedItems.push(item);
|
|
1084
576
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
throw new ItemNotFoundCollectionError("Item was not found");
|
|
577
|
+
if (matchedItems.length > 1) {
|
|
578
|
+
throw new MultipleItemsFoundCollectionError("Multiple items were found");
|
|
1088
579
|
}
|
|
1089
|
-
return matchedItem;
|
|
1090
580
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1095
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
581
|
+
const [matchedItem] = matchedItems;
|
|
582
|
+
if (matchedItem === undefined) {
|
|
583
|
+
throw new ItemNotFoundCollectionError("Item was not found");
|
|
1096
584
|
}
|
|
585
|
+
return matchedItem;
|
|
1097
586
|
}
|
|
1098
587
|
nth(step) {
|
|
1099
|
-
|
|
1100
|
-
return this.filter((_item, index) => index % step === 0);
|
|
1101
|
-
}
|
|
1102
|
-
catch (error) {
|
|
1103
|
-
if (error instanceof CollectionError) {
|
|
1104
|
-
throw error;
|
|
1105
|
-
}
|
|
1106
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1107
|
-
}
|
|
588
|
+
return this.filter((_item, index) => index % step === 0);
|
|
1108
589
|
}
|
|
1109
590
|
count(predicateFn) {
|
|
1110
|
-
|
|
1111
|
-
return this.filter(predicateFn).size();
|
|
1112
|
-
}
|
|
1113
|
-
catch (error) {
|
|
1114
|
-
if (error instanceof CollectionError) {
|
|
1115
|
-
throw error;
|
|
1116
|
-
}
|
|
1117
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1118
|
-
}
|
|
591
|
+
return this.filter(predicateFn).size();
|
|
1119
592
|
}
|
|
1120
593
|
size() {
|
|
1121
|
-
|
|
1122
|
-
return this.array.length;
|
|
1123
|
-
}
|
|
1124
|
-
catch (error) {
|
|
1125
|
-
if (error instanceof CollectionError) {
|
|
1126
|
-
throw error;
|
|
1127
|
-
}
|
|
1128
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1129
|
-
}
|
|
594
|
+
return this.array.length;
|
|
1130
595
|
}
|
|
1131
596
|
isEmpty() {
|
|
1132
|
-
|
|
1133
|
-
return this.array.length === 0;
|
|
1134
|
-
}
|
|
1135
|
-
catch (error) {
|
|
1136
|
-
if (error instanceof CollectionError) {
|
|
1137
|
-
throw error;
|
|
1138
|
-
}
|
|
1139
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1140
|
-
}
|
|
597
|
+
return this.array.length === 0;
|
|
1141
598
|
}
|
|
1142
599
|
isNotEmpty() {
|
|
1143
|
-
|
|
1144
|
-
return this.array.length !== 0;
|
|
1145
|
-
}
|
|
1146
|
-
catch (error) {
|
|
1147
|
-
if (error instanceof CollectionError) {
|
|
1148
|
-
throw error;
|
|
1149
|
-
}
|
|
1150
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1151
|
-
}
|
|
600
|
+
return this.array.length !== 0;
|
|
1152
601
|
}
|
|
1153
602
|
searchFirst(predicateFn) {
|
|
1154
|
-
|
|
1155
|
-
return this.array.findIndex((item, index) => predicateFn(item, index, this));
|
|
1156
|
-
}
|
|
1157
|
-
catch (error) {
|
|
1158
|
-
if (error instanceof CollectionError) {
|
|
1159
|
-
throw error;
|
|
1160
|
-
}
|
|
1161
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1162
|
-
}
|
|
603
|
+
return this.array.findIndex((item, index) => predicateFn(item, index, this));
|
|
1163
604
|
}
|
|
1164
605
|
searchLast(predicateFn) {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
matchedIndex = index;
|
|
1170
|
-
}
|
|
606
|
+
let matchedIndex = -1;
|
|
607
|
+
for (const [index, item] of this.array.entries()) {
|
|
608
|
+
if (predicateFn(item, index, this)) {
|
|
609
|
+
matchedIndex = index;
|
|
1171
610
|
}
|
|
1172
|
-
return matchedIndex;
|
|
1173
|
-
}
|
|
1174
|
-
catch (error) {
|
|
1175
|
-
if (error instanceof CollectionError) {
|
|
1176
|
-
throw error;
|
|
1177
|
-
}
|
|
1178
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1179
611
|
}
|
|
612
|
+
return matchedIndex;
|
|
1180
613
|
}
|
|
1181
614
|
forEach(callback) {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
callback(item, index, this);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
catch (error) {
|
|
1188
|
-
if (error instanceof CollectionError) {
|
|
1189
|
-
throw error;
|
|
1190
|
-
}
|
|
1191
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
615
|
+
for (const [index, item] of this.array.entries()) {
|
|
616
|
+
callback(item, index, this);
|
|
1192
617
|
}
|
|
1193
618
|
}
|
|
1194
619
|
toArray() {
|
|
1195
|
-
|
|
1196
|
-
return [...this.array];
|
|
1197
|
-
}
|
|
1198
|
-
catch (error) {
|
|
1199
|
-
if (error instanceof CollectionError) {
|
|
1200
|
-
throw error;
|
|
1201
|
-
}
|
|
1202
|
-
throw new UnexpectedCollectionError(`Unexpected error "${String(error)}" occured`, error);
|
|
1203
|
-
}
|
|
620
|
+
return [...this.array];
|
|
1204
621
|
}
|
|
1205
622
|
}
|
|
1206
623
|
//# sourceMappingURL=list-collection.js.map
|