@daiso-tech/core 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -45
- package/dist/async/_module-exports.d.ts +1 -1
- package/dist/async/_module-exports.js +1 -1
- package/dist/async/_module-exports.js.map +1 -1
- package/dist/async/async.errors.d.ts +27 -19
- package/dist/async/async.errors.js +33 -20
- package/dist/async/async.errors.js.map +1 -1
- package/dist/async/backof-policies/_shared.d.ts +6 -2
- package/dist/async/backof-policies/_shared.js +1 -0
- package/dist/async/backof-policies/_shared.js.map +1 -1
- package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +1 -1
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +1 -1
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +1 -1
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +2 -2
- package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +1 -1
- package/dist/async/middlewares/_module.d.ts +8 -0
- package/dist/async/middlewares/_module.js +9 -0
- package/dist/async/middlewares/_module.js.map +1 -0
- package/dist/async/middlewares/_shared.d.ts +10 -0
- package/dist/async/middlewares/_shared.js +5 -0
- package/dist/async/middlewares/_shared.js.map +1 -0
- package/dist/async/middlewares/bulkhead/_module.d.ts +1 -0
- package/dist/async/middlewares/bulkhead/_module.js +2 -0
- package/dist/async/middlewares/bulkhead/_module.js.map +1 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +80 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +46 -0
- package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +1 -0
- package/dist/async/middlewares/dynamic/_module.d.ts +1 -0
- package/dist/async/middlewares/dynamic/_module.js +2 -0
- package/dist/async/middlewares/dynamic/_module.js.map +1 -0
- package/dist/async/middlewares/dynamic/dynamic.middleware.d.ts +34 -0
- package/dist/async/middlewares/dynamic/dynamic.middleware.js +36 -0
- package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +1 -0
- package/dist/async/middlewares/fallback/_module.d.ts +1 -0
- package/dist/async/middlewares/fallback/_module.js +2 -0
- package/dist/async/middlewares/fallback/_module.js.map +1 -0
- package/dist/async/middlewares/fallback/fallback.middleware.d.ts +78 -0
- package/dist/async/middlewares/fallback/fallback.middleware.js +52 -0
- package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -0
- package/dist/async/middlewares/hedging/_module.d.ts +2 -0
- package/dist/async/middlewares/hedging/_module.js +3 -0
- package/dist/async/middlewares/hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/_shared.d.ts +93 -0
- package/dist/async/middlewares/hedging/_shared.js +5 -0
- package/dist/async/middlewares/hedging/_shared.js.map +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.d.ts +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.js +2 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.d.ts +51 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +138 -0
- package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.d.ts +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.js +2 -0
- package/dist/async/middlewares/hedging/sequential-hedging/_module.js.map +1 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.d.ts +51 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +104 -0
- package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +1 -0
- package/dist/async/middlewares/observe/_module.d.ts +1 -0
- package/dist/async/middlewares/observe/_module.js +2 -0
- package/dist/async/middlewares/observe/_module.js.map +1 -0
- package/dist/async/middlewares/observe/observe.middleware.d.ts +130 -0
- package/dist/async/middlewares/observe/observe.middleware.js +80 -0
- package/dist/async/middlewares/observe/observe.middleware.js.map +1 -0
- package/dist/async/middlewares/retry/_module.d.ts +1 -0
- package/dist/async/middlewares/retry/_module.js +2 -0
- package/dist/async/middlewares/retry/_module.js.map +1 -0
- package/dist/async/middlewares/retry/retry.middleware.d.ts +117 -0
- package/dist/async/middlewares/retry/retry.middleware.js +82 -0
- package/dist/async/middlewares/retry/retry.middleware.js.map +1 -0
- package/dist/async/middlewares/timeout/_module.d.ts +1 -0
- package/dist/async/middlewares/timeout/_module.js +2 -0
- package/dist/async/middlewares/timeout/_module.js.map +1 -0
- package/dist/async/middlewares/timeout/timeout.middleware.d.ts +83 -0
- package/dist/async/middlewares/timeout/timeout.middleware.js +60 -0
- package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -0
- package/dist/async/utilities/_module.d.ts +3 -4
- package/dist/async/utilities/_module.js +3 -4
- package/dist/async/utilities/_module.js.map +1 -1
- package/dist/async/utilities/abort-and-fail/_module.d.ts +1 -0
- package/dist/async/utilities/abort-and-fail/_module.js +2 -0
- package/dist/async/utilities/abort-and-fail/_module.js.map +1 -0
- package/dist/async/utilities/abort-and-fail/abort-and-fail.d.ts +7 -0
- package/dist/async/utilities/{abort → abort-and-fail}/abort-and-fail.js +6 -6
- package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +1 -0
- package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +37 -194
- package/dist/async/utilities/lazy-promise/lazy-promise.js +62 -359
- package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
- package/dist/async/utilities/promise-queue/_module.d.ts +1 -0
- package/dist/async/utilities/promise-queue/_module.js +2 -0
- package/dist/async/utilities/promise-queue/_module.js.map +1 -0
- package/dist/async/utilities/promise-queue/promise-queue.d.ts +32 -0
- package/dist/async/utilities/promise-queue/promise-queue.js +107 -0
- package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -0
- package/dist/async/utilities/timeout-and-fail/_module.d.ts +1 -0
- package/dist/async/utilities/timeout-and-fail/_module.js +2 -0
- package/dist/async/utilities/timeout-and-fail/_module.js.map +1 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +19 -0
- package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
- package/dist/cache/contracts/cache-adapter.contract.d.ts +14 -14
- package/dist/cache/contracts/cache-factory.contract.d.ts +3 -3
- package/dist/cache/contracts/cache.contract.d.ts +73 -73
- package/dist/cache/contracts/cache.errors.d.ts +7 -7
- package/dist/cache/contracts/cache.errors.js +7 -7
- package/dist/cache/contracts/cache.events.d.ts +54 -58
- package/dist/cache/contracts/cache.events.js +6 -104
- package/dist/cache/contracts/cache.events.js.map +1 -1
- package/dist/cache/contracts/database-cache-adapter.contract.d.ts +16 -16
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +3 -3
- package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +3 -9
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +3 -9
- package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +4 -4
- package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +3 -3
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +2 -2
- package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +3 -3
- package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +2 -2
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +3 -3
- package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +2 -2
- package/dist/cache/implementations/derivables/cache/cache.d.ts +26 -27
- package/dist/cache/implementations/derivables/cache/cache.js +102 -91
- package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +5 -4
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +2 -1
- package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +3 -3
- package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +2 -2
- package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +3 -3
- package/dist/cache/implementations/test-utilities/cache.test-suite.js +140 -149
- package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +3 -3
- package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +2 -2
- package/dist/collection/contracts/_shared/compartor.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/cross-join-result.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/ensure-map.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/ensure-record.type.d.ts +1 -1
- package/dist/collection/contracts/_shared/foreach.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/map.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/modifier.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/predicate.type.d.ts +7 -7
- package/dist/collection/contracts/_shared/reduce.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/tap.type.d.ts +2 -2
- package/dist/collection/contracts/_shared/transform.type.d.ts +2 -2
- package/dist/collection/contracts/async-collection.contract.d.ts +109 -198
- package/dist/collection/contracts/collection.contract.d.ts +103 -103
- package/dist/collection/contracts/collection.errors.d.ts +11 -11
- package/dist/collection/contracts/collection.errors.js +11 -11
- package/dist/collection/implementations/_shared.d.ts +8 -8
- package/dist/collection/implementations/_shared.js +8 -8
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.d.ts +0 -4
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.js +0 -4
- package/dist/collection/implementations/async-iterable-collection/_shared/_module.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-cross-join-iterable.js +21 -19
- package/dist/collection/implementations/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +15 -19
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +15 -30
- package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.d.ts +3 -3
- package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.js +18 -20
- package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +11 -12
- package/dist/collection/implementations/iterable-collection/iterable-collection.js +11 -12
- package/dist/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
- package/dist/collection/implementations/list-collection/list-collection.d.ts +11 -11
- package/dist/collection/implementations/list-collection/list-collection.js +24 -30
- package/dist/collection/implementations/list-collection/list-collection.js.map +1 -1
- package/dist/event-bus/contracts/_module-exports.d.ts +0 -1
- package/dist/event-bus/contracts/_module-exports.js +0 -1
- package/dist/event-bus/contracts/_module-exports.js.map +1 -1
- package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +13 -8
- package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +6 -7
- package/dist/event-bus/contracts/event-bus-factory.contract.js.map +1 -1
- package/dist/event-bus/contracts/event-bus.contract.d.ts +30 -41
- package/dist/event-bus/contracts/event-bus.errors.d.ts +8 -8
- package/dist/event-bus/contracts/event-bus.errors.js +8 -8
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +3 -3
- package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +3 -3
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +2 -2
- package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +2 -2
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +3 -3
- package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +2 -2
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +15 -15
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +32 -32
- package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +17 -10
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +13 -6
- package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +3 -5
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +15 -22
- package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +3 -5
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +189 -209
- package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
- package/dist/lock/contracts/database-lock-adapter.contract.d.ts +9 -9
- package/dist/lock/contracts/lock-adapter.contract.d.ts +7 -7
- package/dist/lock/contracts/lock-provider-factory.contract.d.ts +4 -4
- package/dist/lock/contracts/lock-provider.contract.d.ts +14 -14
- package/dist/lock/contracts/lock.contract.d.ts +22 -22
- package/dist/lock/contracts/lock.errors.d.ts +10 -10
- package/dist/lock/contracts/lock.errors.js +10 -10
- package/dist/lock/contracts/lock.events.d.ts +45 -54
- package/dist/lock/contracts/lock.events.js +9 -91
- package/dist/lock/contracts/lock.events.js.map +1 -1
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +5 -5
- package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +4 -4
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +3 -3
- package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +3 -3
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +5 -5
- package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +4 -4
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +2 -2
- package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +2 -2
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +3 -3
- package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +3 -3
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +5 -5
- package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +4 -4
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +33 -33
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +30 -30
- package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +2 -2
- package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +3 -3
- package/dist/lock/implementations/derivables/lock-provider/lock.js +77 -58
- package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +5 -4
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +2 -1
- package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +3 -3
- package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +2 -2
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +3 -3
- package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +2 -2
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +3 -3
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +214 -214
- package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
- package/dist/serde/contracts/deserializer.contract.d.ts +2 -2
- package/dist/serde/contracts/flexible-serde-adapter.contract.d.ts +4 -4
- package/dist/serde/contracts/flexible-serde.contract.d.ts +8 -19
- package/dist/serde/contracts/serde.contract.d.ts +2 -2
- package/dist/serde/contracts/serde.errors.d.ts +4 -4
- package/dist/serde/contracts/serde.errors.js +4 -4
- package/dist/serde/contracts/serializable.contract.d.ts +2 -2
- package/dist/serde/contracts/serializer.contract.d.ts +2 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +2 -2
- package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +2 -2
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +1 -1
- package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +1 -1
- package/dist/serde/implementations/derivables/serde.d.ts +4 -35
- package/dist/serde/implementations/derivables/serde.js +2 -47
- package/dist/serde/implementations/derivables/serde.js.map +1 -1
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +2 -2
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +3 -3
- package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +2 -2
- package/dist/utilities/classes/_module.d.ts +1 -1
- package/dist/utilities/classes/_module.js +1 -1
- package/dist/utilities/classes/_module.js.map +1 -1
- package/dist/utilities/classes/hooks/_module.d.ts +3 -0
- package/dist/utilities/classes/hooks/_module.js +4 -0
- package/dist/utilities/classes/hooks/_module.js.map +1 -0
- package/dist/utilities/classes/hooks/async-hooks.d.ts +209 -0
- package/dist/utilities/classes/hooks/async-hooks.js +145 -0
- package/dist/utilities/classes/hooks/async-hooks.js.map +1 -0
- package/dist/utilities/classes/hooks/hooks.d.ts +139 -0
- package/dist/utilities/classes/hooks/hooks.js +116 -0
- package/dist/utilities/classes/hooks/hooks.js.map +1 -0
- package/dist/utilities/classes/hooks/types.d.ts +9 -0
- package/dist/utilities/classes/hooks/types.js +5 -0
- package/dist/utilities/classes/hooks/types.js.map +1 -0
- package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +3 -3
- package/dist/utilities/classes/key-prefixer/key-prefixer.js +4 -4
- package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
- package/dist/utilities/classes/time-span/time-span.d.ts +5 -5
- package/dist/utilities/classes/time-span/time-span.js +5 -5
- package/dist/utilities/contracts/_module.d.ts +0 -1
- package/dist/utilities/contracts/_module.js +0 -1
- package/dist/utilities/contracts/_module.js.map +1 -1
- package/dist/utilities/contracts/deinitizable.contract.d.ts +1 -1
- package/dist/utilities/contracts/initizable.contract.d.ts +1 -1
- package/dist/utilities/contracts/prunable.contract.d.ts +1 -1
- package/dist/utilities/contracts/serialized-error.contract.d.ts +1 -1
- package/dist/utilities/contracts/sqlite-database.contract.d.ts +2 -2
- package/dist/utilities/errors.d.ts +5 -5
- package/dist/utilities/errors.js +5 -5
- package/dist/utilities/functions/factory.js +3 -3
- package/dist/utilities/functions/factory.js.map +1 -1
- package/dist/utilities/functions/invokable.d.ts +9 -5
- package/dist/utilities/functions/invokable.js +12 -2
- package/dist/utilities/functions/invokable.js.map +1 -1
- package/dist/utilities/functions/lazy.d.ts +5 -0
- package/dist/utilities/functions/lazy.js +12 -3
- package/dist/utilities/functions/lazy.js.map +1 -1
- package/dist/utilities/types/async-iterable-value.type.d.ts +1 -1
- package/dist/utilities/types/at-least-one.type.d.ts +1 -1
- package/dist/utilities/types/factory.type.d.ts +8 -8
- package/dist/utilities/types/invokable.type.d.ts +3 -3
- package/dist/utilities/types/items.type.d.ts +1 -1
- package/dist/utilities/types/lazy.type.d.ts +5 -5
- package/dist/utilities/types/none-func.type.d.ts +1 -1
- package/dist/utilities/types/one-or-more.type.d.ts +1 -1
- package/dist/utilities/types/promiseable.type.d.ts +1 -1
- package/dist/utilities/types/result.type.d.ts +1 -1
- package/package.json +22 -2
- package/dist/async/async.events.d.ts +0 -105
- package/dist/async/async.events.js +0 -82
- package/dist/async/async.events.js.map +0 -1
- package/dist/async/utilities/abort/_module.d.ts +0 -2
- package/dist/async/utilities/abort/_module.js +0 -3
- package/dist/async/utilities/abort/_module.js.map +0 -1
- package/dist/async/utilities/abort/abort-and-fail.d.ts +0 -4
- package/dist/async/utilities/abort/abort-and-fail.js.map +0 -1
- package/dist/async/utilities/abort/abort.d.ts +0 -9
- package/dist/async/utilities/abort/abort.js +0 -18
- package/dist/async/utilities/abort/abort.js.map +0 -1
- package/dist/async/utilities/delay/_module.d.ts +0 -1
- package/dist/async/utilities/delay/_module.js +0 -2
- package/dist/async/utilities/delay/_module.js.map +0 -1
- package/dist/async/utilities/delay/delay.d.ts +0 -10
- package/dist/async/utilities/delay/delay.js +0 -34
- package/dist/async/utilities/delay/delay.js.map +0 -1
- package/dist/async/utilities/retry/_module.d.ts +0 -2
- package/dist/async/utilities/retry/_module.js +0 -3
- package/dist/async/utilities/retry/_module.js.map +0 -1
- package/dist/async/utilities/retry/retry-or-fail.d.ts +0 -29
- package/dist/async/utilities/retry/retry-or-fail.js +0 -39
- package/dist/async/utilities/retry/retry-or-fail.js.map +0 -1
- package/dist/async/utilities/retry/retry.d.ts +0 -10
- package/dist/async/utilities/retry/retry.js +0 -21
- package/dist/async/utilities/retry/retry.js.map +0 -1
- package/dist/async/utilities/timeout/_module.d.ts +0 -2
- package/dist/async/utilities/timeout/_module.js +0 -3
- package/dist/async/utilities/timeout/_module.js.map +0 -1
- package/dist/async/utilities/timeout/timeout-and-fail.d.ts +0 -5
- package/dist/async/utilities/timeout/timeout-and-fail.js +0 -28
- package/dist/async/utilities/timeout/timeout-and-fail.js.map +0 -1
- package/dist/async/utilities/timeout/timeout.d.ts +0 -10
- package/dist/async/utilities/timeout/timeout.js +0 -21
- package/dist/async/utilities/timeout/timeout.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.d.ts +0 -13
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +0 -30
- package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.d.ts +0 -13
- package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js +0 -36
- package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.d.ts +0 -9
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js +0 -39
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js.map +0 -1
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.d.ts +0 -13
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js +0 -52
- package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js.map +0 -1
- package/dist/event-bus/contracts/_shared.d.ts +0 -12
- package/dist/event-bus/contracts/_shared.js +0 -15
- package/dist/event-bus/contracts/_shared.js.map +0 -1
- package/dist/utilities/classes/sync-event-bus/_module.d.ts +0 -1
- package/dist/utilities/classes/sync-event-bus/_module.js +0 -2
- package/dist/utilities/classes/sync-event-bus/_module.js.map +0 -1
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.d.ts +0 -16
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.js +0 -53
- package/dist/utilities/classes/sync-event-bus/sync-event-bus.js.map +0 -1
- package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +0 -13
- package/dist/utilities/contracts/sync-event-bus-listenable.js +0 -5
- package/dist/utilities/contracts/sync-event-bus-listenable.js.map +0 -1
|
@@ -2,40 +2,40 @@
|
|
|
2
2
|
* @module Collection
|
|
3
3
|
*/
|
|
4
4
|
import type { AsyncReduce, CrossJoinResult, AsyncPredicate, AsyncForEach, AsyncMap, AsyncModifier, Tap, AsyncTransform, Comparator, EnsureRecord, EnsureMap } from "../../collection/contracts/_shared/_module.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { AsyncLazyable, AsyncIterableValue } from "../../utilities/_module-exports.js";
|
|
6
6
|
import type { LazyPromise } from "../../async/_module-exports.js";
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
|
|
10
10
|
*/
|
|
11
11
|
export type AsyncCollapse<TValue> = TValue extends Array<infer TItem> | Iterable<infer TItem> | IAsyncCollection<infer TItem> ? TItem : TValue;
|
|
12
12
|
/**
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
13
|
+
* The `IAsyncCollection` contract offers a fluent and efficient approach to working with {@link AsyncIterable} objects.
|
|
14
|
+
* `IAsyncCollection` is immutable.
|
|
15
15
|
*
|
|
16
|
-
* IMPORT_PATH:
|
|
16
|
+
* IMPORT_PATH: `"@daiso-tech/core/collection/contracts"`
|
|
17
17
|
* @group Contracts
|
|
18
18
|
* @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
|
|
19
19
|
*/
|
|
20
20
|
export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
21
21
|
/**
|
|
22
|
-
* The
|
|
22
|
+
* The `toIterator` method converts the collection to a new iterator.
|
|
23
23
|
*/
|
|
24
24
|
toIterator(): AsyncIterator<TInput, void>;
|
|
25
25
|
/**
|
|
26
|
-
* The
|
|
26
|
+
* The `entries` returns an IAsyncCollection of key, value pairs for every entry in the collection.
|
|
27
27
|
*/
|
|
28
28
|
entries(): IAsyncCollection<[number, TInput]>;
|
|
29
29
|
/**
|
|
30
|
-
* The
|
|
30
|
+
* The `keys` method returns an IAsyncCollection of keys in the collection.
|
|
31
31
|
*/
|
|
32
32
|
keys(): IAsyncCollection<number>;
|
|
33
33
|
/**
|
|
34
|
-
* The
|
|
34
|
+
* The `values` method returns a copy of the collection.
|
|
35
35
|
*/
|
|
36
36
|
values(): IAsyncCollection<TInput>;
|
|
37
37
|
/**
|
|
38
|
-
* The
|
|
38
|
+
* The `filter` method filters the collection using `predicateFn`, keeping only those items that pass `predicateFn`.
|
|
39
39
|
* @example
|
|
40
40
|
* ```ts
|
|
41
41
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -52,7 +52,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
52
52
|
*/
|
|
53
53
|
filter<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TOutput>;
|
|
54
54
|
/**
|
|
55
|
-
* The
|
|
55
|
+
* The `reject` method filters the collection using `predicateFn`, keeping only those items that not pass `predicateFn`.
|
|
56
56
|
* @example
|
|
57
57
|
* ```ts
|
|
58
58
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -69,8 +69,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
69
69
|
*/
|
|
70
70
|
reject<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<Exclude<TInput, TOutput>>;
|
|
71
71
|
/**
|
|
72
|
-
* The
|
|
73
|
-
* The
|
|
72
|
+
* The `map` method iterates through the collection and passes each item to `mapFn`.
|
|
73
|
+
* The `mapFn` is free to modify the item and return it, thus forming a new collection of modified items.
|
|
74
74
|
* @example
|
|
75
75
|
* ```ts
|
|
76
76
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -87,7 +87,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
87
87
|
*/
|
|
88
88
|
map<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TOutput>;
|
|
89
89
|
/**
|
|
90
|
-
* The
|
|
90
|
+
* The `reduce` method executes ` reduceFn ` function on each item of the array, passing in the return value from the calculation on the preceding item.
|
|
91
91
|
* The final result of running the reducer across all items of the array is a single value.
|
|
92
92
|
* @example
|
|
93
93
|
* ```ts
|
|
@@ -125,7 +125,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
125
125
|
reduce(reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TInput>, initialValue: TInput): LazyPromise<TInput>;
|
|
126
126
|
reduce<TOutput>(reduceFn: AsyncReduce<TInput, IAsyncCollection<TInput>, TOutput>, initialValue: TOutput): LazyPromise<TOutput>;
|
|
127
127
|
/**
|
|
128
|
-
* The
|
|
128
|
+
* The `join` method joins the collection's items with ` separator `. An error will be thrown when if a none string item is encounterd.
|
|
129
129
|
* @throws {TypeCollectionError}
|
|
130
130
|
* @example
|
|
131
131
|
* ```ts
|
|
@@ -156,7 +156,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
156
156
|
*/
|
|
157
157
|
join(separator?: string): LazyPromise<Extract<TInput, string>>;
|
|
158
158
|
/**
|
|
159
|
-
* The
|
|
159
|
+
* The `collapse` method collapses a collection of iterables into a single, flat collection.
|
|
160
160
|
* @example
|
|
161
161
|
* ```ts
|
|
162
162
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -173,8 +173,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
173
173
|
*/
|
|
174
174
|
collapse(): IAsyncCollection<AsyncCollapse<TInput>>;
|
|
175
175
|
/**
|
|
176
|
-
* The
|
|
177
|
-
* It is identical to a
|
|
176
|
+
* The `flatMap` method returns a new array formed by applying `mapFn` to each item of the array, and then collapses the result by one level.
|
|
177
|
+
* It is identical to a `map` method followed by a `collapse` method.
|
|
178
178
|
* @example
|
|
179
179
|
* ```ts
|
|
180
180
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -191,7 +191,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
191
191
|
*/
|
|
192
192
|
flatMap<TOutput>(mapFn: AsyncMap<TInput, IAsyncCollection<TInput>, Iterable<TOutput>>): IAsyncCollection<TOutput>;
|
|
193
193
|
/**
|
|
194
|
-
* The
|
|
194
|
+
* The `change` method changes only the items that passes `predicateFn` using `mapFn`.
|
|
195
195
|
* @example
|
|
196
196
|
* ```ts
|
|
197
197
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -208,7 +208,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
208
208
|
*/
|
|
209
209
|
change<TFilterOutput extends TInput, TMapOutput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TFilterOutput>, mapFn: AsyncMap<TFilterOutput, IAsyncCollection<TInput>, TMapOutput>): IAsyncCollection<TInput | TFilterOutput | TMapOutput>;
|
|
210
210
|
/**
|
|
211
|
-
* The
|
|
211
|
+
* The `set` method changes a item by i>index` using `value`.
|
|
212
212
|
* @example
|
|
213
213
|
* ```ts
|
|
214
214
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -238,7 +238,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
238
238
|
*/
|
|
239
239
|
set(index: number, value: TInput | AsyncMap<TInput, IAsyncCollection<TInput>, TInput>): IAsyncCollection<TInput>;
|
|
240
240
|
/**
|
|
241
|
-
* The
|
|
241
|
+
* The `get` method returns the item by index. If the item is not found null will returned.
|
|
242
242
|
* @example
|
|
243
243
|
* ```ts
|
|
244
244
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -257,7 +257,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
257
257
|
*/
|
|
258
258
|
get(index: number): LazyPromise<TInput | null>;
|
|
259
259
|
/**
|
|
260
|
-
* The
|
|
260
|
+
* The `getOrFail` method returns the item by index. If the item is not found an error will be thrown.
|
|
261
261
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
262
262
|
* @example
|
|
263
263
|
* ```ts
|
|
@@ -277,7 +277,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
277
277
|
*/
|
|
278
278
|
getOrFail(index: number): LazyPromise<TInput>;
|
|
279
279
|
/**
|
|
280
|
-
* The
|
|
280
|
+
* The `page` method returns a new collection containing the items that would be present on ` page ` with custom ` pageSize `.
|
|
281
281
|
* @example
|
|
282
282
|
* ```ts
|
|
283
283
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -294,7 +294,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
294
294
|
*/
|
|
295
295
|
page(page: number, pageSize: number): IAsyncCollection<TInput>;
|
|
296
296
|
/**
|
|
297
|
-
* The
|
|
297
|
+
* The `sum` method returns the sum of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
298
298
|
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
299
299
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
300
300
|
* @example
|
|
@@ -312,7 +312,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
312
312
|
*/
|
|
313
313
|
sum(): LazyPromise<Extract<TInput, number>>;
|
|
314
314
|
/**
|
|
315
|
-
* The
|
|
315
|
+
* The `average` method returns the average of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
316
316
|
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
317
317
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
318
318
|
* @example
|
|
@@ -330,7 +330,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
330
330
|
*/
|
|
331
331
|
average(): LazyPromise<Extract<TInput, number>>;
|
|
332
332
|
/**
|
|
333
|
-
* The
|
|
333
|
+
* The `median` method returns the median of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
334
334
|
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
335
335
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
336
336
|
* @example
|
|
@@ -348,7 +348,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
348
348
|
*/
|
|
349
349
|
median(): LazyPromise<Extract<TInput, number>>;
|
|
350
350
|
/**
|
|
351
|
-
* The
|
|
351
|
+
* The `min` method returns the min of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
352
352
|
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
353
353
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
354
354
|
* @example
|
|
@@ -366,7 +366,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
366
366
|
*/
|
|
367
367
|
min(): LazyPromise<Extract<TInput, number>>;
|
|
368
368
|
/**
|
|
369
|
-
* The
|
|
369
|
+
* The `max` method returns the max of all items in the collection. If the collection includes other than number items an error will be thrown.
|
|
370
370
|
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
371
371
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
372
372
|
* @example
|
|
@@ -384,7 +384,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
384
384
|
*/
|
|
385
385
|
max(): LazyPromise<Extract<TInput, number>>;
|
|
386
386
|
/**
|
|
387
|
-
* The
|
|
387
|
+
* The `percentage` method may be used to quickly determine the percentage of items in the collection that pass `predicateFn`.
|
|
388
388
|
* @throws {EmptyCollectionError} {@link EmptyCollectionError}
|
|
389
389
|
* @example
|
|
390
390
|
* ```ts
|
|
@@ -401,7 +401,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
401
401
|
*/
|
|
402
402
|
percentage(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
403
403
|
/**
|
|
404
|
-
* The
|
|
404
|
+
* The `some` method determines whether at least one item in the collection matches `predicateFn`.
|
|
405
405
|
* @example
|
|
406
406
|
* ```ts
|
|
407
407
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -417,7 +417,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
417
417
|
*/
|
|
418
418
|
some<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<boolean>;
|
|
419
419
|
/**
|
|
420
|
-
* The
|
|
420
|
+
* The `every` method determines whether all items in the collection matches `predicateFn`.
|
|
421
421
|
* @example
|
|
422
422
|
* ```ts
|
|
423
423
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -433,7 +433,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
433
433
|
*/
|
|
434
434
|
every<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<boolean>;
|
|
435
435
|
/**
|
|
436
|
-
* The
|
|
436
|
+
* The `take` method takes the first `limit` items.
|
|
437
437
|
* @example
|
|
438
438
|
* ```ts
|
|
439
439
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -463,7 +463,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
463
463
|
*/
|
|
464
464
|
take(limit: number): IAsyncCollection<TInput>;
|
|
465
465
|
/**
|
|
466
|
-
* The
|
|
466
|
+
* The `takeUntil` method takes items until `predicateFn` returns true.
|
|
467
467
|
* @example
|
|
468
468
|
* ```ts
|
|
469
469
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -480,7 +480,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
480
480
|
*/
|
|
481
481
|
takeUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
482
482
|
/**
|
|
483
|
-
* The
|
|
483
|
+
* The `takeWhile` method takes items until `predicateFn` returns false.
|
|
484
484
|
* @example
|
|
485
485
|
* ```ts
|
|
486
486
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -497,7 +497,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
497
497
|
*/
|
|
498
498
|
takeWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
499
499
|
/**
|
|
500
|
-
* The
|
|
500
|
+
* The `skip` method skips the first `offset` items.
|
|
501
501
|
* @example
|
|
502
502
|
* ```ts
|
|
503
503
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -514,7 +514,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
514
514
|
*/
|
|
515
515
|
skip(offset: number): IAsyncCollection<TInput>;
|
|
516
516
|
/**
|
|
517
|
-
* The
|
|
517
|
+
* The `skipUntil` method skips items until `predicateFn` returns true.
|
|
518
518
|
* @example
|
|
519
519
|
* ```ts
|
|
520
520
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -531,7 +531,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
531
531
|
*/
|
|
532
532
|
skipUntil(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
533
533
|
/**
|
|
534
|
-
* The
|
|
534
|
+
* The `skipWhile` method skips items until `predicateFn` returns false.
|
|
535
535
|
* @example
|
|
536
536
|
* ```ts
|
|
537
537
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -548,7 +548,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
548
548
|
*/
|
|
549
549
|
skipWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
550
550
|
/**
|
|
551
|
-
* The
|
|
551
|
+
* The `when` method will execute `callback` when `condition` evaluates to true.
|
|
552
552
|
* @example
|
|
553
553
|
* ```ts
|
|
554
554
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -566,7 +566,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
566
566
|
*/
|
|
567
567
|
when<TExtended = TInput>(condition: boolean, callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
568
568
|
/**
|
|
569
|
-
* The
|
|
569
|
+
* The `whenEmpty` method will execute `callback` when the collection is empty.
|
|
570
570
|
* @example
|
|
571
571
|
* ```ts
|
|
572
572
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -596,7 +596,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
596
596
|
*/
|
|
597
597
|
whenEmpty<TExtended = TInput>(callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
598
598
|
/**
|
|
599
|
-
* The
|
|
599
|
+
* The `whenNot` method will execute `callback` when `condition` evaluates to false.
|
|
600
600
|
* @example
|
|
601
601
|
* ```ts
|
|
602
602
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -614,7 +614,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
614
614
|
*/
|
|
615
615
|
whenNot<TExtended = TInput>(condition: boolean, callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
616
616
|
/**
|
|
617
|
-
* The
|
|
617
|
+
* The `whenNotEmpty` method will execute `callback` when the collection is not empty.
|
|
618
618
|
* @example
|
|
619
619
|
* ```ts
|
|
620
620
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -643,7 +643,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
643
643
|
*/
|
|
644
644
|
whenNotEmpty<TExtended = TInput>(callback: AsyncModifier<IAsyncCollection<TInput>, IAsyncCollection<TExtended>>): IAsyncCollection<TInput | TExtended>;
|
|
645
645
|
/**
|
|
646
|
-
* The
|
|
646
|
+
* The `pipe` method passes the orignal collection to `callback` and returns the result from `callback`.
|
|
647
647
|
* This method is useful when you want compose multiple smaller functions.
|
|
648
648
|
* @example
|
|
649
649
|
* ```ts
|
|
@@ -671,7 +671,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
671
671
|
*/
|
|
672
672
|
pipe<TOutput = TInput>(callback: AsyncTransform<IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
673
673
|
/**
|
|
674
|
-
* The
|
|
674
|
+
* The `tap` method passes a copy of the original collection to `callback`, allowing you to do something with the items while not affecting the original collection.
|
|
675
675
|
* @example
|
|
676
676
|
* ```ts
|
|
677
677
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -692,8 +692,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
692
692
|
*/
|
|
693
693
|
tap(callback: Tap<IAsyncCollection<TInput>>): IAsyncCollection<TInput>;
|
|
694
694
|
/**
|
|
695
|
-
* The
|
|
696
|
-
* If
|
|
695
|
+
* The `chunk` method breaks the collection into multiple, smaller collections of size `chunkSize`.
|
|
696
|
+
* If `chunkSize` is not divisible with total number of items then the last chunk will contain the remaining items.
|
|
697
697
|
* @example
|
|
698
698
|
* ```ts
|
|
699
699
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -711,8 +711,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
711
711
|
*/
|
|
712
712
|
chunk(chunkSize: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
713
713
|
/**
|
|
714
|
-
* The
|
|
715
|
-
* The chunk variable passed to the
|
|
714
|
+
* The `chunkWhile` method breaks the collection into multiple, smaller collections based on the evaluation of `predicateFn`.
|
|
715
|
+
* The chunk variable passed to the `predicateFn` may be used to inspect the previous item.
|
|
716
716
|
* @example
|
|
717
717
|
* ```ts
|
|
718
718
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -732,7 +732,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
732
732
|
*/
|
|
733
733
|
chunkWhile(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
734
734
|
/**
|
|
735
|
-
* The
|
|
735
|
+
* The `split` method breaks a collection evenly into `chunkAmount` of chunks.
|
|
736
736
|
* @example
|
|
737
737
|
* ```ts
|
|
738
738
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -777,7 +777,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
777
777
|
*/
|
|
778
778
|
split(chunkAmount: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
779
779
|
/**
|
|
780
|
-
* The
|
|
780
|
+
* The `partition` method is used to separate items that pass `predicateFn` from those that do not.
|
|
781
781
|
* @example
|
|
782
782
|
* ```ts
|
|
783
783
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -795,7 +795,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
795
795
|
*/
|
|
796
796
|
partition(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
797
797
|
/**
|
|
798
|
-
* The
|
|
798
|
+
* The `sliding` method returns a new collection of chunks representing a "sliding window" view of the items in the collection.
|
|
799
799
|
* @example
|
|
800
800
|
* ```ts
|
|
801
801
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -813,7 +813,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
813
813
|
*/
|
|
814
814
|
sliding(chunkSize: number, step?: number): IAsyncCollection<IAsyncCollection<TInput>>;
|
|
815
815
|
/**
|
|
816
|
-
* The
|
|
816
|
+
* The `groupBy` method groups the collection's items by ` selectFn `.
|
|
817
817
|
* By default the equality check occurs on the item.
|
|
818
818
|
* @example
|
|
819
819
|
* ```ts
|
|
@@ -868,7 +868,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
868
868
|
*/
|
|
869
869
|
groupBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, IAsyncCollection<TInput>]>;
|
|
870
870
|
/**
|
|
871
|
-
* The
|
|
871
|
+
* The `countBy` method counts the occurrences of values in the collection by ` selectFn `.
|
|
872
872
|
* By default the equality check occurs on the item.
|
|
873
873
|
* @example
|
|
874
874
|
* ```ts
|
|
@@ -907,7 +907,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
907
907
|
*/
|
|
908
908
|
countBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, number]>;
|
|
909
909
|
/**
|
|
910
|
-
* The
|
|
910
|
+
* The `unique` method removes all duplicate values from the collection by ` selectFn `.
|
|
911
911
|
* By default the equality check occurs on the item.
|
|
912
912
|
* @example
|
|
913
913
|
* ```ts
|
|
@@ -953,7 +953,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
953
953
|
*/
|
|
954
954
|
unique<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TInput>;
|
|
955
955
|
/**
|
|
956
|
-
* The
|
|
956
|
+
* The `difference` method will return the values in the original collection that are not present in `iterable`.
|
|
957
957
|
* By default the equality check occurs on the item.
|
|
958
958
|
* @example
|
|
959
959
|
* ```ts
|
|
@@ -1005,7 +1005,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1005
1005
|
*/
|
|
1006
1006
|
difference<TOutput = TInput>(iterable: AsyncIterableValue<TInput>, selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TInput>;
|
|
1007
1007
|
/**
|
|
1008
|
-
* The
|
|
1008
|
+
* The `repeat` method will repeat the original collection `amount` times.
|
|
1009
1009
|
* @example
|
|
1010
1010
|
* ```ts
|
|
1011
1011
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1022,7 +1022,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1022
1022
|
*/
|
|
1023
1023
|
repeat(amount: number): IAsyncCollection<TInput>;
|
|
1024
1024
|
/**
|
|
1025
|
-
* The
|
|
1025
|
+
* The `padStart` method pads this collection with `fillItems` until the resulting collection size reaches `maxLength`.
|
|
1026
1026
|
* The padding is applied from the start of this collection.
|
|
1027
1027
|
* @example
|
|
1028
1028
|
* ```ts
|
|
@@ -1070,7 +1070,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1070
1070
|
*/
|
|
1071
1071
|
padStart<TExtended = TInput>(maxLength: number, fillItems: AsyncIterableValue<TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
1072
1072
|
/**
|
|
1073
|
-
* The
|
|
1073
|
+
* The `padEnd` method pads this collection with `fillItems` until the resulting collection size reaches `maxLength`.
|
|
1074
1074
|
* The padding is applied from the end of this collection.
|
|
1075
1075
|
* @example
|
|
1076
1076
|
* ```ts
|
|
@@ -1118,8 +1118,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1118
1118
|
*/
|
|
1119
1119
|
padEnd<TExtended = TInput>(maxLength: number, fillItems: AsyncIterableValue<TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
1120
1120
|
/**
|
|
1121
|
-
* The
|
|
1122
|
-
* where
|
|
1121
|
+
* The `slice` method creates porition of the original collection selected from `start` and `end`
|
|
1122
|
+
* where `start` and `end` (end not included) represent the index of items in the collection.
|
|
1123
1123
|
* @example
|
|
1124
1124
|
* ```ts
|
|
1125
1125
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1201,7 +1201,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1201
1201
|
*/
|
|
1202
1202
|
slice(start?: number, end?: number): IAsyncCollection<TInput>;
|
|
1203
1203
|
/**
|
|
1204
|
-
* The
|
|
1204
|
+
* The `prepend` method adds `iterable` to the beginning of the collection.
|
|
1205
1205
|
* @example
|
|
1206
1206
|
* ```ts
|
|
1207
1207
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1218,7 +1218,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1218
1218
|
*/
|
|
1219
1219
|
prepend<TExtended = TInput>(iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
1220
1220
|
/**
|
|
1221
|
-
* The
|
|
1221
|
+
* The `append` method adds `iterable` to the end of the collection.
|
|
1222
1222
|
* @example
|
|
1223
1223
|
* ```ts
|
|
1224
1224
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1235,7 +1235,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1235
1235
|
*/
|
|
1236
1236
|
append<TExtended = TInput>(iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
1237
1237
|
/**
|
|
1238
|
-
* The
|
|
1238
|
+
* The `insertBefore` method adds `iterable` before the first item that matches `predicateFn`.
|
|
1239
1239
|
* @example
|
|
1240
1240
|
* ```ts
|
|
1241
1241
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1252,7 +1252,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1252
1252
|
*/
|
|
1253
1253
|
insertBefore<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
1254
1254
|
/**
|
|
1255
|
-
* The
|
|
1255
|
+
* The `insertAfter` method adds `iterable` after the first item that matches `predicateFn`.
|
|
1256
1256
|
* @example
|
|
1257
1257
|
* ```ts
|
|
1258
1258
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1269,7 +1269,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1269
1269
|
*/
|
|
1270
1270
|
insertAfter<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
1271
1271
|
/**
|
|
1272
|
-
* The
|
|
1272
|
+
* The `crossJoin` method cross joins the collection's values among `iterables`, returning a Cartesian product with all possible permutations.
|
|
1273
1273
|
* @example
|
|
1274
1274
|
* ```ts
|
|
1275
1275
|
* import { ICollection } from "@daiso-tech/core";;
|
|
@@ -1312,7 +1312,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1312
1312
|
*/
|
|
1313
1313
|
crossJoin<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<CrossJoinResult<TInput, TExtended>>;
|
|
1314
1314
|
/**
|
|
1315
|
-
* The
|
|
1315
|
+
* The `zip` method merges together the values of `iterable` with the values of the collection at their corresponding index.
|
|
1316
1316
|
* The returned collection has size of the shortest collection.
|
|
1317
1317
|
* @example
|
|
1318
1318
|
* ```ts
|
|
@@ -1356,7 +1356,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1356
1356
|
*/
|
|
1357
1357
|
zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<[TInput, TExtended]>;
|
|
1358
1358
|
/**
|
|
1359
|
-
* The
|
|
1359
|
+
* The `sort` method sorts the collection. You can provide a `comparator` function.
|
|
1360
1360
|
* @example
|
|
1361
1361
|
* ```ts
|
|
1362
1362
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1401,8 +1401,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1401
1401
|
*/
|
|
1402
1402
|
sort(comparator?: Comparator<TInput>): IAsyncCollection<TInput>;
|
|
1403
1403
|
/**
|
|
1404
|
-
* The
|
|
1405
|
-
* The reversing of the collection will be applied in chunks that are the size of
|
|
1404
|
+
* The `reverse` method will reverse the order of the collection.
|
|
1405
|
+
* The reversing of the collection will be applied in chunks that are the size of ` chunkSize `.
|
|
1406
1406
|
* @example
|
|
1407
1407
|
* ```ts
|
|
1408
1408
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1419,12 +1419,12 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1419
1419
|
*/
|
|
1420
1420
|
reverse(chunkSize?: number): IAsyncCollection<TInput>;
|
|
1421
1421
|
/**
|
|
1422
|
-
* The
|
|
1422
|
+
* The `shuffle` method randomly shuffles the items in the collection. You can provide a custom Math.random function by passing in `mathRandom`.
|
|
1423
1423
|
*/
|
|
1424
1424
|
shuffle(mathRandom?: () => number): IAsyncCollection<TInput>;
|
|
1425
1425
|
/**
|
|
1426
|
-
* The
|
|
1427
|
-
* By default it will get the first item. If the collection is empty or no items passes
|
|
1426
|
+
* The `first` method returns the first item in the collection that passes ` predicateFn `.
|
|
1427
|
+
* By default it will get the first item. If the collection is empty or no items passes ` predicateFn ` than null i returned.
|
|
1428
1428
|
* @example
|
|
1429
1429
|
* ```ts
|
|
1430
1430
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1464,8 +1464,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1464
1464
|
*/
|
|
1465
1465
|
first<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | null>;
|
|
1466
1466
|
/**
|
|
1467
|
-
* The
|
|
1468
|
-
* By default it will get the first item. If the collection is empty or no items passes
|
|
1467
|
+
* The `firstOr` method returns the first item in the collection that passes ` predicateFn `
|
|
1468
|
+
* By default it will get the first item. If the collection is empty or no items passes ` predicateFn ` than ` defaultValue `.
|
|
1469
1469
|
* @example
|
|
1470
1470
|
* ```ts
|
|
1471
1471
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1516,7 +1516,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1516
1516
|
* // -1
|
|
1517
1517
|
* }
|
|
1518
1518
|
* ```
|
|
1519
|
-
* You can pass a
|
|
1519
|
+
* You can pass a {@link LazyPromise| `LazyPromise`} as default value.
|
|
1520
1520
|
* @example
|
|
1521
1521
|
* ```ts
|
|
1522
1522
|
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
@@ -1532,8 +1532,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1532
1532
|
*/
|
|
1533
1533
|
firstOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | TExtended>;
|
|
1534
1534
|
/**
|
|
1535
|
-
* The
|
|
1536
|
-
* By default it will get the first item. If the collection is empty or no items passes
|
|
1535
|
+
* The `firstOrFail` method returns the first item in the collection that passes ` predicateFn `.
|
|
1536
|
+
* By default it will get the first item. If the collection is empty or no items passes ` predicateFn ` than error is thrown.
|
|
1537
1537
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1538
1538
|
* @example
|
|
1539
1539
|
* ```ts
|
|
@@ -1574,8 +1574,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1574
1574
|
*/
|
|
1575
1575
|
firstOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
1576
1576
|
/**
|
|
1577
|
-
* The
|
|
1578
|
-
* By default it will get the last item. If the collection is empty or no items passes
|
|
1577
|
+
* The `last` method returns the last item in the collection that passes ` predicateFn `.
|
|
1578
|
+
* By default it will get the last item. If the collection is empty or no items passes ` predicateFn ` than null i returned.
|
|
1579
1579
|
* @example
|
|
1580
1580
|
* ```ts
|
|
1581
1581
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1615,8 +1615,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1615
1615
|
*/
|
|
1616
1616
|
last<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | null>;
|
|
1617
1617
|
/**
|
|
1618
|
-
* The
|
|
1619
|
-
* By default it will get the last item. If the collection is empty or no items passes
|
|
1618
|
+
* The `lastOr` method returns the last item in the collection that passes ` predicateFn `.
|
|
1619
|
+
* By default it will get the last item. If the collection is empty or no items passes ` predicateFn ` than ` defaultValue `.
|
|
1620
1620
|
* @example
|
|
1621
1621
|
* ```ts
|
|
1622
1622
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1667,7 +1667,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1667
1667
|
* // -1
|
|
1668
1668
|
* }
|
|
1669
1669
|
* ```
|
|
1670
|
-
* You can pass a
|
|
1670
|
+
* You can pass a {@link LazyPromise| `LazyPromise`} as default value.
|
|
1671
1671
|
* @example
|
|
1672
1672
|
* ```ts
|
|
1673
1673
|
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
@@ -1683,8 +1683,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1683
1683
|
*/
|
|
1684
1684
|
lastOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | TExtended>;
|
|
1685
1685
|
/**
|
|
1686
|
-
* The
|
|
1687
|
-
* By default it will get the last item. If the collection is empty or no items passes
|
|
1686
|
+
* The `lastOrFail` method returns the last item in the collection that passes ` predicateFn `.
|
|
1687
|
+
* By default it will get the last item. If the collection is empty or no items passes ` predicateFn ` than error is thrown.
|
|
1688
1688
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1689
1689
|
* @example
|
|
1690
1690
|
* ```ts
|
|
@@ -1725,8 +1725,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1725
1725
|
*/
|
|
1726
1726
|
lastOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
1727
1727
|
/**
|
|
1728
|
-
* The
|
|
1729
|
-
* If the
|
|
1728
|
+
* The `before` method returns the item that comes before the first item that matches `predicateFn`.
|
|
1729
|
+
* If the `predicateFn` does not match or matches the first item then null is returned.
|
|
1730
1730
|
* @example
|
|
1731
1731
|
* ```ts
|
|
1732
1732
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1754,8 +1754,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1754
1754
|
*/
|
|
1755
1755
|
before(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | null>;
|
|
1756
1756
|
/**
|
|
1757
|
-
* The
|
|
1758
|
-
* If the collection is empty or the
|
|
1757
|
+
* The `beforeOr` method returns the item that comes before the first item that matches `predicateFn`.
|
|
1758
|
+
* If the collection is empty or the `predicateFn` does not match or matches the first item then `defaultValue` is returned.
|
|
1759
1759
|
* @example
|
|
1760
1760
|
* ```ts
|
|
1761
1761
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1794,7 +1794,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1794
1794
|
* // -1
|
|
1795
1795
|
* }
|
|
1796
1796
|
* ```
|
|
1797
|
-
* You can pass a
|
|
1797
|
+
* You can pass a {@link LazyPromise| `LazyPromise`} as default value.
|
|
1798
1798
|
* @example
|
|
1799
1799
|
* ```ts
|
|
1800
1800
|
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
@@ -1810,8 +1810,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1810
1810
|
*/
|
|
1811
1811
|
beforeOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | TExtended>;
|
|
1812
1812
|
/**
|
|
1813
|
-
* The
|
|
1814
|
-
* If the collection is empty or the
|
|
1813
|
+
* The `beforeOrFail` method returns the item that comes before the first item that matches `predicateFn`.
|
|
1814
|
+
* If the collection is empty or the `predicateFn` does not match or matches the first item then an error is thrown.
|
|
1815
1815
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1816
1816
|
* @example
|
|
1817
1817
|
* ```ts
|
|
@@ -1840,8 +1840,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1840
1840
|
*/
|
|
1841
1841
|
beforeOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput>;
|
|
1842
1842
|
/**
|
|
1843
|
-
* The
|
|
1844
|
-
* If the collection is empty or the
|
|
1843
|
+
* The `after` method returns the item that comes after the first item that matches `predicateFn`.
|
|
1844
|
+
* If the collection is empty or the `predicateFn` does not match or matches the last item then null is returned.
|
|
1845
1845
|
* @example
|
|
1846
1846
|
* ```ts
|
|
1847
1847
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1869,8 +1869,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1869
1869
|
*/
|
|
1870
1870
|
after(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | null>;
|
|
1871
1871
|
/**
|
|
1872
|
-
* The
|
|
1873
|
-
* If the collection is empty or the
|
|
1872
|
+
* The `afterOr` method returns the item that comes after the first item that matches `predicateFn`.
|
|
1873
|
+
* If the collection is empty or the `predicateFn` does not match or matches the last item then `defaultValue` is returned.
|
|
1874
1874
|
* @example
|
|
1875
1875
|
* ```ts
|
|
1876
1876
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -1909,7 +1909,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1909
1909
|
* // -1
|
|
1910
1910
|
* }
|
|
1911
1911
|
* ```
|
|
1912
|
-
* You can pass a
|
|
1912
|
+
* You can pass a {@link LazyPromise| `LazyPromise`} as default value.
|
|
1913
1913
|
* @example
|
|
1914
1914
|
* ```ts
|
|
1915
1915
|
* import type { IAsyncCollection, ICache } from "@daiso-tech/core";
|
|
@@ -1925,8 +1925,8 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1925
1925
|
*/
|
|
1926
1926
|
afterOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | TExtended>;
|
|
1927
1927
|
/**
|
|
1928
|
-
* The
|
|
1929
|
-
* If the collection is empty or the
|
|
1928
|
+
* The `afterOrFail` method returns the item that comes after the first item that matches `predicateFn`.
|
|
1929
|
+
* If the collection is empty or the `predicateFn` does not match or matches the last item then an error is thrown.
|
|
1930
1930
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1931
1931
|
* @example
|
|
1932
1932
|
* ```ts
|
|
@@ -1955,7 +1955,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1955
1955
|
*/
|
|
1956
1956
|
afterOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput>;
|
|
1957
1957
|
/**
|
|
1958
|
-
* The
|
|
1958
|
+
* The `sole` method returns the first item in the collection that passes `predicateFn`, but only if `predicateFn` matches exactly one item.
|
|
1959
1959
|
* If no items matches or multiple items are found an error will be thrown.
|
|
1960
1960
|
* @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
|
|
1961
1961
|
* @throws {MultipleItemsFoundCollectionError} {@link MultipleItemsFoundCollectionError}
|
|
@@ -1998,7 +1998,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
1998
1998
|
*/
|
|
1999
1999
|
sole<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
|
|
2000
2000
|
/**
|
|
2001
|
-
* The
|
|
2001
|
+
* The `nth` method creates a new collection consisting of every n-th item.
|
|
2002
2002
|
* @example
|
|
2003
2003
|
* ```ts
|
|
2004
2004
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -2014,7 +2014,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
2014
2014
|
*/
|
|
2015
2015
|
nth(step: number): IAsyncCollection<TInput>;
|
|
2016
2016
|
/**
|
|
2017
|
-
* The
|
|
2017
|
+
* The `count` method returns the total number of items in the collection that passes `predicateFn`.
|
|
2018
2018
|
* @example
|
|
2019
2019
|
* ```ts
|
|
2020
2020
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -2030,19 +2030,19 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
2030
2030
|
*/
|
|
2031
2031
|
count(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
2032
2032
|
/**
|
|
2033
|
-
* The
|
|
2033
|
+
* The `size` returns the size of the collection.
|
|
2034
2034
|
*/
|
|
2035
2035
|
size(): LazyPromise<number>;
|
|
2036
2036
|
/**
|
|
2037
|
-
* The
|
|
2037
|
+
* The `isEmpty` returns true if the collection is empty.
|
|
2038
2038
|
*/
|
|
2039
2039
|
isEmpty(): LazyPromise<boolean>;
|
|
2040
2040
|
/**
|
|
2041
|
-
* The
|
|
2041
|
+
* The `isNotEmpty` returns true if the collection is not empty.
|
|
2042
2042
|
*/
|
|
2043
2043
|
isNotEmpty(): LazyPromise<boolean>;
|
|
2044
2044
|
/**
|
|
2045
|
-
* The
|
|
2045
|
+
* The `searchFirst` return the index of the first item that matches `predicateFn`.
|
|
2046
2046
|
* @example
|
|
2047
2047
|
* ```ts
|
|
2048
2048
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -2058,7 +2058,7 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
2058
2058
|
*/
|
|
2059
2059
|
searchFirst(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
2060
2060
|
/**
|
|
2061
|
-
* The
|
|
2061
|
+
* The `searchLast` return the index of the last item that matches `predicateFn`.
|
|
2062
2062
|
* @example
|
|
2063
2063
|
* ```ts
|
|
2064
2064
|
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
@@ -2074,110 +2074,21 @@ export type IAsyncCollection<TInput = unknown> = AsyncIterable<TInput> & {
|
|
|
2074
2074
|
*/
|
|
2075
2075
|
searchLast(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
|
|
2076
2076
|
/**
|
|
2077
|
-
* The
|
|
2077
|
+
* The `forEach` method iterates through all items in the collection.
|
|
2078
2078
|
*/
|
|
2079
2079
|
forEach(callback: AsyncForEach<TInput, IAsyncCollection<TInput>>): LazyPromise<void>;
|
|
2080
2080
|
/**
|
|
2081
|
-
* The
|
|
2082
|
-
* This method is especially useful for situations where you may be interacting with external APIs that rate limit incoming requests:
|
|
2083
|
-
* @example
|
|
2084
|
-
* ```ts
|
|
2085
|
-
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
2086
|
-
*
|
|
2087
|
-
* // Asume the inputed collection is empty.
|
|
2088
|
-
* class MyIterable implements Iterable<number> {
|
|
2089
|
-
* async *[Symbol.asyncIterator]() {
|
|
2090
|
-
* for (let i = 0; i < 10; i++) {
|
|
2091
|
-
* yield i;
|
|
2092
|
-
* }
|
|
2093
|
-
* }
|
|
2094
|
-
* }
|
|
2095
|
-
*
|
|
2096
|
-
* // Asume the inputed collection is empty.
|
|
2097
|
-
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
2098
|
-
* const myIterable = new MyIterable();
|
|
2099
|
-
* await collection
|
|
2100
|
-
* .append(myIterable)
|
|
2101
|
-
* .delay(1000)
|
|
2102
|
-
* .forEach(user => console.log(user))
|
|
2103
|
-
* }
|
|
2104
|
-
* ```
|
|
2105
|
-
*/
|
|
2106
|
-
delay(time: TimeSpan): IAsyncCollection<TInput>;
|
|
2107
|
-
/**
|
|
2108
|
-
* @experimental
|
|
2109
|
-
* The <I>takeUntilAbort</i> method returns a new collection that will iterate values until aborted by passing in <i>{@link abortSignal | AbortSignal}</i>.
|
|
2110
|
-
* After when aborted, the collection will stop iterating:
|
|
2111
|
-
* @example
|
|
2112
|
-
* ```ts
|
|
2113
|
-
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
2114
|
-
*
|
|
2115
|
-
* class InfiniteIterable implements Iterable<number> {
|
|
2116
|
-
* async *[Symbol.asyncIterator]() {
|
|
2117
|
-
* let index = 0;
|
|
2118
|
-
* while(true) {
|
|
2119
|
-
* index++;
|
|
2120
|
-
* yield index;
|
|
2121
|
-
* }
|
|
2122
|
-
* }
|
|
2123
|
-
* }
|
|
2124
|
-
*
|
|
2125
|
-
* // Asume the inputed collection is empty.
|
|
2126
|
-
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
2127
|
-
* const abortController = new AbortController();
|
|
2128
|
-
* setTimeout(() => {
|
|
2129
|
-
* abortController.abort("My abort error");
|
|
2130
|
-
* }, 1000)
|
|
2131
|
-
* const infiniteIterable = new InfiniteIterable();
|
|
2132
|
-
* await collection
|
|
2133
|
-
* .append(infiniteIterable);
|
|
2134
|
-
* .takeUntilAbort(abortController)
|
|
2135
|
-
* .forEach(nbr => console.log(nbr))
|
|
2136
|
-
* }
|
|
2137
|
-
* ```
|
|
2138
|
-
*/
|
|
2139
|
-
takeUntilAbort(abortSignal: AbortSignal, shouldThrow?: boolean): IAsyncCollection<TInput>;
|
|
2140
|
-
/**
|
|
2141
|
-
* @experimental
|
|
2142
|
-
* The <I>takeUntilTimeout</i> method returns a new collection that will iterate values until the specified time.
|
|
2143
|
-
* After that time, the collection will stop iterating:
|
|
2144
|
-
* @example
|
|
2145
|
-
* ```ts
|
|
2146
|
-
* import type { IAsyncCollection } from "@daiso-tech/core";
|
|
2147
|
-
*
|
|
2148
|
-
* class InfiniteIterable implements AsyncIterable<number> {
|
|
2149
|
-
* async *[Symbol.asyncIterator]() {
|
|
2150
|
-
* let index = 0;
|
|
2151
|
-
* while(true) {
|
|
2152
|
-
* index++;
|
|
2153
|
-
* yield index;
|
|
2154
|
-
* }
|
|
2155
|
-
* }
|
|
2156
|
-
* }
|
|
2157
|
-
*
|
|
2158
|
-
* // Asume the inputed collection is empty.
|
|
2159
|
-
* async function main(collection: IAsyncCollection<number>): Promise<void> {
|
|
2160
|
-
* const infiniteIterable = new InfiniteIterable();
|
|
2161
|
-
* await collection
|
|
2162
|
-
* .append(infiniteIterable)
|
|
2163
|
-
* .takeUntilTimeout(1000)
|
|
2164
|
-
* .forEach(nbr => console.log(nbr))
|
|
2165
|
-
* }
|
|
2166
|
-
* ```
|
|
2167
|
-
*/
|
|
2168
|
-
takeUntilTimeout(time: TimeSpan, shouldThrow?: boolean): IAsyncCollection<TInput>;
|
|
2169
|
-
/**
|
|
2170
|
-
* The <i>toArray</i> method converts the collection to a new <i>{@link Array}</i>.
|
|
2081
|
+
* The `toArray` method converts the collection to a new {@link Array | `Array`}.
|
|
2171
2082
|
*/
|
|
2172
2083
|
toArray(): LazyPromise<TInput[]>;
|
|
2173
2084
|
/**
|
|
2174
|
-
* The
|
|
2085
|
+
* The `toRecord` method converts the collection to a new {@link Record | `Record`}.
|
|
2175
2086
|
* An error will be thrown if item is not a tuple of size 2 where the first element is a string or a number.
|
|
2176
2087
|
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
2177
2088
|
*/
|
|
2178
2089
|
toRecord(): LazyPromise<EnsureRecord<TInput>>;
|
|
2179
2090
|
/**
|
|
2180
|
-
* The
|
|
2091
|
+
* The `toMap` method converts the collection to a new {@link Map | `Map`}.
|
|
2181
2092
|
* An error will be thrown if item is not a tuple of size 2.
|
|
2182
2093
|
* @throws {TypeCollectionError} {@link TypeCollectionError}
|
|
2183
2094
|
*/
|