@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
package/README.md
CHANGED
|
@@ -1,51 +1,72 @@
|
|
|
1
1
|
# @daiso-tech/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@daiso-tech/core)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
[](https://nodejs.org/api/esm.html)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
A modular, framework-agnostic library providing essential components for modern web applications. Stop reinventing the wheel - focus on building your application while the library handles the core functionalities.
|
|
11
|
+
|
|
12
|
+
## ✨ Features
|
|
13
|
+
|
|
14
|
+
### Current Features
|
|
15
|
+
|
|
16
|
+
- **Immutable Collections**:
|
|
17
|
+
|
|
18
|
+
- `IterableCollection` - Simplifies work with `Iterable`
|
|
19
|
+
- `ListCollection` - Simplifies work with `Array`
|
|
20
|
+
- `AsyncIterableCollection` - Simplifies work with `AsyncIterable`
|
|
21
|
+
|
|
22
|
+
- **Middleware System**
|
|
23
|
+
- Agnostic middlewares applicable to any async/sync functions.
|
|
24
|
+
- `fallback`: Automatic recovery with default values on errors
|
|
25
|
+
- `observe`: Monitor function execution and performance
|
|
26
|
+
- `retry`: Smart retries with multiple backoff policies:
|
|
27
|
+
- `constantBackoffPolicy`
|
|
28
|
+
- `exponentialBackoffPolicy`
|
|
29
|
+
- `linearBackoffPolicy`
|
|
30
|
+
- `polynomialBackoffPolicy`
|
|
31
|
+
- `sequentialHedging`: Runs fallbacks sequentially if the primary function fails, ensuring graceful failure handling.
|
|
32
|
+
- `concurrentHedging`: Executes the primary function alongside fallbacks concurrently, returning the first successful result and aborting all remaining operations.
|
|
33
|
+
- `timeout`: Guaranteed execution time limits
|
|
34
|
+
- **LazyPromise**:
|
|
35
|
+
- Executes only when awaited
|
|
36
|
+
- With middleware support
|
|
37
|
+
- **Pluggable Components**:
|
|
38
|
+
- `Cache` with adapter support
|
|
39
|
+
- `Lock` with adapter support
|
|
40
|
+
- `EventBus` with adapter support
|
|
41
|
+
- `Serde` (serializer, deserializer) adapters
|
|
42
|
+
|
|
43
|
+
### Planned Features
|
|
44
|
+
|
|
45
|
+
- Query bus
|
|
46
|
+
- Command bus
|
|
47
|
+
- Semaphore component
|
|
48
|
+
- SharedLock (ReaderWriterLock)
|
|
49
|
+
- RateLimiter
|
|
50
|
+
- CircuitBreaker
|
|
51
|
+
- MessageQueue
|
|
52
|
+
- TaskScheduler
|
|
53
|
+
- Notification system
|
|
54
|
+
- Abstract file system
|
|
55
|
+
|
|
56
|
+
## 🚀 Installation
|
|
57
|
+
|
|
4
58
|
```bash
|
|
5
59
|
npm install @daiso-tech/core
|
|
6
60
|
```
|
|
7
61
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- Easily retrying when it fails
|
|
20
|
-
- Cache component with support for pluggable adapters.
|
|
21
|
-
- Lock component with supports for pluggable adapters.
|
|
22
|
-
- EventBus component with support for pluggable adapters.
|
|
23
|
-
|
|
24
|
-
### In the future the following components will be added:
|
|
25
|
-
- Command bus
|
|
26
|
-
- Semaphore component
|
|
27
|
-
- SharedLock (ReaderWriterLock) component
|
|
28
|
-
- RateLimter component
|
|
29
|
-
- CircuitBreaker component
|
|
30
|
-
- MessageQueue component
|
|
31
|
-
- TaskScheduler component
|
|
32
|
-
- Notification component
|
|
33
|
-
- Abstract file system component
|
|
34
|
-
|
|
35
|
-
#### NOTE !!: This library only supports ESM (ecmascript) module.
|
|
36
|
-
|
|
37
|
-
#### NOTE !!: This library is under construction and breaking changes can occur.
|
|
38
|
-
|
|
39
|
-
### Inspiration
|
|
40
|
-
This library is inspired by [Laravel](https://laravel.com/docs/11.x/readme) and built with a modular design, so you can use only the parts you need.
|
|
41
|
-
|
|
42
|
-
It also integrates ideas from other libraries:
|
|
43
|
-
- [Symfony components](https://symfony.com/components), PHP
|
|
44
|
-
- [Verrou](https://verrou.dev/docs/introduction), TypeScript
|
|
45
|
-
- [Distributed lock](https://github.com/ZiggyCreatures/FusionCache), C#
|
|
46
|
-
- [Bento cache](https://bentocache.dev/docs/introduction), TypeScript
|
|
47
|
-
- [Fusion cache](https://github.com/ZiggyCreatures/FusionCache), C#
|
|
48
|
-
- [Polly](https://www.pollydocs.org/), C#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### Visit the [docs](https://yousif-khalil-abdulkarim.github.io/daiso-core/) for more information!
|
|
62
|
+
## Inspired By
|
|
63
|
+
|
|
64
|
+
Built with ideas from:
|
|
65
|
+
|
|
66
|
+
- [Laravel](https://laravel.com/docs/11.x/readme), PHP
|
|
67
|
+
- [Symfony components](https://symfony.com/components), PHP
|
|
68
|
+
- [Verrou](https://verrou.dev/docs/introduction), TypeScript
|
|
69
|
+
- [Distributed lock](https://github.com/ZiggyCreatures/FusionCache), C#
|
|
70
|
+
- [Bento cache](https://bentocache.dev/docs/introduction), TypeScript
|
|
71
|
+
- [Fusion cache](https://github.com/ZiggyCreatures/FusionCache), C#
|
|
72
|
+
- [Polly](https://www.pollydocs.org/), C#
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "../async/backof-policies/_module.js";
|
|
2
|
+
export * from "../async/middlewares/_module.js";
|
|
2
3
|
export * from "../async/utilities/_module.js";
|
|
3
4
|
export * from "../async/async.errors.js";
|
|
4
|
-
export * from "../async/async.events.js";
|
|
5
5
|
//# sourceMappingURL=_module-exports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_module-exports.js","sourceRoot":"","sources":["../../src/async/_module-exports.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,
|
|
1
|
+
{"version":3,"file":"_module-exports.js","sourceRoot":"","sources":["../../src/async/_module-exports.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC"}
|
|
@@ -3,25 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
|
-
* IMPORT_PATH:
|
|
6
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
7
7
|
* @group Errors
|
|
8
8
|
*/
|
|
9
9
|
export declare class AsyncError extends Error {
|
|
10
10
|
constructor(message: string, cause?: unknown);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* This error is thrown when the <i>LazyPromise</i> is aborted.
|
|
14
13
|
*
|
|
15
|
-
* IMPORT_PATH:
|
|
16
|
-
* @group Errors
|
|
17
|
-
*/
|
|
18
|
-
export declare class AbortAsyncError extends AsyncError {
|
|
19
|
-
constructor(message: string, cause?: unknown);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* This error is thrown when the <i>LazyPromise</i> has exceeded the given time limit.
|
|
23
|
-
*
|
|
24
|
-
* IMPORT_PATH: ```"@daiso-tech/core/async"```
|
|
14
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
25
15
|
* @group Errors
|
|
26
16
|
*/
|
|
27
17
|
export declare class TimeoutAsyncError extends AsyncError {
|
|
@@ -29,31 +19,49 @@ export declare class TimeoutAsyncError extends AsyncError {
|
|
|
29
19
|
}
|
|
30
20
|
/**
|
|
31
21
|
*
|
|
32
|
-
* IMPORT_PATH:
|
|
22
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
33
23
|
* @group Errors
|
|
34
24
|
*/
|
|
35
25
|
export type RetryAsyncErrorData = {
|
|
36
|
-
|
|
26
|
+
errors: unknown[];
|
|
37
27
|
maxAttempts: number;
|
|
38
28
|
};
|
|
39
29
|
/**
|
|
40
|
-
* This error is thrown when the <i>LazyPromise</i> has failed all retry attempts.
|
|
41
30
|
*
|
|
42
|
-
* IMPORT_PATH:
|
|
31
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
43
32
|
* @group Errors
|
|
44
33
|
*/
|
|
45
34
|
export declare class RetryAsyncError extends AsyncError {
|
|
46
35
|
readonly maxAttempts: number;
|
|
47
|
-
|
|
36
|
+
readonly errors: unknown[];
|
|
37
|
+
constructor(message: string, { errors, maxAttempts }: RetryAsyncErrorData);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
42
|
+
* @group Errors
|
|
43
|
+
*/
|
|
44
|
+
export declare class HedgingAsyncError extends AsyncError {
|
|
45
|
+
readonly errors: unknown[];
|
|
46
|
+
constructor(message: string, errors: unknown[]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
51
|
+
* @group Errors
|
|
52
|
+
*/
|
|
53
|
+
export declare class CapacityFullAsyncError extends AsyncError {
|
|
54
|
+
constructor(message: string, cause?: unknown);
|
|
48
55
|
}
|
|
49
56
|
/**
|
|
50
57
|
*
|
|
51
|
-
* IMPORT_PATH:
|
|
58
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
52
59
|
* @group Errors
|
|
53
60
|
*/
|
|
54
61
|
export declare const ASYNC_ERRORS: {
|
|
55
62
|
readonly Base: typeof AsyncError;
|
|
56
|
-
readonly Abort: typeof AbortAsyncError;
|
|
57
63
|
readonly Timeout: typeof TimeoutAsyncError;
|
|
58
64
|
readonly Retry: typeof RetryAsyncError;
|
|
65
|
+
readonly Hedging: typeof HedgingAsyncError;
|
|
66
|
+
readonly CapacityFull: typeof CapacityFullAsyncError;
|
|
59
67
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
|
-
* IMPORT_PATH:
|
|
6
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
7
7
|
* @group Errors
|
|
8
8
|
*/
|
|
9
9
|
export class AsyncError extends Error {
|
|
@@ -13,52 +13,65 @@ export class AsyncError extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* This error is thrown when the <i>LazyPromise</i> is aborted.
|
|
17
16
|
*
|
|
18
|
-
* IMPORT_PATH:
|
|
17
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
19
18
|
* @group Errors
|
|
20
19
|
*/
|
|
21
|
-
export class
|
|
20
|
+
export class TimeoutAsyncError extends AsyncError {
|
|
22
21
|
constructor(message, cause) {
|
|
23
22
|
super(message, cause);
|
|
24
|
-
this.name =
|
|
23
|
+
this.name = TimeoutAsyncError.name;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
|
-
* This error is thrown when the <i>LazyPromise</i> has exceeded the given time limit.
|
|
29
27
|
*
|
|
30
|
-
* IMPORT_PATH:
|
|
28
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
31
29
|
* @group Errors
|
|
32
30
|
*/
|
|
33
|
-
export class
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
export class RetryAsyncError extends AsyncError {
|
|
32
|
+
maxAttempts;
|
|
33
|
+
errors = [];
|
|
34
|
+
constructor(message, { errors, maxAttempts }) {
|
|
35
|
+
super(message, errors);
|
|
36
|
+
this.errors = errors;
|
|
37
|
+
this.maxAttempts = maxAttempts;
|
|
38
|
+
this.name = RetryAsyncError.name;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
|
-
* This error is thrown when the <i>LazyPromise</i> has failed all retry attempts.
|
|
41
42
|
*
|
|
42
|
-
* IMPORT_PATH:
|
|
43
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
43
44
|
* @group Errors
|
|
44
45
|
*/
|
|
45
|
-
export class
|
|
46
|
-
|
|
47
|
-
constructor(message,
|
|
46
|
+
export class HedgingAsyncError extends AsyncError {
|
|
47
|
+
errors;
|
|
48
|
+
constructor(message, errors) {
|
|
49
|
+
super(message, errors);
|
|
50
|
+
this.errors = errors;
|
|
51
|
+
this.name = HedgingAsyncError.name;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
57
|
+
* @group Errors
|
|
58
|
+
*/
|
|
59
|
+
export class CapacityFullAsyncError extends AsyncError {
|
|
60
|
+
constructor(message, cause) {
|
|
48
61
|
super(message, cause);
|
|
49
|
-
this.name =
|
|
50
|
-
this.maxAttempts = maxAttempts;
|
|
62
|
+
this.name = CapacityFullAsyncError.name;
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
65
|
/**
|
|
54
66
|
*
|
|
55
|
-
* IMPORT_PATH:
|
|
67
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
56
68
|
* @group Errors
|
|
57
69
|
*/
|
|
58
70
|
export const ASYNC_ERRORS = {
|
|
59
71
|
Base: AsyncError,
|
|
60
|
-
Abort: AbortAsyncError,
|
|
61
72
|
Timeout: TimeoutAsyncError,
|
|
62
73
|
Retry: RetryAsyncError,
|
|
74
|
+
Hedging: HedgingAsyncError,
|
|
75
|
+
CapacityFull: CapacityFullAsyncError,
|
|
63
76
|
};
|
|
64
77
|
//# sourceMappingURL=async.errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.errors.js","sourceRoot":"","sources":["../../src/async/async.errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACjC,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAChC,CAAC;CACJ;AAED
|
|
1
|
+
{"version":3,"file":"async.errors.js","sourceRoot":"","sources":["../../src/async/async.errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACjC,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAChC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAC7C,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC;IACvC,CAAC;CACJ;AAYD;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC3B,WAAW,CAAS;IAEpB,MAAM,GAAc,EAAE,CAAC;IAEvC,YAAY,OAAe,EAAE,EAAE,MAAM,EAAE,WAAW,EAAuB;QACrE,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;IACrC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAGzB;IAFpB,YACI,OAAe,EACC,MAAiB;QAEjC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAFP,WAAM,GAAN,MAAM,CAAW;QAGjC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC;IACvC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,OAAO,sBAAuB,SAAQ,UAAU;IAClD,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC;IAC5C,CAAC;CACJ;AACD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,iBAAiB;IAC1B,KAAK,EAAE,eAAe;IACtB,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,sBAAsB;CAC9B,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Async
|
|
3
3
|
*/
|
|
4
|
+
import type { Invokable } from "../../utilities/_module-exports.js";
|
|
4
5
|
/**
|
|
5
6
|
* @returns Amount milliseconds to wait
|
|
6
7
|
*
|
|
7
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
8
9
|
* @group BackoffPolicies
|
|
9
10
|
*/
|
|
10
|
-
export type BackoffPolicy =
|
|
11
|
+
export type BackoffPolicy = Invokable<[
|
|
12
|
+
attempt: number,
|
|
13
|
+
error: unknown
|
|
14
|
+
], number>;
|
|
11
15
|
/**
|
|
12
16
|
* @internal
|
|
13
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../../src/async/backof-policies/_shared.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../../src/async/backof-policies/_shared.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,+CAA+C;AAE/C;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,MAAc,EACd,KAAa,EACb,UAAwB;IAExB,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC;AAC/C,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { TimeSpan } from "../../../utilities/_module-exports.js";
|
|
|
5
5
|
import { type BackoffPolicy } from "../../../async/backof-policies/_shared.js";
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
9
9
|
* @group BackoffPolicies
|
|
10
10
|
*/
|
|
11
11
|
export type ConstantBackoffPolicySettings = {
|
|
@@ -26,7 +26,7 @@ export type ConstantBackoffPolicySettings = {
|
|
|
26
26
|
/**
|
|
27
27
|
* Constant backoff policy with jitter
|
|
28
28
|
*
|
|
29
|
-
* IMPORT_PATH:
|
|
29
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
30
30
|
* @group BackoffPolicies
|
|
31
31
|
*/
|
|
32
32
|
export declare function constantBackoffPolicy(settings?: ConstantBackoffPolicySettings | ((error: unknown) => ConstantBackoffPolicySettings)): BackoffPolicy;
|
|
@@ -6,7 +6,7 @@ import { withJitter, } from "../../../async/backof-policies/_shared.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Constant backoff policy with jitter
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
10
10
|
* @group BackoffPolicies
|
|
11
11
|
*/
|
|
12
12
|
export function constantBackoffPolicy(settings = {}) {
|
package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { TimeSpan } from "../../../utilities/_module-exports.js";
|
|
|
5
5
|
import type { BackoffPolicy } from "../../../async/backof-policies/_shared.js";
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
9
9
|
* @group BackoffPolicies
|
|
10
10
|
*/
|
|
11
11
|
export type ExponentialBackoffPolicySettings = {
|
|
@@ -34,7 +34,7 @@ export type ExponentialBackoffPolicySettings = {
|
|
|
34
34
|
/**
|
|
35
35
|
* Exponential backoff policy with jitter
|
|
36
36
|
*
|
|
37
|
-
* IMPORT_PATH:
|
|
37
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
38
38
|
* @group BackoffPolicies
|
|
39
39
|
*/
|
|
40
40
|
export declare function exponentialBackoffPolicy(settings?: ExponentialBackoffPolicySettings | ((error: unknown) => ExponentialBackoffPolicySettings)): BackoffPolicy;
|
|
@@ -6,7 +6,7 @@ import { withJitter } from "../../../async/backof-policies/_shared.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Exponential backoff policy with jitter
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
10
10
|
* @group BackoffPolicies
|
|
11
11
|
*/
|
|
12
12
|
export function exponentialBackoffPolicy(settings = {}) {
|
|
@@ -5,7 +5,7 @@ import { TimeSpan } from "../../../utilities/_module-exports.js";
|
|
|
5
5
|
import type { BackoffPolicy } from "../../../async/backof-policies/_shared.js";
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
9
9
|
* @group BackoffPolicies
|
|
10
10
|
*/
|
|
11
11
|
export type LinearBackoffPolicySettings = {
|
|
@@ -30,7 +30,7 @@ export type LinearBackoffPolicySettings = {
|
|
|
30
30
|
/**
|
|
31
31
|
* Linear backoff policy with jitter
|
|
32
32
|
*
|
|
33
|
-
* IMPORT_PATH:
|
|
33
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
34
34
|
* @group BackoffPolicies
|
|
35
35
|
*/
|
|
36
36
|
export declare function linearBackoffPolicy(settings?: LinearBackoffPolicySettings | ((error: unknown) => LinearBackoffPolicySettings)): BackoffPolicy;
|
|
@@ -6,7 +6,7 @@ import { withJitter } from "../../../async/backof-policies/_shared.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Linear backoff policy with jitter
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
10
10
|
* @group BackoffPolicies
|
|
11
11
|
*/
|
|
12
12
|
export function linearBackoffPolicy(settings = {}) {
|
|
@@ -5,7 +5,7 @@ import { TimeSpan } from "../../../utilities/_module-exports.js";
|
|
|
5
5
|
import type { BackoffPolicy } from "../../../async/backof-policies/_shared.js";
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
|
-
* IMPORT_PATH:
|
|
8
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
9
9
|
* @group BackoffPolicies
|
|
10
10
|
*/
|
|
11
11
|
export type PolynomialBackoffPolicySettings = {
|
|
@@ -34,7 +34,7 @@ export type PolynomialBackoffPolicySettings = {
|
|
|
34
34
|
/**
|
|
35
35
|
* Polynomial backoff policy with jitter
|
|
36
36
|
*
|
|
37
|
-
* IMPORT_PATH:
|
|
37
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
38
38
|
* @group BackoffPolicies
|
|
39
39
|
*/
|
|
40
40
|
export declare function polynomialBackoffPolicy(settings?: PolynomialBackoffPolicySettings | ((error: unknown) => PolynomialBackoffPolicySettings)): BackoffPolicy;
|
|
@@ -6,7 +6,7 @@ import { withJitter } from "../../../async/backof-policies/_shared.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Polynomial backoff policy with jitter
|
|
8
8
|
*
|
|
9
|
-
* IMPORT_PATH:
|
|
9
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
10
10
|
* @group BackoffPolicies
|
|
11
11
|
*/
|
|
12
12
|
export function polynomialBackoffPolicy(settings = {}) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "../../async/middlewares/bulkhead/_module.js";
|
|
2
|
+
export * from "../../async/middlewares/dynamic/_module.js";
|
|
3
|
+
export * from "../../async/middlewares/fallback/_module.js";
|
|
4
|
+
export * from "../../async/middlewares/hedging/_module.js";
|
|
5
|
+
export * from "../../async/middlewares/observe/_module.js";
|
|
6
|
+
export * from "../../async/middlewares/retry/_module.js";
|
|
7
|
+
export * from "../../async/middlewares/timeout/_module.js";
|
|
8
|
+
export * from "../../async/middlewares/_shared.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "../../async/middlewares/bulkhead/_module.js";
|
|
2
|
+
export * from "../../async/middlewares/dynamic/_module.js";
|
|
3
|
+
export * from "../../async/middlewares/fallback/_module.js";
|
|
4
|
+
export * from "../../async/middlewares/hedging/_module.js";
|
|
5
|
+
export * from "../../async/middlewares/observe/_module.js";
|
|
6
|
+
export * from "../../async/middlewares/retry/_module.js";
|
|
7
|
+
export * from "../../async/middlewares/timeout/_module.js";
|
|
8
|
+
export * from "../../async/middlewares/_shared.js";
|
|
9
|
+
//# sourceMappingURL=_module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../src/async/middlewares/_module.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../../src/async/middlewares/_shared.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAkB,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../async/middlewares/bulkhead/bulkhead.middleware.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../src/async/middlewares/bulkhead/_module.ts"],"names":[],"mappings":"AAAA,cAAc,qDAAqD,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
import { TimeSpan, type AsyncMiddlewareFn, type HookContext, type Invokable } from "../../../utilities/_module-exports.js";
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
8
|
+
* @group Middleware
|
|
9
|
+
*/
|
|
10
|
+
export type OnProcessingData<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
|
|
11
|
+
args: TParameters;
|
|
12
|
+
context: TContext;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
17
|
+
* @group Middleware
|
|
18
|
+
*/
|
|
19
|
+
export type OnProcessing<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = Invokable<[data: OnProcessingData<TParameters, TContext>]>;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
23
|
+
* @group Middleware
|
|
24
|
+
*/
|
|
25
|
+
export type BulkheadCallbacks<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = {
|
|
26
|
+
onProcessing?: OnProcessing<TParameters, TContext>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
31
|
+
* @group Middleware
|
|
32
|
+
*/
|
|
33
|
+
export type BulkheadSettings<TParameters extends unknown[] = unknown[], TContext extends HookContext = HookContext> = BulkheadCallbacks<TParameters, TContext> & {
|
|
34
|
+
/**
|
|
35
|
+
* The maximum number of promises allowed to run concurrently. If this limit is exceeded, additional promises will be queued until a slot becomes available.
|
|
36
|
+
*
|
|
37
|
+
* @default {25}
|
|
38
|
+
*/
|
|
39
|
+
maxConcurrency?: number;
|
|
40
|
+
/**
|
|
41
|
+
* The maximum capacity of the promise queue. If null, the queue can grow indefinitely.
|
|
42
|
+
* If a number is provided and the queue exceeds this limit, an error will be thrown, and no further promises will be enqueued.
|
|
43
|
+
*
|
|
44
|
+
* @default {null}
|
|
45
|
+
*/
|
|
46
|
+
maxCapacity?: number | null;
|
|
47
|
+
/**
|
|
48
|
+
* @default
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { TimeSpan } from "@daiso-tech/core/utilities";
|
|
51
|
+
*
|
|
52
|
+
* TimeSpan.fromMilliseconds(0)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
interval?: TimeSpan;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The `bulkhead` middlewares ensures that a given amount of {@link Promiselike | `PromiseLike`} objects run at the same time concurrently and the rest will be queued up.
|
|
59
|
+
* You can provide {@link BulkheadSettings | `settings.maxCapacity`}
|
|
60
|
+
*
|
|
61
|
+
* IMPORT_PATH: `"@daiso-tech/core/async"`
|
|
62
|
+
* @group Middleware
|
|
63
|
+
* @throws {CapacityFullAsyncError} {@link CapacityFullAsyncError}
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { bulkhead } from "@daiso-tech/core/async";
|
|
66
|
+
* import { AsyncHooks } from "@daiso-tech/core/utilities";
|
|
67
|
+
*
|
|
68
|
+
* const fetchData = new AsyncHooks(async (url: string): Promise<unknown> => {
|
|
69
|
+
* const response = await fetch(url);
|
|
70
|
+
* const json = await response.json();
|
|
71
|
+
* return json;
|
|
72
|
+
* }, [
|
|
73
|
+
* bulkhead()
|
|
74
|
+
* ]);
|
|
75
|
+
*
|
|
76
|
+
* // Will run only 25 promises concurrently by default.
|
|
77
|
+
* await Promise.all(Array(50).fill("").map(() => fetchData.invoke("URL")));
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function bulkhead<TParameters extends unknown[], TReturn, TContext extends HookContext>(settings?: BulkheadSettings<TParameters, TContext>): AsyncMiddlewareFn<TParameters, TReturn, TContext>;
|