@daiso-tech/core 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_module.js +5 -1
- package/dist/cjs/_module.js.map +1 -1
- package/dist/cjs/_shared/kysely/_module.js +18 -0
- package/dist/cjs/_shared/kysely/_module.js.map +1 -0
- package/dist/cjs/_shared/kysely/kysely-table-name-transformer-plugin.js +45 -0
- package/dist/cjs/_shared/kysely/kysely-table-name-transformer-plugin.js.map +1 -0
- package/dist/cjs/_shared/redis/_module.js +20 -0
- package/dist/cjs/_shared/redis/_module.js.map +1 -0
- package/dist/cjs/_shared/redis/clear-iterable.js +25 -0
- package/dist/cjs/_shared/redis/clear-iterable.js.map +1 -0
- package/dist/cjs/_shared/redis/escape-redis-chars.js +41 -0
- package/dist/cjs/_shared/redis/escape-redis-chars.js.map +1 -0
- package/dist/cjs/_shared/redis/is-redis-type-error.js +9 -0
- package/dist/cjs/_shared/redis/is-redis-type-error.js.map +1 -0
- package/dist/cjs/_shared/utilities.js.map +1 -1
- package/dist/cjs/async/_module.js +29 -0
- package/dist/cjs/async/_module.js.map +1 -0
- package/dist/cjs/async/_shared.js +34 -0
- package/dist/cjs/async/_shared.js.map +1 -0
- package/dist/cjs/async/abortable/_module.js +18 -0
- package/dist/cjs/async/abortable/_module.js.map +1 -0
- package/dist/cjs/async/abortable/abortable.js +48 -0
- package/dist/cjs/async/abortable/abortable.js.map +1 -0
- package/dist/cjs/async/abortable-iterable/_module.js +18 -0
- package/dist/cjs/async/abortable-iterable/_module.js.map +1 -0
- package/dist/cjs/async/abortable-iterable/abortable-iterable.js +32 -0
- package/dist/cjs/async/abortable-iterable/abortable-iterable.js.map +1 -0
- package/dist/cjs/async/backof-policies/_module.js +21 -0
- package/dist/cjs/async/backof-policies/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/_shared.js +7 -0
- package/dist/cjs/async/backof-policies/_shared.js.map +1 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +19 -0
- package/dist/cjs/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +23 -0
- package/dist/cjs/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +23 -0
- package/dist/cjs/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/_module.js +18 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/_module.js.map +1 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +23 -0
- package/dist/cjs/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
- package/dist/cjs/async/delay/_module.js +18 -0
- package/dist/cjs/async/delay/_module.js.map +1 -0
- package/dist/cjs/async/delay/delay.js +24 -0
- package/dist/cjs/async/delay/delay.js.map +1 -0
- package/dist/cjs/async/delay-iterable/_module.js +18 -0
- package/dist/cjs/async/delay-iterable/_module.js.map +1 -0
- package/dist/cjs/async/delay-iterable/delay-iterable.js +36 -0
- package/dist/cjs/async/delay-iterable/delay-iterable.js.map +1 -0
- package/dist/cjs/async/lazy-promise/_module.js +18 -0
- package/dist/cjs/async/lazy-promise/_module.js.map +1 -0
- package/dist/cjs/async/lazy-promise/lazy-promise.js +22 -0
- package/dist/cjs/async/lazy-promise/lazy-promise.js.map +1 -0
- package/dist/cjs/async/retry/_module.js +18 -0
- package/dist/cjs/async/retry/_module.js.map +1 -0
- package/dist/cjs/async/retry/retry.js +43 -0
- package/dist/cjs/async/retry/retry.js.map +1 -0
- package/dist/cjs/async/retry-iterable/_module.js +18 -0
- package/dist/cjs/async/retry-iterable/_module.js.map +1 -0
- package/dist/cjs/async/retry-iterable/retry-iterable.js +32 -0
- package/dist/cjs/async/retry-iterable/retry-iterable.js.map +1 -0
- package/dist/cjs/async/timeout/_module.js +18 -0
- package/dist/cjs/async/timeout/_module.js.map +1 -0
- package/dist/cjs/async/timeout/timeout.js +28 -0
- package/dist/cjs/async/timeout/timeout.js.map +1 -0
- package/dist/cjs/async/timeout-iterable/_module.js +18 -0
- package/dist/cjs/async/timeout-iterable/_module.js.map +1 -0
- package/dist/cjs/async/timeout-iterable/timeout-iterable.js +11 -0
- package/dist/cjs/async/timeout-iterable/timeout-iterable.js.map +1 -0
- package/dist/cjs/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/cjs/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/cjs/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/cjs/contracts/_module.js +2 -0
- package/dist/cjs/contracts/_module.js.map +1 -1
- package/dist/cjs/contracts/collection/_module.js.map +1 -1
- package/dist/cjs/contracts/serializer/_module.js +18 -0
- package/dist/cjs/contracts/serializer/_module.js.map +1 -0
- package/dist/cjs/contracts/serializer/serializer.contract.js +25 -0
- package/dist/cjs/contracts/serializer/serializer.contract.js.map +1 -0
- package/dist/cjs/contracts/storage/_module.js +20 -0
- package/dist/cjs/contracts/storage/_module.js.map +1 -0
- package/dist/cjs/contracts/storage/_shared.js +32 -0
- package/dist/cjs/contracts/storage/_shared.js.map +1 -0
- package/dist/cjs/contracts/storage/storage-adapter.contract.js +3 -0
- package/dist/cjs/contracts/storage/storage-adapter.contract.js.map +1 -0
- package/dist/cjs/contracts/storage/storage.contract.js +3 -0
- package/dist/cjs/contracts/storage/storage.contract.js.map +1 -0
- package/dist/cjs/serializer/_module.js +22 -0
- package/dist/cjs/serializer/_module.js.map +1 -0
- package/dist/cjs/serializer/_shared/test-utilities/_module.js +18 -0
- package/dist/cjs/serializer/_shared/test-utilities/_module.js.map +1 -0
- package/dist/cjs/serializer/_shared/test-utilities/serializer.test-suite.js +361 -0
- package/dist/cjs/serializer/_shared/test-utilities/serializer.test-suite.js.map +1 -0
- package/dist/cjs/serializer/mongodb-serializer/_module.js +18 -0
- package/dist/cjs/serializer/mongodb-serializer/_module.js.map +1 -0
- package/dist/cjs/serializer/mongodb-serializer/mongodb-serializer.js +36 -0
- package/dist/cjs/serializer/mongodb-serializer/mongodb-serializer.js.map +1 -0
- package/dist/cjs/serializer/redis-serializer/_module.js +18 -0
- package/dist/cjs/serializer/redis-serializer/_module.js.map +1 -0
- package/dist/cjs/serializer/redis-serializer/redis-serializer.js +37 -0
- package/dist/cjs/serializer/redis-serializer/redis-serializer.js.map +1 -0
- package/dist/cjs/serializer/sql-serializer/_module.js +18 -0
- package/dist/cjs/serializer/sql-serializer/_module.js.map +1 -0
- package/dist/cjs/serializer/sql-serializer/sql-serializer.js +37 -0
- package/dist/cjs/serializer/sql-serializer/sql-serializer.js.map +1 -0
- package/dist/cjs/serializer/super-json-serializer/_module.js +18 -0
- package/dist/cjs/serializer/super-json-serializer/_module.js.map +1 -0
- package/dist/cjs/serializer/super-json-serializer/super-json-serializer.js +304 -0
- package/dist/cjs/serializer/super-json-serializer/super-json-serializer.js.map +1 -0
- package/dist/cjs/storage/_module.js +23 -0
- package/dist/cjs/storage/_module.js.map +1 -0
- package/dist/cjs/storage/_shared/test-utilities/_module.js +18 -0
- package/dist/cjs/storage/_shared/test-utilities/_module.js.map +1 -0
- package/dist/cjs/storage/_shared/test-utilities/storage-api.test-suite.js +572 -0
- package/dist/cjs/storage/_shared/test-utilities/storage-api.test-suite.js.map +1 -0
- package/dist/cjs/storage/_shared/test-utilities/storage-namespace.test-suite.js +241 -0
- package/dist/cjs/storage/_shared/test-utilities/storage-namespace.test-suite.js.map +1 -0
- package/dist/cjs/storage/_shared/test-utilities/storage-value.test-suite.js +4172 -0
- package/dist/cjs/storage/_shared/test-utilities/storage-value.test-suite.js.map +1 -0
- package/dist/cjs/storage/_shared/test-utilities/storage.test-suite.js +12 -0
- package/dist/cjs/storage/_shared/test-utilities/storage.test-suite.js.map +1 -0
- package/dist/cjs/storage/memory-storage-adapter/_module.js +18 -0
- package/dist/cjs/storage/memory-storage-adapter/_module.js.map +1 -0
- package/dist/cjs/storage/memory-storage-adapter/memory-storage-adapter.js +62 -0
- package/dist/cjs/storage/memory-storage-adapter/memory-storage-adapter.js.map +1 -0
- package/dist/cjs/storage/mongodb-storage-adapter/_module.js +6 -0
- package/dist/cjs/storage/mongodb-storage-adapter/_module.js.map +1 -0
- package/dist/cjs/storage/mongodb-storage-adapter/mongodb-storage-adapter.js +273 -0
- package/dist/cjs/storage/mongodb-storage-adapter/mongodb-storage-adapter.js.map +1 -0
- package/dist/cjs/storage/namespace-storage-adapter.js +66 -0
- package/dist/cjs/storage/namespace-storage-adapter.js.map +1 -0
- package/dist/cjs/storage/redis-storage-adapter/_module.js +18 -0
- package/dist/cjs/storage/redis-storage-adapter/_module.js.map +1 -0
- package/dist/cjs/storage/redis-storage-adapter/redis-storage-adapter.js +248 -0
- package/dist/cjs/storage/redis-storage-adapter/redis-storage-adapter.js.map +1 -0
- package/dist/cjs/storage/sqlite/_module.js +19 -0
- package/dist/cjs/storage/sqlite/_module.js.map +1 -0
- package/dist/cjs/storage/sqlite/_shared/_module.js +18 -0
- package/dist/cjs/storage/sqlite/_shared/_module.js.map +1 -0
- package/dist/cjs/storage/sqlite/_shared/base-sqlite-storage-adapter.js +224 -0
- package/dist/cjs/storage/sqlite/_shared/base-sqlite-storage-adapter.js.map +1 -0
- package/dist/cjs/storage/sqlite/libsql-storage-adapter/_module.js +18 -0
- package/dist/cjs/storage/sqlite/libsql-storage-adapter/_module.js.map +1 -0
- package/dist/cjs/storage/sqlite/libsql-storage-adapter/libsql-storage-adapter.js +53 -0
- package/dist/cjs/storage/sqlite/libsql-storage-adapter/libsql-storage-adapter.js.map +1 -0
- package/dist/cjs/storage/sqlite/sqlite-storage-adapter/_module.js +18 -0
- package/dist/cjs/storage/sqlite/sqlite-storage-adapter/_module.js.map +1 -0
- package/dist/cjs/storage/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js +52 -0
- package/dist/cjs/storage/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js.map +1 -0
- package/dist/cjs/storage/storage.js +301 -0
- package/dist/cjs/storage/storage.js.map +1 -0
- package/dist/cjs/storage/usable-storage-adapter.js +102 -0
- package/dist/cjs/storage/usable-storage-adapter.js.map +1 -0
- package/dist/cjs/utilities/_module.js +18 -0
- package/dist/cjs/utilities/_module.js.map +1 -0
- package/dist/cjs/utilities/time-span/_module.js +18 -0
- package/dist/cjs/utilities/time-span/_module.js.map +1 -0
- package/dist/cjs/utilities/time-span/time-span.js +103 -0
- package/dist/cjs/utilities/time-span/time-span.js.map +1 -0
- package/dist/esm/_module.js +5 -1
- package/dist/esm/_module.js.map +1 -1
- package/dist/esm/_shared/kysely/_module.js +2 -0
- package/dist/esm/_shared/kysely/_module.js.map +1 -0
- package/dist/esm/_shared/kysely/kysely-table-name-transformer-plugin.js +41 -0
- package/dist/esm/_shared/kysely/kysely-table-name-transformer-plugin.js.map +1 -0
- package/dist/esm/_shared/redis/_module.js +4 -0
- package/dist/esm/_shared/redis/_module.js.map +1 -0
- package/dist/esm/_shared/redis/clear-iterable.js +21 -0
- package/dist/esm/_shared/redis/clear-iterable.js.map +1 -0
- package/dist/esm/_shared/redis/escape-redis-chars.js +38 -0
- package/dist/esm/_shared/redis/escape-redis-chars.js.map +1 -0
- package/dist/esm/_shared/redis/is-redis-type-error.js +6 -0
- package/dist/esm/_shared/redis/is-redis-type-error.js.map +1 -0
- package/dist/esm/_shared/utilities.js.map +1 -1
- package/dist/esm/async/_module.js +11 -0
- package/dist/esm/async/_module.js.map +1 -0
- package/dist/esm/async/_shared.js +27 -0
- package/dist/esm/async/_shared.js.map +1 -0
- package/dist/esm/async/abortable/_module.js +2 -0
- package/dist/esm/async/abortable/_module.js.map +1 -0
- package/dist/esm/async/abortable/abortable.js +45 -0
- package/dist/esm/async/abortable/abortable.js.map +1 -0
- package/dist/esm/async/abortable-iterable/_module.js +2 -0
- package/dist/esm/async/abortable-iterable/_module.js.map +1 -0
- package/dist/esm/async/abortable-iterable/abortable-iterable.js +29 -0
- package/dist/esm/async/abortable-iterable/abortable-iterable.js.map +1 -0
- package/dist/esm/async/backof-policies/_module.js +5 -0
- package/dist/esm/async/backof-policies/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/_shared.js +4 -0
- package/dist/esm/async/backof-policies/_shared.js.map +1 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +16 -0
- package/dist/esm/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js.map +1 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +20 -0
- package/dist/esm/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js.map +1 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +20 -0
- package/dist/esm/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js.map +1 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/_module.js +2 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/_module.js.map +1 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +20 -0
- package/dist/esm/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js.map +1 -0
- package/dist/esm/async/delay/_module.js +2 -0
- package/dist/esm/async/delay/_module.js.map +1 -0
- package/dist/esm/async/delay/delay.js +21 -0
- package/dist/esm/async/delay/delay.js.map +1 -0
- package/dist/esm/async/delay-iterable/_module.js +2 -0
- package/dist/esm/async/delay-iterable/_module.js.map +1 -0
- package/dist/esm/async/delay-iterable/delay-iterable.js +33 -0
- package/dist/esm/async/delay-iterable/delay-iterable.js.map +1 -0
- package/dist/esm/async/lazy-promise/_module.js +2 -0
- package/dist/esm/async/lazy-promise/_module.js.map +1 -0
- package/dist/esm/async/lazy-promise/lazy-promise.js +17 -0
- package/dist/esm/async/lazy-promise/lazy-promise.js.map +1 -0
- package/dist/esm/async/retry/_module.js +2 -0
- package/dist/esm/async/retry/_module.js.map +1 -0
- package/dist/esm/async/retry/retry.js +40 -0
- package/dist/esm/async/retry/retry.js.map +1 -0
- package/dist/esm/async/retry-iterable/_module.js +2 -0
- package/dist/esm/async/retry-iterable/_module.js.map +1 -0
- package/dist/esm/async/retry-iterable/retry-iterable.js +29 -0
- package/dist/esm/async/retry-iterable/retry-iterable.js.map +1 -0
- package/dist/esm/async/timeout/_module.js +2 -0
- package/dist/esm/async/timeout/_module.js.map +1 -0
- package/dist/esm/async/timeout/timeout.js +25 -0
- package/dist/esm/async/timeout/timeout.js.map +1 -0
- package/dist/esm/async/timeout-iterable/_module.js +2 -0
- package/dist/esm/async/timeout-iterable/_module.js.map +1 -0
- package/dist/esm/async/timeout-iterable/timeout-iterable.js +8 -0
- package/dist/esm/async/timeout-iterable/timeout-iterable.js.map +1 -0
- package/dist/esm/collection/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
- package/dist/esm/collection/async-iterable-collection/async-iterable-collection.js.map +1 -1
- package/dist/esm/collection/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
- package/dist/esm/contracts/_module.js +2 -0
- package/dist/esm/contracts/_module.js.map +1 -1
- package/dist/esm/contracts/collection/_module.js.map +1 -1
- package/dist/esm/contracts/serializer/_module.js +2 -0
- package/dist/esm/contracts/serializer/_module.js.map +1 -0
- package/dist/esm/contracts/serializer/serializer.contract.js +19 -0
- package/dist/esm/contracts/serializer/serializer.contract.js.map +1 -0
- package/dist/esm/contracts/storage/_module.js +4 -0
- package/dist/esm/contracts/storage/_module.js.map +1 -0
- package/dist/esm/contracts/storage/_shared.js +25 -0
- package/dist/esm/contracts/storage/_shared.js.map +1 -0
- package/dist/esm/contracts/storage/storage-adapter.contract.js +1 -0
- package/dist/esm/contracts/storage/storage-adapter.contract.js.map +1 -0
- package/dist/esm/contracts/storage/storage.contract.js +1 -0
- package/dist/esm/contracts/storage/storage.contract.js.map +1 -0
- package/dist/esm/serializer/_module.js +6 -0
- package/dist/esm/serializer/_module.js.map +1 -0
- package/dist/esm/serializer/_shared/test-utilities/_module.js +2 -0
- package/dist/esm/serializer/_shared/test-utilities/_module.js.map +1 -0
- package/dist/esm/serializer/_shared/test-utilities/serializer.test-suite.js +358 -0
- package/dist/esm/serializer/_shared/test-utilities/serializer.test-suite.js.map +1 -0
- package/dist/esm/serializer/mongodb-serializer/_module.js +2 -0
- package/dist/esm/serializer/mongodb-serializer/_module.js.map +1 -0
- package/dist/esm/serializer/mongodb-serializer/mongodb-serializer.js +32 -0
- package/dist/esm/serializer/mongodb-serializer/mongodb-serializer.js.map +1 -0
- package/dist/esm/serializer/redis-serializer/_module.js +2 -0
- package/dist/esm/serializer/redis-serializer/_module.js.map +1 -0
- package/dist/esm/serializer/redis-serializer/redis-serializer.js +33 -0
- package/dist/esm/serializer/redis-serializer/redis-serializer.js.map +1 -0
- package/dist/esm/serializer/sql-serializer/_module.js +2 -0
- package/dist/esm/serializer/sql-serializer/_module.js.map +1 -0
- package/dist/esm/serializer/sql-serializer/sql-serializer.js +33 -0
- package/dist/esm/serializer/sql-serializer/sql-serializer.js.map +1 -0
- package/dist/esm/serializer/super-json-serializer/_module.js +2 -0
- package/dist/esm/serializer/super-json-serializer/_module.js.map +1 -0
- package/dist/esm/serializer/super-json-serializer/super-json-serializer.js +277 -0
- package/dist/esm/serializer/super-json-serializer/super-json-serializer.js.map +1 -0
- package/dist/esm/storage/_module.js +7 -0
- package/dist/esm/storage/_module.js.map +1 -0
- package/dist/esm/storage/_shared/test-utilities/_module.js +2 -0
- package/dist/esm/storage/_shared/test-utilities/_module.js.map +1 -0
- package/dist/esm/storage/_shared/test-utilities/storage-api.test-suite.js +569 -0
- package/dist/esm/storage/_shared/test-utilities/storage-api.test-suite.js.map +1 -0
- package/dist/esm/storage/_shared/test-utilities/storage-namespace.test-suite.js +238 -0
- package/dist/esm/storage/_shared/test-utilities/storage-namespace.test-suite.js.map +1 -0
- package/dist/esm/storage/_shared/test-utilities/storage-value.test-suite.js +4169 -0
- package/dist/esm/storage/_shared/test-utilities/storage-value.test-suite.js.map +1 -0
- package/dist/esm/storage/_shared/test-utilities/storage.test-suite.js +9 -0
- package/dist/esm/storage/_shared/test-utilities/storage.test-suite.js.map +1 -0
- package/dist/esm/storage/memory-storage-adapter/_module.js +2 -0
- package/dist/esm/storage/memory-storage-adapter/_module.js.map +1 -0
- package/dist/esm/storage/memory-storage-adapter/memory-storage-adapter.js +58 -0
- package/dist/esm/storage/memory-storage-adapter/memory-storage-adapter.js.map +1 -0
- package/dist/esm/storage/mongodb-storage-adapter/_module.js +2 -0
- package/dist/esm/storage/mongodb-storage-adapter/_module.js.map +1 -0
- package/dist/esm/storage/mongodb-storage-adapter/mongodb-storage-adapter.js +266 -0
- package/dist/esm/storage/mongodb-storage-adapter/mongodb-storage-adapter.js.map +1 -0
- package/dist/esm/storage/namespace-storage-adapter.js +62 -0
- package/dist/esm/storage/namespace-storage-adapter.js.map +1 -0
- package/dist/esm/storage/redis-storage-adapter/_module.js +2 -0
- package/dist/esm/storage/redis-storage-adapter/_module.js.map +1 -0
- package/dist/esm/storage/redis-storage-adapter/redis-storage-adapter.js +244 -0
- package/dist/esm/storage/redis-storage-adapter/redis-storage-adapter.js.map +1 -0
- package/dist/esm/storage/sqlite/_module.js +3 -0
- package/dist/esm/storage/sqlite/_module.js.map +1 -0
- package/dist/esm/storage/sqlite/_shared/_module.js +2 -0
- package/dist/esm/storage/sqlite/_shared/_module.js.map +1 -0
- package/dist/esm/storage/sqlite/_shared/base-sqlite-storage-adapter.js +220 -0
- package/dist/esm/storage/sqlite/_shared/base-sqlite-storage-adapter.js.map +1 -0
- package/dist/esm/storage/sqlite/libsql-storage-adapter/_module.js +2 -0
- package/dist/esm/storage/sqlite/libsql-storage-adapter/_module.js.map +1 -0
- package/dist/esm/storage/sqlite/libsql-storage-adapter/libsql-storage-adapter.js +49 -0
- package/dist/esm/storage/sqlite/libsql-storage-adapter/libsql-storage-adapter.js.map +1 -0
- package/dist/esm/storage/sqlite/sqlite-storage-adapter/_module.js +2 -0
- package/dist/esm/storage/sqlite/sqlite-storage-adapter/_module.js.map +1 -0
- package/dist/esm/storage/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js +48 -0
- package/dist/esm/storage/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.js.map +1 -0
- package/dist/esm/storage/storage.js +297 -0
- package/dist/esm/storage/storage.js.map +1 -0
- package/dist/esm/storage/usable-storage-adapter.js +98 -0
- package/dist/esm/storage/usable-storage-adapter.js.map +1 -0
- package/dist/esm/utilities/_module.js +2 -0
- package/dist/esm/utilities/_module.js.map +1 -0
- package/dist/esm/utilities/time-span/_module.js +2 -0
- package/dist/esm/utilities/time-span/_module.js.map +1 -0
- package/dist/esm/utilities/time-span/time-span.js +99 -0
- package/dist/esm/utilities/time-span/time-span.js.map +1 -0
- package/dist/types/_module.d.ts +5 -1
- package/dist/types/_shared/kysely/_module.d.ts +1 -0
- package/dist/types/_shared/kysely/kysely-table-name-transformer-plugin.d.ts +13 -0
- package/dist/types/_shared/redis/_module.d.ts +3 -0
- package/dist/types/_shared/redis/clear-iterable.d.ts +13 -0
- package/dist/types/_shared/redis/escape-redis-chars.d.ts +7 -0
- package/dist/types/_shared/redis/is-redis-type-error.d.ts +7 -0
- package/dist/types/_shared/types.d.ts +15 -2
- package/dist/types/_shared/utilities.d.ts +5 -1
- package/dist/types/async/_module.d.ts +10 -0
- package/dist/types/async/_shared.d.ts +35 -0
- package/dist/types/async/abortable/_module.d.ts +1 -0
- package/dist/types/async/abortable/abortable.d.ts +39 -0
- package/dist/types/async/abortable-iterable/_module.d.ts +1 -0
- package/dist/types/async/abortable-iterable/abortable-iterable.d.ts +36 -0
- package/dist/types/async/backof-policies/_module.d.ts +5 -0
- package/dist/types/async/backof-policies/_shared.d.ts +12 -0
- package/dist/types/async/backof-policies/constant-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +28 -0
- package/dist/types/async/backof-policies/exponential-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +36 -0
- package/dist/types/async/backof-policies/linear-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +32 -0
- package/dist/types/async/backof-policies/polynomial-backoff-policy/_module.d.ts +1 -0
- package/dist/types/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +36 -0
- package/dist/types/async/delay/_module.d.ts +1 -0
- package/dist/types/async/delay/delay.d.ts +38 -0
- package/dist/types/async/delay-iterable/_module.d.ts +1 -0
- package/dist/types/async/delay-iterable/delay-iterable.d.ts +57 -0
- package/dist/types/async/lazy-promise/_module.d.ts +1 -0
- package/dist/types/async/lazy-promise/lazy-promise.d.ts +28 -0
- package/dist/types/async/retry/_module.d.ts +1 -0
- package/dist/types/async/retry/retry.d.ts +86 -0
- package/dist/types/async/retry-iterable/_module.d.ts +1 -0
- package/dist/types/async/retry-iterable/retry-iterable.d.ts +86 -0
- package/dist/types/async/timeout/_module.d.ts +1 -0
- package/dist/types/async/timeout/timeout.d.ts +40 -0
- package/dist/types/async/timeout-iterable/_module.d.ts +1 -0
- package/dist/types/async/timeout-iterable/timeout-iterable.d.ts +64 -0
- package/dist/types/collection/_shared.d.ts +1 -1
- package/dist/types/collection/async-iterable-collection/_shared/async-cross-join-iterable.d.ts +2 -1
- package/dist/types/collection/async-iterable-collection/_shared/async-group-by-iterable.d.ts +1 -1
- package/dist/types/collection/async-iterable-collection/async-iterable-collection.d.ts +2 -2
- package/dist/types/collection/iterable-collection/_shared/cross-join-iterable.d.ts +1 -1
- package/dist/types/collection/iterable-collection/_shared/group-by-iterable.d.ts +1 -1
- package/dist/types/collection/iterable-collection/iterable-collection.d.ts +1 -1
- package/dist/types/collection/list-collection/list-collection.d.ts +1 -1
- package/dist/types/contracts/_module.d.ts +2 -0
- package/dist/types/contracts/collection/_module.d.ts +0 -3
- package/dist/types/contracts/collection/_shared.d.ts +1 -1
- package/dist/types/contracts/collection/async-collection.contract.d.ts +3 -3
- package/dist/types/contracts/collection/collection.contract.d.ts +3 -3
- package/dist/types/contracts/serializer/_module.d.ts +1 -0
- package/dist/types/contracts/serializer/serializer.contract.d.ts +37 -0
- package/dist/types/contracts/storage/_module.d.ts +3 -0
- package/dist/types/contracts/storage/_shared.d.ts +27 -0
- package/dist/types/contracts/storage/storage-adapter.contract.d.ts +72 -0
- package/dist/types/contracts/storage/storage.contract.d.ts +148 -0
- package/dist/types/serializer/_module.d.ts +5 -0
- package/dist/types/serializer/_shared/test-utilities/_module.d.ts +1 -0
- package/dist/types/serializer/_shared/test-utilities/serializer.test-suite.d.ts +18 -0
- package/dist/types/serializer/mongodb-serializer/_module.d.ts +1 -0
- package/dist/types/serializer/mongodb-serializer/mongodb-serializer.d.ts +13 -0
- package/dist/types/serializer/redis-serializer/_module.d.ts +1 -0
- package/dist/types/serializer/redis-serializer/redis-serializer.d.ts +13 -0
- package/dist/types/serializer/sql-serializer/_module.d.ts +1 -0
- package/dist/types/serializer/sql-serializer/sql-serializer.d.ts +13 -0
- package/dist/types/serializer/super-json-serializer/_module.d.ts +1 -0
- package/dist/types/serializer/super-json-serializer/super-json-serializer.d.ts +37 -0
- package/dist/types/storage/_module.d.ts +6 -0
- package/dist/types/storage/_shared/test-utilities/_module.d.ts +1 -0
- package/dist/types/storage/_shared/test-utilities/storage-api.test-suite.d.ts +20 -0
- package/dist/types/storage/_shared/test-utilities/storage-namespace.test-suite.d.ts +20 -0
- package/dist/types/storage/_shared/test-utilities/storage-value.test-suite.d.ts +20 -0
- package/dist/types/storage/_shared/test-utilities/storage.test-suite.d.ts +20 -0
- package/dist/types/storage/memory-storage-adapter/_module.d.ts +1 -0
- package/dist/types/storage/memory-storage-adapter/memory-storage-adapter.d.ts +16 -0
- package/dist/types/storage/mongodb-storage-adapter/_module.d.ts +1 -0
- package/dist/types/storage/mongodb-storage-adapter/mongodb-storage-adapter.d.ts +46 -0
- package/dist/types/storage/namespace-storage-adapter.d.ts +30 -0
- package/dist/types/storage/redis-storage-adapter/_module.d.ts +1 -0
- package/dist/types/storage/redis-storage-adapter/redis-storage-adapter.d.ts +41 -0
- package/dist/types/storage/sqlite/_module.d.ts +2 -0
- package/dist/types/storage/sqlite/_shared/_module.d.ts +1 -0
- package/dist/types/storage/sqlite/_shared/base-sqlite-storage-adapter.d.ts +42 -0
- package/dist/types/storage/sqlite/libsql-storage-adapter/_module.d.ts +1 -0
- package/dist/types/storage/sqlite/libsql-storage-adapter/libsql-storage-adapter.d.ts +30 -0
- package/dist/types/storage/sqlite/sqlite-storage-adapter/_module.d.ts +1 -0
- package/dist/types/storage/sqlite/sqlite-storage-adapter/sqlite-storage-adapter.d.ts +30 -0
- package/dist/types/storage/storage.d.ts +38 -0
- package/dist/types/storage/usable-storage-adapter.d.ts +22 -0
- package/dist/types/utilities/_module.d.ts +1 -0
- package/dist/types/utilities/time-span/_module.d.ts +1 -0
- package/dist/types/utilities/time-span/time-span.d.ts +50 -0
- package/package.json +41 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
import type { TimeSpan } from "../../utilities/_module";
|
|
5
|
+
import { LazyPromise } from "../../async/lazy-promise/_module";
|
|
6
|
+
/**
|
|
7
|
+
* The <i>delay</i> function creates a promise that will be fulfilled after given <i>time</i> and can be aborted by providing <i>abortSignal</i>.
|
|
8
|
+
* @group Promise utilities
|
|
9
|
+
* @throws {AsyncError} {@link AsyncError}
|
|
10
|
+
* @throws {AbortAsyncError} {@link AbortAsyncError}
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { delay, TimeSpan } from "@daiso-tech/core";
|
|
14
|
+
* (async () => {
|
|
15
|
+
* console.log("a");
|
|
16
|
+
* await delay(TimeSpan.fromSeconds(2));
|
|
17
|
+
* console.log("b");
|
|
18
|
+
* })();
|
|
19
|
+
* ```
|
|
20
|
+
* @example with abortSignal
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { delay, TimeSpan } from "@daiso-tech/core";
|
|
23
|
+
*
|
|
24
|
+
* const abortController = new AbortController();
|
|
25
|
+
* setTimeout(() => {
|
|
26
|
+
* abortController.abort("My abort error");
|
|
27
|
+
* }, TimeSpan.fromSeconds(1).toMilliseconds());
|
|
28
|
+
* const promise = delay(TimeSpan.fromSeconds(2), abortController.signal);
|
|
29
|
+
*
|
|
30
|
+
* (async () => {
|
|
31
|
+
* console.log("a");
|
|
32
|
+
* // Will throw AbortAsyncError
|
|
33
|
+
* await promise;
|
|
34
|
+
* console.log("b");
|
|
35
|
+
* })();
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function delay(time: TimeSpan, abortSignal?: AbortSignal): LazyPromise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../async/delay-iterable/delay-iterable";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
import type { TimeSpan } from "../../utilities/_module";
|
|
5
|
+
/**
|
|
6
|
+
* The <i>delayIterable</i> function adds delay to each iteration of <i>{@link AsyncIterable}</i> and the delay can be aborted by providing <i>abortSignal</i>.
|
|
7
|
+
* @group AsyncIterable utilities
|
|
8
|
+
* @throws {AsyncError} {@link AsyncError}
|
|
9
|
+
* @throws {AbortAsyncError} {@link AbortAsyncError}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { delayIterable, TimeSpan } from "@daiso-tech/core";
|
|
13
|
+
*
|
|
14
|
+
* const iterable: AsyncIterable<void> = {
|
|
15
|
+
* async *[Symbol.asyncIterator]() {
|
|
16
|
+
* yield 1;
|
|
17
|
+
* yield 2;
|
|
18
|
+
* yield 3;
|
|
19
|
+
* yield 4;
|
|
20
|
+
* yield 5;
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* (async () => {
|
|
25
|
+
* for await (const item of delayIterable(iterable, TimeSpan.fromSeconds(1))) {
|
|
26
|
+
* console.log(item);
|
|
27
|
+
* }
|
|
28
|
+
* })();
|
|
29
|
+
* ```
|
|
30
|
+
* @example with abortSignal
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { delayIterable, TimeSpan } from "@daiso-tech/core";
|
|
33
|
+
*
|
|
34
|
+
* const abortController = new AbortController();
|
|
35
|
+
* setTimeout(() => {
|
|
36
|
+
* abortController.abort("My abort error");
|
|
37
|
+
* }, TimeSpan.fromSeconds(3).toMilliseconds());
|
|
38
|
+
*
|
|
39
|
+
* const iterable: AsyncIterable<void> = {
|
|
40
|
+
* async *[Symbol.asyncIterator]() {
|
|
41
|
+
* yield 1;
|
|
42
|
+
* yield 2;
|
|
43
|
+
* yield 3;
|
|
44
|
+
* yield 4;
|
|
45
|
+
* yield 5;
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* (async () => {
|
|
50
|
+
* // Will throw AbortAsyncError
|
|
51
|
+
* for await (const item of delayIterable(iterable, TimeSpan.fromSeconds(1), abortController.signal)) {
|
|
52
|
+
* console.log(item);
|
|
53
|
+
* }
|
|
54
|
+
* })();
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function delayIterable<TValue>(iterable: AsyncIterable<TValue>, time: TimeSpan, abortSignal?: AbortSignal): AsyncIterable<TValue>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../async/lazy-promise/lazy-promise";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The <i>LazyPromise</i> class is used for creating lazy <i>{@link PromiseLike}<i> object that will only execute when awaited or when then method is called.
|
|
6
|
+
* @group Promise utilities
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* (async () => {
|
|
10
|
+
* const promise = new LazyPromise(async () => {
|
|
11
|
+
* console.log("I am lazy");
|
|
12
|
+
* });
|
|
13
|
+
* // "I am lazy" will only logged when awaited or then method i called.
|
|
14
|
+
* await promise;
|
|
15
|
+
* })();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class LazyPromise<TValue> implements PromiseLike<TValue> {
|
|
19
|
+
private readonly asyncFn;
|
|
20
|
+
private promise;
|
|
21
|
+
constructor(asyncFn: () => PromiseLike<TValue>);
|
|
22
|
+
then<TResult1 = TValue, TResult2 = never>(onfulfilled?: ((value: TValue) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The <i>deferLazyPromise</i> function will execute <i>{@link LazyPromise}</i> without awaiting it.
|
|
26
|
+
* @group Promise utilities
|
|
27
|
+
*/
|
|
28
|
+
export declare function deferLazyPromise<TValue>(promise: LazyPromise<TValue>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../async/retry/retry";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
import type { BackoffPolicy } from "../../async/backof-policies/_module";
|
|
5
|
+
import { LazyPromise } from "../../async/lazy-promise/_module";
|
|
6
|
+
import { TimeSpan } from "../../utilities/_module";
|
|
7
|
+
export type RetryPolicy = (error: unknown) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @group Promise utilities
|
|
10
|
+
*/
|
|
11
|
+
export type RetrySettings = {
|
|
12
|
+
/**
|
|
13
|
+
* @default {4}
|
|
14
|
+
*/
|
|
15
|
+
maxAttempts?: number;
|
|
16
|
+
backoffPolicy?: BackoffPolicy;
|
|
17
|
+
retryPolicy?: RetryPolicy;
|
|
18
|
+
/**
|
|
19
|
+
* @default 60_000 milliseconds
|
|
20
|
+
*/
|
|
21
|
+
retryTimeout?: TimeSpan;
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The <i>retry</i> function will retry a async function if it throws an error until given <i>settings.maxAttempts</i>.
|
|
26
|
+
* You can add timeout for each retry by passing <i>settings.retryTimeout</i> and <i>settings.abortSignal</i> for aborting it on your own.
|
|
27
|
+
* You can also customize the retry policy by passing <i>settings.retryPolicy</i> and custom backof policy by passing <i>settings.backoffPolicy</i>.
|
|
28
|
+
* @group Promise utilities
|
|
29
|
+
* @throws {AsyncError} {@link AsyncError}
|
|
30
|
+
* @throws {AbortAsyncError} {@link AbortAsyncError}
|
|
31
|
+
* @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
|
|
32
|
+
* @throws {RetryAsyncError} {@link RetryAsyncError}
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { retry, TimeSpan, exponentialBackoffPolicy } from "@daiso-tech/core";
|
|
36
|
+
*
|
|
37
|
+
* (async () => {
|
|
38
|
+
* // Will throw RetryAsyncError after failing 4:th attempt
|
|
39
|
+
* await retry(async () => {
|
|
40
|
+
* throw new Error("My error mesasge");
|
|
41
|
+
* }, {
|
|
42
|
+
* // You can choose the max retry attempts
|
|
43
|
+
* maxAttempts: 4,
|
|
44
|
+
* // You can provide a custom backoff policy
|
|
45
|
+
* backoffPolicy: exponentialBackoffPolicy(),
|
|
46
|
+
* // You can choose what error to retry, this function will retry all errors thrown
|
|
47
|
+
* retryPolicy: () => true,
|
|
48
|
+
* // You can provide a timeout for each retry
|
|
49
|
+
* retryTimeout: TimeSpan.fromMilliseconds(60_000),
|
|
50
|
+
* });
|
|
51
|
+
* })();
|
|
52
|
+
* ```
|
|
53
|
+
* @example with abortSignal
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { retry, TimeSpan } from "@daiso-tech/core";
|
|
56
|
+
*
|
|
57
|
+
* (async () => {
|
|
58
|
+
* const abortController = new AbortController();
|
|
59
|
+
* abortController.abort("My abort message");
|
|
60
|
+
*
|
|
61
|
+
* // Will be aborted by throwing AbortAsyncError
|
|
62
|
+
* await retry(async () => {
|
|
63
|
+
* throw new Error("My error message");
|
|
64
|
+
* }, {
|
|
65
|
+
* abortSignal: abortController.signal
|
|
66
|
+
* });
|
|
67
|
+
* })();
|
|
68
|
+
* ```
|
|
69
|
+
* @example with custom retry policy
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { retry, TimeSpan } from "@daiso-tech/core";
|
|
72
|
+
*
|
|
73
|
+
* class ErrorA extends Error {};
|
|
74
|
+
* class ErrorB extends Error {};
|
|
75
|
+
*
|
|
76
|
+
* (async () => {
|
|
77
|
+
* // Will not retry and ErrorB will be thrown
|
|
78
|
+
* await retry(async () => {
|
|
79
|
+
* throw new ErrorB("My error message");
|
|
80
|
+
* }, {
|
|
81
|
+
* retryPolicy: error => error instanceof ErrorA
|
|
82
|
+
* });
|
|
83
|
+
* })();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function retry<TValue = void>(asyncFn: () => PromiseLike<TValue>, settings?: RetrySettings): LazyPromise<TValue>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../async/retry-iterable/retry-iterable";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { RetrySettings } from "../../async/retry/_module";
|
|
2
|
+
/**
|
|
3
|
+
* The <i>retryIterable</i> function will retry each iteration of {@link AsyncIterable} if it throws an error until given <i>settings.maxAttempts</i>.
|
|
4
|
+
* You can add timeout for each retry by passing <i>settings.retryTimeout</i> and <i>settings.abortSignal</i> for aborting it on your own.
|
|
5
|
+
* You can also customize the retry policy by passing <i>settings.retryPolicy</i> and custom backof policy by passing <i>settings.backoffPolicy</i>.
|
|
6
|
+
* @group AsyncIterable utilities
|
|
7
|
+
* @throws {AsyncError} {@link AsyncError}
|
|
8
|
+
* @throws {AbortAsyncError} {@link AbortAsyncError}
|
|
9
|
+
* @throws {RetryAsyncError} {@link RetryAsyncError}
|
|
10
|
+
* @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { retryIterable, TimeSpan, exponentialBackoffPolicy } from "@daiso-tech/core";
|
|
14
|
+
*
|
|
15
|
+
* const iterable: AsyncIterable<void> = {
|
|
16
|
+
* async *[Symbol.asyncIterator]() {
|
|
17
|
+
* yield 1;
|
|
18
|
+
* throw new Error("My error mesasge");
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* (async () => {
|
|
23
|
+
* // Will throw RetryAsyncError after failing 4:th attempt
|
|
24
|
+
* for await (const item of retryIterable(iterable, {
|
|
25
|
+
* // You can choose the max retry attempts
|
|
26
|
+
* maxAttempts: 4,
|
|
27
|
+
* // You can provide a custom backoff policy
|
|
28
|
+
* backoffPolicy: exponentialBackoffPolicy(),
|
|
29
|
+
* // You can choose what error to retry, this function will retry all errors thrown
|
|
30
|
+
* retryPolicy: () => true,
|
|
31
|
+
* // You can provide a timeout for each retry
|
|
32
|
+
* retryTimeout: TimeSpan.fromMilliseconds(60_000),
|
|
33
|
+
* })) {
|
|
34
|
+
* console.log(item)
|
|
35
|
+
* }
|
|
36
|
+
* })();
|
|
37
|
+
* ```
|
|
38
|
+
* @example with abortSignal
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { retryIterable, TimeSpan } from "@daiso-tech/core";
|
|
41
|
+
*
|
|
42
|
+
* const iterable: AsyncIterable<void> = {
|
|
43
|
+
* async *[Symbol.asyncIterator]() {
|
|
44
|
+
* yield 1;
|
|
45
|
+
* throw new Error("My error mesasge");
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* (async () => {
|
|
50
|
+
* const abortController = new AbortController();
|
|
51
|
+
* abortController.abort("My abort message");
|
|
52
|
+
*
|
|
53
|
+
* // Will be aborted by throwing AbortAsyncError
|
|
54
|
+
* for await (const item of retry(iterable, {
|
|
55
|
+
* abortSignal: abortController.signal
|
|
56
|
+
* })) {
|
|
57
|
+
* console.log(item)
|
|
58
|
+
* }
|
|
59
|
+
* })();
|
|
60
|
+
* ```
|
|
61
|
+
* @example with abortSignal
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { retryIterable, TimeSpan } from "@daiso-tech/core";
|
|
64
|
+
*
|
|
65
|
+
* class ErrorA extends Error {};
|
|
66
|
+
* class ErrorB extends Error {};
|
|
67
|
+
*
|
|
68
|
+
* const iterable: AsyncIterable<void> = {
|
|
69
|
+
* async *[Symbol.asyncIterator]() {
|
|
70
|
+
* yield 1;
|
|
71
|
+
* throw new ErrorB("My error mesasge");
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
*
|
|
76
|
+
* (async () => {
|
|
77
|
+
* // Will not retry and ErrorB will be thrown
|
|
78
|
+
* for await (const item of retry(iterable, {
|
|
79
|
+
* retryPolicy: error => error instanceof ErrorA
|
|
80
|
+
* })) {
|
|
81
|
+
* console.log(item)
|
|
82
|
+
* }
|
|
83
|
+
* })();
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function retryIterable<TValue>(iterable: AsyncIterable<TValue>, settings?: RetrySettings): AsyncIterable<TValue>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../async/timeout/timeout";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
import { LazyPromise } from "../../async/lazy-promise/_module";
|
|
5
|
+
import type { TimeSpan } from "../../utilities/_module";
|
|
6
|
+
/**
|
|
7
|
+
* The <i>timeout</i> function makes a <i>{@link PromiseLike}</i> object abort after a given <i>time</i> and you can also abort it on your own by passing <i>abortSignal</i>.
|
|
8
|
+
* @group Promise utilities
|
|
9
|
+
* @throws {AsyncError} {@link AsyncError}
|
|
10
|
+
* @throws {AbortAsyncError} {@link AbortAsyncError}
|
|
11
|
+
* @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { timeout, delay, TimeSpan } from "@daiso-tech/core";
|
|
15
|
+
*
|
|
16
|
+
* (async () => {
|
|
17
|
+
* // Will throw an AbortAsyncError
|
|
18
|
+
* await timeout(async () => {
|
|
19
|
+
* await delay(TimeSpan.fromSeconds(10));
|
|
20
|
+
* }, TimeSpan.fromSeconds(5));
|
|
21
|
+
* })();
|
|
22
|
+
* ```
|
|
23
|
+
* @example with abortSignal
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { timeout, delay, TimeSpan } from "@daiso-tech/core";
|
|
26
|
+
*
|
|
27
|
+
* const abortController = new AbortController();
|
|
28
|
+
* setTimeout(() => {
|
|
29
|
+
* abortController.abort("My abort error");
|
|
30
|
+
* }, TimeSpan.fromSeconds(1));
|
|
31
|
+
*
|
|
32
|
+
* (async () => {
|
|
33
|
+
* // Will abort after 1 second by throwing AbortAsyncError
|
|
34
|
+
* await timeout(async () => {
|
|
35
|
+
* await delay(TimeSpan.fromSeconds(10));
|
|
36
|
+
* }, TimeSpan.fromSeconds(5), abortController.signal);
|
|
37
|
+
* })();
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function timeout<TValue>(asyncFn: () => PromiseLike<TValue>, time: TimeSpan, abortSignal?: AbortSignal): LazyPromise<TValue>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../async/timeout-iterable/timeout-iterable";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Async
|
|
3
|
+
*/
|
|
4
|
+
import type { TimeSpan } from "../../utilities/_module";
|
|
5
|
+
/**
|
|
6
|
+
* The <i>timeoutIterable</i> function makes a <i>{@link AsyncIterable}</i> abort after a given <i>time</i> and you can also abort it on your own by passing <i>abortSignal</i>.
|
|
7
|
+
* @group AsyncIterable utilities
|
|
8
|
+
* @throws {AsyncError} {@link AsyncError}
|
|
9
|
+
* @throws {AbortAsyncError} {@link AbortAsyncError}
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { timeoutIterable, delayIterable, TimeSpan } from "@daiso-tech/core";
|
|
13
|
+
*
|
|
14
|
+
* const iterable: AsyncIterable<void> = delayIterable({
|
|
15
|
+
* async *[Symbol.asyncIterator]() {
|
|
16
|
+
* yield 1;
|
|
17
|
+
* yield 2;
|
|
18
|
+
* yield 3;
|
|
19
|
+
* yield 4;
|
|
20
|
+
* yield 5;
|
|
21
|
+
* yield 6;
|
|
22
|
+
* yield 7;
|
|
23
|
+
* yield 8;
|
|
24
|
+
* }
|
|
25
|
+
* }, TimeSpan.fromSeconds(1));
|
|
26
|
+
*
|
|
27
|
+
* (async () => {
|
|
28
|
+
* // Will throw an AbortAsyncError
|
|
29
|
+
* for (const item of timeoutIterable(iterable, TimeSpan.fromSeconds(5))) {
|
|
30
|
+
* console.log(item);
|
|
31
|
+
* }
|
|
32
|
+
* })();
|
|
33
|
+
* ```
|
|
34
|
+
* @example with abortSignal
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { timeoutIterable, delay, TimeSpan } from "@daiso-tech/core";
|
|
37
|
+
*
|
|
38
|
+
* const iterable: AsyncIterable<void> = delayIterable({
|
|
39
|
+
* async *[Symbol.asyncIterator]() {
|
|
40
|
+
* yield 1;
|
|
41
|
+
* yield 2;
|
|
42
|
+
* yield 3;
|
|
43
|
+
* yield 4;
|
|
44
|
+
* yield 5;
|
|
45
|
+
* yield 6;
|
|
46
|
+
* yield 7;
|
|
47
|
+
* yield 8;
|
|
48
|
+
* }
|
|
49
|
+
* }, TimeSpan.fromSeconds(1));
|
|
50
|
+
*
|
|
51
|
+
* const abortController = new AbortController();
|
|
52
|
+
* setTimeout(() => {
|
|
53
|
+
* abortController.abort("My abort message");
|
|
54
|
+
* }, TimeSpan.fromSeconds(3));
|
|
55
|
+
*
|
|
56
|
+
* (async () => {
|
|
57
|
+
* // Will abort after 3 second by throwing AbortAsyncError
|
|
58
|
+
* for (const item of timeoutIterable(iterable, TimeSpan.fromSeconds(5), abortController.signal)) {
|
|
59
|
+
* console.log(item);
|
|
60
|
+
* }
|
|
61
|
+
* })();
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function timeoutIterable<TValue>(iterable: AsyncIterable<TValue>, time: TimeSpan, abortSignal?: AbortSignal): AsyncIterable<TValue>;
|
package/dist/types/collection/async-iterable-collection/_shared/async-cross-join-iterable.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CrossJoinResult
|
|
1
|
+
import type { CrossJoinResult } from "../../../contracts/collection/_module";
|
|
2
|
+
import { type IAsyncCollection } from "../../../contracts/collection/_module";
|
|
2
3
|
import { type AsyncIterableValue } from "../../../_shared/types";
|
|
3
4
|
/**
|
|
4
5
|
* @internal
|
package/dist/types/collection/async-iterable-collection/_shared/async-group-by-iterable.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare class AsyncGroupByIterable<TInput, TOutput = TInput> implements A
|
|
|
7
7
|
private collection;
|
|
8
8
|
private selectFn;
|
|
9
9
|
private makeCollection;
|
|
10
|
-
constructor(collection: IAsyncCollection<TInput>, selectFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput
|
|
10
|
+
constructor(collection: IAsyncCollection<TInput>, selectFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput> | undefined, makeCollection: <TInput>(iterable: AsyncIterableValue<TInput>) => IAsyncCollection<TInput>);
|
|
11
11
|
[Symbol.asyncIterator](): AsyncIterator<RecordItem<TOutput, IAsyncCollection<TInput>>>;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Collection
|
|
3
3
|
*/
|
|
4
4
|
import { type AsyncCollapse, type AsyncPredicate, type AsyncForEach, type AsyncMap, type AsyncModifier, type AsyncTap, type AsyncTransform, type Comparator, type IAsyncCollection, type ChangendItem, type AsyncReduce, type CrossJoinResult } from "../../contracts/collection/_module";
|
|
5
5
|
import { type AsyncIterableValue, type AsyncLazyable, type EnsureType } from "../../_shared/types";
|
|
@@ -72,7 +72,7 @@ export declare class AsyncIterableCollection<TInput> implements IAsyncCollection
|
|
|
72
72
|
insertAfter<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
|
|
73
73
|
crossJoin<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<CrossJoinResult<TInput, TExtended>>;
|
|
74
74
|
zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<RecordItem<TInput, TExtended>>;
|
|
75
|
-
sort(comparator?: Comparator<TInput>
|
|
75
|
+
sort(comparator?: Comparator<TInput>): IAsyncCollection<TInput>;
|
|
76
76
|
reverse(chunkSize?: number): IAsyncCollection<TInput>;
|
|
77
77
|
shuffle(mathRandom?: () => number): IAsyncCollection<TInput>;
|
|
78
78
|
first<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): Promise<TOutput | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CrossJoinResult, ICollection } from "../../../contracts/collection/_module";
|
|
1
|
+
import type { CrossJoinResult, ICollection } from "../../../contracts/collection/_module";
|
|
2
2
|
export declare class CrossJoinIterable<TInput, TExtended = TInput> implements Iterable<CrossJoinResult<TInput, TExtended>> {
|
|
3
3
|
private collection;
|
|
4
4
|
private iterable;
|
|
@@ -7,6 +7,6 @@ export declare class GroupByIterable<TInput, TOutput = TInput> implements Iterab
|
|
|
7
7
|
private collection;
|
|
8
8
|
private selectFn;
|
|
9
9
|
private makeCollection;
|
|
10
|
-
constructor(collection: ICollection<TInput>, selectFn: Map<TInput, ICollection<TInput>, TOutput
|
|
10
|
+
constructor(collection: ICollection<TInput>, selectFn: Map<TInput, ICollection<TInput>, TOutput> | undefined, makeCollection: <TInput>(iterable: Iterable<TInput>) => ICollection<TInput>);
|
|
11
11
|
[Symbol.iterator](): Iterator<RecordItem<TOutput, ICollection<TInput>>>;
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Collection
|
|
3
3
|
*/
|
|
4
4
|
import { type Collapse, type Comparator, type Predicate, type ForEach, type ICollection, type Map, type Modifier, type Tap, type Transform, type ChangendItem, type Reduce, type CrossJoinResult } from "../../contracts/collection/_module";
|
|
5
5
|
import { type Lazyable, type EnsureType } from "../../_shared/types";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Collection
|
|
3
3
|
*/
|
|
4
4
|
import { type Collapse, type Comparator, type Predicate, type ICollection, type Map, type Modifier, type Tap, type Transform, type ChangendItem, type Reduce, type ForEach, type CrossJoinResult } from "../../contracts/collection/_module";
|
|
5
5
|
import { type EnsureType, type Lazyable } from "../../_shared/types";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Collection
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import type { AsyncReduce, CrossJoinResult, AsyncPredicate, AsyncForEach, AsyncMap, AsyncModifier, AsyncTap, AsyncTransform, Comparator, ChangendItem } from "../../contracts/collection/_shared";
|
|
5
|
+
import type { RecordItem, AsyncLazyable, EnsureType, AsyncIterableValue } from "../../_shared/types";
|
|
6
6
|
export type AsyncCollapse<TValue> = TValue extends Array<infer TItem> | Iterable<infer TItem> | IAsyncCollection<infer TItem> ? TItem : TValue;
|
|
7
7
|
/**
|
|
8
8
|
* <i>IAsyncCollection</i> is immutable. The <i>throwOnIndexOverflow</i> parameter in the <i>IAsyncCollection</i> methods is used for preventing the index to overflow by throwing an error.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @module
|
|
2
|
+
* @module Collection
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import type { Comparator, Predicate, ForEach, Map, Modifier, Tap, Transform, ChangendItem, Reduce, CrossJoinResult } from "../../contracts/collection/_shared";
|
|
5
|
+
import type { Lazyable, RecordItem, EnsureType } from "../../_shared/types";
|
|
6
6
|
export type Collapse<TValue> = TValue extends Array<infer TItem> | Iterable<infer TItem> | ICollection<infer TItem> ? TItem : TValue;
|
|
7
7
|
/**
|
|
8
8
|
* <i>ICollection</i> is immutable.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../contracts/serializer/serializer.contract";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Serializer
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @group Errors
|
|
6
|
+
*/
|
|
7
|
+
export declare class SerializerError extends Error {
|
|
8
|
+
constructor(message: string, cause?: unknown);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @group Errors
|
|
12
|
+
*/
|
|
13
|
+
export declare class SerializationError extends SerializerError {
|
|
14
|
+
constructor(message: string, cause?: unknown);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @group Errors
|
|
18
|
+
*/
|
|
19
|
+
export declare class DeserializationError extends SerializerError {
|
|
20
|
+
constructor(message: string, cause?: unknown);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @group Contracts
|
|
24
|
+
* @throws {SerializerError} {@link SerializerError}
|
|
25
|
+
* @throws {SerializationError} {@link SerializationError}
|
|
26
|
+
* @throws {DeserializationError} {@link DeserializationError}
|
|
27
|
+
*/
|
|
28
|
+
export type ISerializer<TSerialized = unknown> = {
|
|
29
|
+
/**
|
|
30
|
+
* @throws {SerializationError} {@link SerializationError}
|
|
31
|
+
*/
|
|
32
|
+
serialize<TValue>(value: TValue): Promise<TSerialized>;
|
|
33
|
+
/**
|
|
34
|
+
* @throws {DeserializationError} {@link DeserializationError}
|
|
35
|
+
*/
|
|
36
|
+
deserialize<TValue>(value: TSerialized): Promise<TValue>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Storage
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @group Errors
|
|
6
|
+
*/
|
|
7
|
+
export declare class StorageError extends Error {
|
|
8
|
+
constructor(message: string, cause?: unknown);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @group Errors
|
|
12
|
+
*/
|
|
13
|
+
export declare class UnexpectedStorageError extends StorageError {
|
|
14
|
+
constructor(message: string, cause?: unknown);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @group Errors
|
|
18
|
+
*/
|
|
19
|
+
export declare class TypeStorageError extends StorageError {
|
|
20
|
+
constructor(message: string, cause?: unknown);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @group Errors
|
|
24
|
+
*/
|
|
25
|
+
export declare class KeyNotFoundStorageError extends StorageError {
|
|
26
|
+
constructor(message: string, cause?: unknown);
|
|
27
|
+
}
|