@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.
Files changed (365) hide show
  1. package/README.md +66 -45
  2. package/dist/async/_module-exports.d.ts +1 -1
  3. package/dist/async/_module-exports.js +1 -1
  4. package/dist/async/_module-exports.js.map +1 -1
  5. package/dist/async/async.errors.d.ts +27 -19
  6. package/dist/async/async.errors.js +33 -20
  7. package/dist/async/async.errors.js.map +1 -1
  8. package/dist/async/backof-policies/_shared.d.ts +6 -2
  9. package/dist/async/backof-policies/_shared.js +1 -0
  10. package/dist/async/backof-policies/_shared.js.map +1 -1
  11. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.d.ts +2 -2
  12. package/dist/async/backof-policies/constant-backoff-policy/constant-backoff-policy.js +1 -1
  13. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.d.ts +2 -2
  14. package/dist/async/backof-policies/exponential-backoff-policy/exponential-backoff-policy.js +1 -1
  15. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.d.ts +2 -2
  16. package/dist/async/backof-policies/linear-backoff-policy/linear-backoff-policy.js +1 -1
  17. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.d.ts +2 -2
  18. package/dist/async/backof-policies/polynomial-backoff-policy/polynomial-backoff-policy.js +1 -1
  19. package/dist/async/middlewares/_module.d.ts +8 -0
  20. package/dist/async/middlewares/_module.js +9 -0
  21. package/dist/async/middlewares/_module.js.map +1 -0
  22. package/dist/async/middlewares/_shared.d.ts +10 -0
  23. package/dist/async/middlewares/_shared.js +5 -0
  24. package/dist/async/middlewares/_shared.js.map +1 -0
  25. package/dist/async/middlewares/bulkhead/_module.d.ts +1 -0
  26. package/dist/async/middlewares/bulkhead/_module.js +2 -0
  27. package/dist/async/middlewares/bulkhead/_module.js.map +1 -0
  28. package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +80 -0
  29. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +46 -0
  30. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +1 -0
  31. package/dist/async/middlewares/dynamic/_module.d.ts +1 -0
  32. package/dist/async/middlewares/dynamic/_module.js +2 -0
  33. package/dist/async/middlewares/dynamic/_module.js.map +1 -0
  34. package/dist/async/middlewares/dynamic/dynamic.middleware.d.ts +34 -0
  35. package/dist/async/middlewares/dynamic/dynamic.middleware.js +36 -0
  36. package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +1 -0
  37. package/dist/async/middlewares/fallback/_module.d.ts +1 -0
  38. package/dist/async/middlewares/fallback/_module.js +2 -0
  39. package/dist/async/middlewares/fallback/_module.js.map +1 -0
  40. package/dist/async/middlewares/fallback/fallback.middleware.d.ts +78 -0
  41. package/dist/async/middlewares/fallback/fallback.middleware.js +52 -0
  42. package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -0
  43. package/dist/async/middlewares/hedging/_module.d.ts +2 -0
  44. package/dist/async/middlewares/hedging/_module.js +3 -0
  45. package/dist/async/middlewares/hedging/_module.js.map +1 -0
  46. package/dist/async/middlewares/hedging/_shared.d.ts +93 -0
  47. package/dist/async/middlewares/hedging/_shared.js +5 -0
  48. package/dist/async/middlewares/hedging/_shared.js.map +1 -0
  49. package/dist/async/middlewares/hedging/concurrent-hedging/_module.d.ts +1 -0
  50. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js +2 -0
  51. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js.map +1 -0
  52. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.d.ts +51 -0
  53. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +138 -0
  54. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +1 -0
  55. package/dist/async/middlewares/hedging/sequential-hedging/_module.d.ts +1 -0
  56. package/dist/async/middlewares/hedging/sequential-hedging/_module.js +2 -0
  57. package/dist/async/middlewares/hedging/sequential-hedging/_module.js.map +1 -0
  58. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.d.ts +51 -0
  59. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +104 -0
  60. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +1 -0
  61. package/dist/async/middlewares/observe/_module.d.ts +1 -0
  62. package/dist/async/middlewares/observe/_module.js +2 -0
  63. package/dist/async/middlewares/observe/_module.js.map +1 -0
  64. package/dist/async/middlewares/observe/observe.middleware.d.ts +130 -0
  65. package/dist/async/middlewares/observe/observe.middleware.js +80 -0
  66. package/dist/async/middlewares/observe/observe.middleware.js.map +1 -0
  67. package/dist/async/middlewares/retry/_module.d.ts +1 -0
  68. package/dist/async/middlewares/retry/_module.js +2 -0
  69. package/dist/async/middlewares/retry/_module.js.map +1 -0
  70. package/dist/async/middlewares/retry/retry.middleware.d.ts +117 -0
  71. package/dist/async/middlewares/retry/retry.middleware.js +82 -0
  72. package/dist/async/middlewares/retry/retry.middleware.js.map +1 -0
  73. package/dist/async/middlewares/timeout/_module.d.ts +1 -0
  74. package/dist/async/middlewares/timeout/_module.js +2 -0
  75. package/dist/async/middlewares/timeout/_module.js.map +1 -0
  76. package/dist/async/middlewares/timeout/timeout.middleware.d.ts +83 -0
  77. package/dist/async/middlewares/timeout/timeout.middleware.js +60 -0
  78. package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -0
  79. package/dist/async/utilities/_module.d.ts +3 -4
  80. package/dist/async/utilities/_module.js +3 -4
  81. package/dist/async/utilities/_module.js.map +1 -1
  82. package/dist/async/utilities/abort-and-fail/_module.d.ts +1 -0
  83. package/dist/async/utilities/abort-and-fail/_module.js +2 -0
  84. package/dist/async/utilities/abort-and-fail/_module.js.map +1 -0
  85. package/dist/async/utilities/abort-and-fail/abort-and-fail.d.ts +7 -0
  86. package/dist/async/utilities/{abort → abort-and-fail}/abort-and-fail.js +6 -6
  87. package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +1 -0
  88. package/dist/async/utilities/lazy-promise/lazy-promise.d.ts +37 -194
  89. package/dist/async/utilities/lazy-promise/lazy-promise.js +62 -359
  90. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  91. package/dist/async/utilities/promise-queue/_module.d.ts +1 -0
  92. package/dist/async/utilities/promise-queue/_module.js +2 -0
  93. package/dist/async/utilities/promise-queue/_module.js.map +1 -0
  94. package/dist/async/utilities/promise-queue/promise-queue.d.ts +32 -0
  95. package/dist/async/utilities/promise-queue/promise-queue.js +107 -0
  96. package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -0
  97. package/dist/async/utilities/timeout-and-fail/_module.d.ts +1 -0
  98. package/dist/async/utilities/timeout-and-fail/_module.js +2 -0
  99. package/dist/async/utilities/timeout-and-fail/_module.js.map +1 -0
  100. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
  101. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +19 -0
  102. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
  103. package/dist/cache/contracts/cache-adapter.contract.d.ts +14 -14
  104. package/dist/cache/contracts/cache-factory.contract.d.ts +3 -3
  105. package/dist/cache/contracts/cache.contract.d.ts +73 -73
  106. package/dist/cache/contracts/cache.errors.d.ts +7 -7
  107. package/dist/cache/contracts/cache.errors.js +7 -7
  108. package/dist/cache/contracts/cache.events.d.ts +54 -58
  109. package/dist/cache/contracts/cache.events.js +6 -104
  110. package/dist/cache/contracts/cache.events.js.map +1 -1
  111. package/dist/cache/contracts/database-cache-adapter.contract.d.ts +16 -16
  112. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +3 -3
  113. package/dist/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +2 -2
  114. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +3 -9
  115. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +3 -9
  116. package/dist/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  117. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +4 -4
  118. package/dist/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +3 -3
  119. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +2 -2
  120. package/dist/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.js +2 -2
  121. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +3 -3
  122. package/dist/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +2 -2
  123. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +3 -3
  124. package/dist/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +2 -2
  125. package/dist/cache/implementations/derivables/cache/cache.d.ts +26 -27
  126. package/dist/cache/implementations/derivables/cache/cache.js +102 -91
  127. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  128. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +5 -4
  129. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js +2 -1
  130. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  131. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.d.ts +3 -3
  132. package/dist/cache/implementations/test-utilities/cache-adapter.test-suite.js +2 -2
  133. package/dist/cache/implementations/test-utilities/cache.test-suite.d.ts +3 -3
  134. package/dist/cache/implementations/test-utilities/cache.test-suite.js +140 -149
  135. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  136. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.d.ts +3 -3
  137. package/dist/cache/implementations/test-utilities/database-cache-dapter.test-suite.js +2 -2
  138. package/dist/collection/contracts/_shared/compartor.type.d.ts +1 -1
  139. package/dist/collection/contracts/_shared/cross-join-result.type.d.ts +1 -1
  140. package/dist/collection/contracts/_shared/ensure-map.type.d.ts +1 -1
  141. package/dist/collection/contracts/_shared/ensure-record.type.d.ts +1 -1
  142. package/dist/collection/contracts/_shared/foreach.type.d.ts +2 -2
  143. package/dist/collection/contracts/_shared/map.type.d.ts +2 -2
  144. package/dist/collection/contracts/_shared/modifier.type.d.ts +2 -2
  145. package/dist/collection/contracts/_shared/predicate.type.d.ts +7 -7
  146. package/dist/collection/contracts/_shared/reduce.type.d.ts +2 -2
  147. package/dist/collection/contracts/_shared/tap.type.d.ts +2 -2
  148. package/dist/collection/contracts/_shared/transform.type.d.ts +2 -2
  149. package/dist/collection/contracts/async-collection.contract.d.ts +109 -198
  150. package/dist/collection/contracts/collection.contract.d.ts +103 -103
  151. package/dist/collection/contracts/collection.errors.d.ts +11 -11
  152. package/dist/collection/contracts/collection.errors.js +11 -11
  153. package/dist/collection/implementations/_shared.d.ts +8 -8
  154. package/dist/collection/implementations/_shared.js +8 -8
  155. package/dist/collection/implementations/async-iterable-collection/_shared/_module.d.ts +0 -4
  156. package/dist/collection/implementations/async-iterable-collection/_shared/_module.js +0 -4
  157. package/dist/collection/implementations/async-iterable-collection/_shared/_module.js.map +1 -1
  158. package/dist/collection/implementations/async-iterable-collection/_shared/async-cross-join-iterable.js +21 -19
  159. package/dist/collection/implementations/async-iterable-collection/_shared/async-cross-join-iterable.js.map +1 -1
  160. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +15 -19
  161. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js +15 -30
  162. package/dist/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  163. package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.d.ts +3 -3
  164. package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.js +18 -20
  165. package/dist/collection/implementations/iterable-collection/_shared/cross-join-iterable.js.map +1 -1
  166. package/dist/collection/implementations/iterable-collection/iterable-collection.d.ts +11 -12
  167. package/dist/collection/implementations/iterable-collection/iterable-collection.js +11 -12
  168. package/dist/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
  169. package/dist/collection/implementations/list-collection/list-collection.d.ts +11 -11
  170. package/dist/collection/implementations/list-collection/list-collection.js +24 -30
  171. package/dist/collection/implementations/list-collection/list-collection.js.map +1 -1
  172. package/dist/event-bus/contracts/_module-exports.d.ts +0 -1
  173. package/dist/event-bus/contracts/_module-exports.js +0 -1
  174. package/dist/event-bus/contracts/_module-exports.js.map +1 -1
  175. package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +13 -8
  176. package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +6 -7
  177. package/dist/event-bus/contracts/event-bus-factory.contract.js.map +1 -1
  178. package/dist/event-bus/contracts/event-bus.contract.d.ts +30 -41
  179. package/dist/event-bus/contracts/event-bus.errors.d.ts +8 -8
  180. package/dist/event-bus/contracts/event-bus.errors.js +8 -8
  181. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +3 -3
  182. package/dist/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +3 -3
  183. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +2 -2
  184. package/dist/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +2 -2
  185. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +3 -3
  186. package/dist/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +2 -2
  187. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +15 -15
  188. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +32 -32
  189. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  190. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +17 -10
  191. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +13 -6
  192. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  193. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +3 -5
  194. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +15 -22
  195. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
  196. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +3 -5
  197. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +189 -209
  198. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
  199. package/dist/lock/contracts/database-lock-adapter.contract.d.ts +9 -9
  200. package/dist/lock/contracts/lock-adapter.contract.d.ts +7 -7
  201. package/dist/lock/contracts/lock-provider-factory.contract.d.ts +4 -4
  202. package/dist/lock/contracts/lock-provider.contract.d.ts +14 -14
  203. package/dist/lock/contracts/lock.contract.d.ts +22 -22
  204. package/dist/lock/contracts/lock.errors.d.ts +10 -10
  205. package/dist/lock/contracts/lock.errors.js +10 -10
  206. package/dist/lock/contracts/lock.events.d.ts +45 -54
  207. package/dist/lock/contracts/lock.events.js +9 -91
  208. package/dist/lock/contracts/lock.events.js.map +1 -1
  209. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.d.ts +5 -5
  210. package/dist/lock/implementations/adapters/libsql-lock-adapter/libsql-lock-adapter.js +4 -4
  211. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.d.ts +3 -3
  212. package/dist/lock/implementations/adapters/memory-lock-adapter/memory-lock-adapter.js +3 -3
  213. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.d.ts +5 -5
  214. package/dist/lock/implementations/adapters/mongodb-lock-adapter/mongodb-lock-adapter.js +4 -4
  215. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.d.ts +2 -2
  216. package/dist/lock/implementations/adapters/no-op-lock-adapter/no-op-lock-adapter.js +2 -2
  217. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.d.ts +3 -3
  218. package/dist/lock/implementations/adapters/redis-lock-adapter/redis-lock-adapter.js +3 -3
  219. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.d.ts +5 -5
  220. package/dist/lock/implementations/adapters/sqlite-lock-adapter/sqlite-lock-adapter.js +4 -4
  221. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +33 -33
  222. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +30 -30
  223. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  224. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +2 -2
  225. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  226. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +3 -3
  227. package/dist/lock/implementations/derivables/lock-provider/lock.js +77 -58
  228. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  229. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +5 -4
  230. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js +2 -1
  231. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  232. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.d.ts +3 -3
  233. package/dist/lock/implementations/test-utilities/database-lock-adapter.test-suite.js +2 -2
  234. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.d.ts +3 -3
  235. package/dist/lock/implementations/test-utilities/lock-adapter.test-suite.js +2 -2
  236. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.d.ts +3 -3
  237. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +214 -214
  238. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  239. package/dist/serde/contracts/deserializer.contract.d.ts +2 -2
  240. package/dist/serde/contracts/flexible-serde-adapter.contract.d.ts +4 -4
  241. package/dist/serde/contracts/flexible-serde.contract.d.ts +8 -19
  242. package/dist/serde/contracts/serde.contract.d.ts +2 -2
  243. package/dist/serde/contracts/serde.errors.d.ts +4 -4
  244. package/dist/serde/contracts/serde.errors.js +4 -4
  245. package/dist/serde/contracts/serializable.contract.d.ts +2 -2
  246. package/dist/serde/contracts/serializer.contract.d.ts +2 -2
  247. package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.d.ts +2 -2
  248. package/dist/serde/implementations/adapters/no-op-serde-adapter/no-op-serde-adapter.js +2 -2
  249. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.d.ts +1 -1
  250. package/dist/serde/implementations/adapters/super-json-serde-adapter/super-json-serde-adapter.js +1 -1
  251. package/dist/serde/implementations/derivables/serde.d.ts +4 -35
  252. package/dist/serde/implementations/derivables/serde.js +2 -47
  253. package/dist/serde/implementations/derivables/serde.js.map +1 -1
  254. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.d.ts +3 -3
  255. package/dist/serde/implementations/test-utilities/flexible-serde-adapter.test-suite.js +2 -2
  256. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.d.ts +3 -3
  257. package/dist/serde/implementations/test-utilities/flexible-serde.test-suite.js +2 -2
  258. package/dist/utilities/classes/_module.d.ts +1 -1
  259. package/dist/utilities/classes/_module.js +1 -1
  260. package/dist/utilities/classes/_module.js.map +1 -1
  261. package/dist/utilities/classes/hooks/_module.d.ts +3 -0
  262. package/dist/utilities/classes/hooks/_module.js +4 -0
  263. package/dist/utilities/classes/hooks/_module.js.map +1 -0
  264. package/dist/utilities/classes/hooks/async-hooks.d.ts +209 -0
  265. package/dist/utilities/classes/hooks/async-hooks.js +145 -0
  266. package/dist/utilities/classes/hooks/async-hooks.js.map +1 -0
  267. package/dist/utilities/classes/hooks/hooks.d.ts +139 -0
  268. package/dist/utilities/classes/hooks/hooks.js +116 -0
  269. package/dist/utilities/classes/hooks/hooks.js.map +1 -0
  270. package/dist/utilities/classes/hooks/types.d.ts +9 -0
  271. package/dist/utilities/classes/hooks/types.js +5 -0
  272. package/dist/utilities/classes/hooks/types.js.map +1 -0
  273. package/dist/utilities/classes/key-prefixer/key-prefixer.d.ts +3 -3
  274. package/dist/utilities/classes/key-prefixer/key-prefixer.js +4 -4
  275. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
  276. package/dist/utilities/classes/time-span/time-span.d.ts +5 -5
  277. package/dist/utilities/classes/time-span/time-span.js +5 -5
  278. package/dist/utilities/contracts/_module.d.ts +0 -1
  279. package/dist/utilities/contracts/_module.js +0 -1
  280. package/dist/utilities/contracts/_module.js.map +1 -1
  281. package/dist/utilities/contracts/deinitizable.contract.d.ts +1 -1
  282. package/dist/utilities/contracts/initizable.contract.d.ts +1 -1
  283. package/dist/utilities/contracts/prunable.contract.d.ts +1 -1
  284. package/dist/utilities/contracts/serialized-error.contract.d.ts +1 -1
  285. package/dist/utilities/contracts/sqlite-database.contract.d.ts +2 -2
  286. package/dist/utilities/errors.d.ts +5 -5
  287. package/dist/utilities/errors.js +5 -5
  288. package/dist/utilities/functions/factory.js +3 -3
  289. package/dist/utilities/functions/factory.js.map +1 -1
  290. package/dist/utilities/functions/invokable.d.ts +9 -5
  291. package/dist/utilities/functions/invokable.js +12 -2
  292. package/dist/utilities/functions/invokable.js.map +1 -1
  293. package/dist/utilities/functions/lazy.d.ts +5 -0
  294. package/dist/utilities/functions/lazy.js +12 -3
  295. package/dist/utilities/functions/lazy.js.map +1 -1
  296. package/dist/utilities/types/async-iterable-value.type.d.ts +1 -1
  297. package/dist/utilities/types/at-least-one.type.d.ts +1 -1
  298. package/dist/utilities/types/factory.type.d.ts +8 -8
  299. package/dist/utilities/types/invokable.type.d.ts +3 -3
  300. package/dist/utilities/types/items.type.d.ts +1 -1
  301. package/dist/utilities/types/lazy.type.d.ts +5 -5
  302. package/dist/utilities/types/none-func.type.d.ts +1 -1
  303. package/dist/utilities/types/one-or-more.type.d.ts +1 -1
  304. package/dist/utilities/types/promiseable.type.d.ts +1 -1
  305. package/dist/utilities/types/result.type.d.ts +1 -1
  306. package/package.json +22 -2
  307. package/dist/async/async.events.d.ts +0 -105
  308. package/dist/async/async.events.js +0 -82
  309. package/dist/async/async.events.js.map +0 -1
  310. package/dist/async/utilities/abort/_module.d.ts +0 -2
  311. package/dist/async/utilities/abort/_module.js +0 -3
  312. package/dist/async/utilities/abort/_module.js.map +0 -1
  313. package/dist/async/utilities/abort/abort-and-fail.d.ts +0 -4
  314. package/dist/async/utilities/abort/abort-and-fail.js.map +0 -1
  315. package/dist/async/utilities/abort/abort.d.ts +0 -9
  316. package/dist/async/utilities/abort/abort.js +0 -18
  317. package/dist/async/utilities/abort/abort.js.map +0 -1
  318. package/dist/async/utilities/delay/_module.d.ts +0 -1
  319. package/dist/async/utilities/delay/_module.js +0 -2
  320. package/dist/async/utilities/delay/_module.js.map +0 -1
  321. package/dist/async/utilities/delay/delay.d.ts +0 -10
  322. package/dist/async/utilities/delay/delay.js +0 -34
  323. package/dist/async/utilities/delay/delay.js.map +0 -1
  324. package/dist/async/utilities/retry/_module.d.ts +0 -2
  325. package/dist/async/utilities/retry/_module.js +0 -3
  326. package/dist/async/utilities/retry/_module.js.map +0 -1
  327. package/dist/async/utilities/retry/retry-or-fail.d.ts +0 -29
  328. package/dist/async/utilities/retry/retry-or-fail.js +0 -39
  329. package/dist/async/utilities/retry/retry-or-fail.js.map +0 -1
  330. package/dist/async/utilities/retry/retry.d.ts +0 -10
  331. package/dist/async/utilities/retry/retry.js +0 -21
  332. package/dist/async/utilities/retry/retry.js.map +0 -1
  333. package/dist/async/utilities/timeout/_module.d.ts +0 -2
  334. package/dist/async/utilities/timeout/_module.js +0 -3
  335. package/dist/async/utilities/timeout/_module.js.map +0 -1
  336. package/dist/async/utilities/timeout/timeout-and-fail.d.ts +0 -5
  337. package/dist/async/utilities/timeout/timeout-and-fail.js +0 -28
  338. package/dist/async/utilities/timeout/timeout-and-fail.js.map +0 -1
  339. package/dist/async/utilities/timeout/timeout.d.ts +0 -10
  340. package/dist/async/utilities/timeout/timeout.js +0 -21
  341. package/dist/async/utilities/timeout/timeout.js.map +0 -1
  342. package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.d.ts +0 -13
  343. package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js +0 -30
  344. package/dist/collection/implementations/async-iterable-collection/_shared/async-delay-iterable.js.map +0 -1
  345. package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.d.ts +0 -13
  346. package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js +0 -36
  347. package/dist/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js.map +0 -1
  348. package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.d.ts +0 -9
  349. package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js +0 -39
  350. package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js.map +0 -1
  351. package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.d.ts +0 -13
  352. package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js +0 -52
  353. package/dist/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js.map +0 -1
  354. package/dist/event-bus/contracts/_shared.d.ts +0 -12
  355. package/dist/event-bus/contracts/_shared.js +0 -15
  356. package/dist/event-bus/contracts/_shared.js.map +0 -1
  357. package/dist/utilities/classes/sync-event-bus/_module.d.ts +0 -1
  358. package/dist/utilities/classes/sync-event-bus/_module.js +0 -2
  359. package/dist/utilities/classes/sync-event-bus/_module.js.map +0 -1
  360. package/dist/utilities/classes/sync-event-bus/sync-event-bus.d.ts +0 -16
  361. package/dist/utilities/classes/sync-event-bus/sync-event-bus.js +0 -53
  362. package/dist/utilities/classes/sync-event-bus/sync-event-bus.js.map +0 -1
  363. package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +0 -13
  364. package/dist/utilities/contracts/sync-event-bus-listenable.js +0 -5
  365. package/dist/utilities/contracts/sync-event-bus-listenable.js.map +0 -1
@@ -1,64 +1,35 @@
1
- import { retryOrFail } from "../../../async/utilities/retry/_module.js";
2
- import { timeoutAndFail } from "../../../async/utilities/timeout/_module.js";
3
- import { abortAndFail } from "../../../async/utilities/abort/_module.js";
4
- import {
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
- TimeoutAsyncError, } from "../../../async/async.errors.js";
7
- import {
8
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
- RetryAsyncError, } from "../../../async/async.errors.js";
10
- import {
11
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
- AbortAsyncError, } from "../../../async/async.errors.js";
13
- import { removeUndefinedProperties, resolveAsyncLazyable, resolveInvokable, SyncEventBus, } from "../../../utilities/_module-exports.js";
14
- import { delay } from "../../../async/utilities/_module.js";
15
- import { AbortAsyncEvent, FailureAsyncEvent, FinallyAsyncEvent, RetryAttemptAsyncEvent, RetryFailureAsyncEvent, RetryTimeoutAsyncEvent, SuccessAsyncEvent, TotalTimeoutFailureAsyncEvent, } from "../../../async/async.events.js";
16
1
  /**
17
- * 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.
18
- * The class includes helpful methods
19
- * - <i>defer</i>
20
- * - <i>setRetryTimeout</i>
21
- * - <i>setRetryPolicy</i>
22
- * - <i>setBackoffPolicy</i>
23
- * - <i>setRetryAttempts</i>
24
- * - <i>setTotalTimeout</i>
25
- * - <i>setAbortSignal</i>
26
- *
27
- * The order in which these methods are called does not have any affect. Internally, the following execution order is applied:
28
- * 1. <i>setRetryTimeout</i>
29
- * 2. <i>setRetryPolicy</i>
30
- * 3. <i>setBackoffPolicy</i>
31
- * 4. <i>setRetryAttempts</i>
32
- * 5. <i>setTotalTimeout</i>
33
- * 6. <i>setAbortSignal</i>
2
+ * @module Async
3
+ */
4
+ import { AsyncHooks, callInvokable, resolveAsyncLazyable, } from "../../../utilities/_module-exports.js";
5
+ import { abortAndFail } from "../../../async/utilities/abort-and-fail/_module.js";
6
+ /**
7
+ * The `LazyPromise` class is used for creating lazy {@link PromiseLike | `PromiseLike`} object that will only execute when awaited or when `then` method is called.
8
+ * Note the class is immutable.
34
9
  *
35
- * IMPORT_PATH: ```"@daiso-tech/core/async"```
10
+ * IMPORT_PATH: `"@daiso-tech/core/async"`
36
11
  * @group Utilities
37
12
  */
38
13
  export class LazyPromise {
39
14
  /**
40
- * The <i>wrapFn</i> is convience method used for wrapping async <i>{@link Invokable}</i> with a <i>LazyPromise</i>.
15
+ * The `wrapFn` is convience method used for wrapping async {@link Invokable | `Invokable`} with a `LazyPromise`.
41
16
  * @example
42
17
  * ```ts
43
- * import { LazyPromise } from "@daiso-tech/core/async";
18
+ * import { LazyPromise, retry } from "@daiso-tech/core/async";
44
19
  * import { TimeSpan } from "@daiso-tech/core/utilities";
45
20
  * import { readFile as readFileNodeJs } from "node:fs/promises";
46
21
  *
47
22
  * const readFile = LazyPromise.wrapFn(readFileNodeJs);
48
23
  *
49
- * const file = await readFile("none_existing_file.txt")
50
- * .setRetryAttempts(4)
51
- * .setRetryTimeout(TimeSpan.fromMinutes(1));
24
+ * const file = await readFile("none_existing_file.txt");
52
25
  * ```
53
26
  */
54
- static wrapFn(fn, settings) {
55
- return (...parameters) => new LazyPromise(() => resolveInvokable(fn)(...parameters), settings);
27
+ static wrapFn(fn) {
28
+ return (...parameters) => new LazyPromise(() => callInvokable(fn, ...parameters));
56
29
  }
57
30
  /**
58
- * The <i>delay</i> method creates a <i>{@link LazyPromise}</i> that will be fulfilled after given <i>time</i>.
31
+ * The `delay` method creates a {@link LazyPromise | `LazyPromise`} that will be fulfilled after given `time`.
59
32
  *
60
- * @throws {AsyncError} {@link AsyncError}
61
- * @throws {AbortAsyncError} {@link AbortAsyncError}
62
33
  * @example
63
34
  * ```ts
64
35
  * import { LazyPromise } from "@daiso-tech/core/async";
@@ -69,37 +40,49 @@ export class LazyPromise {
69
40
  * console.log("b");
70
41
  * ```
71
42
  */
72
- static delay(time) {
43
+ static delay(time, abortSignal = new AbortController().signal) {
73
44
  return new LazyPromise(async () => {
74
- await delay(time);
45
+ let timeoutId = null;
46
+ try {
47
+ await abortAndFail(new Promise((resolve) => {
48
+ timeoutId = setTimeout(() => {
49
+ resolve();
50
+ }, time.toMilliseconds());
51
+ }), abortSignal);
52
+ }
53
+ finally {
54
+ if (timeoutId !== null) {
55
+ clearTimeout(timeoutId);
56
+ }
57
+ }
75
58
  });
76
59
  }
77
60
  /**
78
- * The <i>all<i> method works similarly to <i>{@link Promise.all}</i> with the key distinction that it operates lazily.
61
+ * The `all` method works similarly to {@link Promise.all | `Promise.all`} with the key distinction that it operates lazily.
79
62
  */
80
- static all(promises, settings) {
81
- return new LazyPromise(async () => Promise.all(promises), settings);
63
+ static all(promises) {
64
+ return new LazyPromise(async () => Promise.all(promises));
82
65
  }
83
66
  /**
84
- * The <i>allSettled<i> method works similarly to <i>{@link Promise.allSettled}</i> with the key distinction that it operates lazily.
67
+ * The `allSettled` method works similarly to {@link Promise.allSettled | `Promise.allSettled`} with the key distinction that it operates lazily.
85
68
  */
86
- static allSettled(promises, settings) {
87
- return new LazyPromise(async () => Promise.allSettled(promises), settings);
69
+ static allSettled(promises) {
70
+ return new LazyPromise(async () => Promise.allSettled(promises));
88
71
  }
89
72
  /**
90
- * The <i>race<i> method works similarly to <i>{@link Promise.race}</i> with the key distinction that it operates lazily.
73
+ * The `race` method works similarly to {@link Promise.race | `Promise.race`} with the key distinction that it operates lazily.
91
74
  */
92
- static race(promises, settings) {
93
- return new LazyPromise(async () => Promise.race(promises), settings);
75
+ static race(promises) {
76
+ return new LazyPromise(async () => Promise.race(promises));
94
77
  }
95
78
  /**
96
- * The <i>any<i> method works similarly to <i>{@link Promise.any}</i> with the key distinction that it operates lazily.
79
+ * The `any` method works similarly to {@link Promise.any | `Promise.any`} with the key distinction that it operates lazily.
97
80
  */
98
- static any(promises, settings) {
99
- return new LazyPromise(async () => Promise.any(promises), settings);
81
+ static any(promises) {
82
+ return new LazyPromise(async () => Promise.any(promises));
100
83
  }
101
84
  /**
102
- * The <i>fromCallback</i> is convience method used for wrapping Node js callback functions with a <i>LazyPromise</i>.
85
+ * The `fromCallback` is convience method used for wrapping Node js callback functions with a `LazyPromise`.
103
86
  * @example
104
87
  * ```ts
105
88
  * import { LazyPromise } from "@daiso-tech/core/async";
@@ -118,321 +101,55 @@ export class LazyPromise {
118
101
  * console.log(file);
119
102
  * ```
120
103
  */
121
- static fromCallback(callback, settings) {
104
+ static fromCallback(callback) {
122
105
  return new LazyPromise(() => new Promise((resolve, reject) => {
123
106
  callback(resolve, reject);
124
- }), settings);
107
+ }));
125
108
  }
126
109
  promise = null;
127
- asyncFn;
128
- settings;
129
- eventBus = new SyncEventBus();
110
+ invokable;
130
111
  /**
131
112
  * @example
132
113
  * ```ts
133
- * import { LazyPromise } from "@daiso-tech/core/async";
114
+ * import { LazyPromise, retryMiddleware } from "@daiso-tech/core/async";
134
115
  *
135
116
  * const promise = new LazyPromise(async () => {
136
117
  * console.log("I am lazy");
137
- * });
118
+ * },
119
+ * // You can also pass in one AsyncMiddleware or multiple (as an Array).
120
+ * retry()
121
+ * );
138
122
  *
139
123
  * // "I am lazy" will only logged when awaited or then method i called.
140
124
  * await promise;
141
125
  * ```
142
126
  *
143
- * You can pass sync or async <i>{@link Invokable}</i>.
127
+ * You can pass sync or async {@link Invokable | `Invokable`}.
144
128
  */
145
- constructor(invokable, settings = {}) {
146
- this.asyncFn = () => resolveAsyncLazyable(invokable);
147
- this.settings = removeUndefinedProperties({
148
- retryAttempts: null,
149
- backoffPolicy: null,
150
- retryPolicy: null,
151
- retryTimeout: null,
152
- totalTimeout: null,
153
- abortSignal: null,
154
- onFinally: () => { },
155
- onSuccess: (_value) => { },
156
- onError: () => { },
157
- ...settings,
158
- });
159
- }
160
- addListener(event, listener) {
161
- this.eventBus.addListener(event, listener);
162
- }
163
- removeListener(event, listener) {
164
- this.eventBus.removeListener(event, listener);
165
- }
166
- applyRetryTimeout() {
167
- if (this.settings.retryTimeout === null) {
168
- return;
169
- }
170
- const oldAsyncFn = this.asyncFn;
171
- const newAsyncFn = async () => {
172
- try {
173
- if (this.settings.retryTimeout === null) {
174
- throw new Error(`LazyPromise["time"] field is null`);
175
- }
176
- return await timeoutAndFail(oldAsyncFn, this.settings.retryTimeout);
177
- }
178
- catch (error) {
179
- if (error instanceof TimeoutAsyncError) {
180
- this.eventBus.dispatch(new RetryTimeoutAsyncEvent({ error }));
181
- }
182
- throw error;
183
- }
184
- };
185
- this.asyncFn = newAsyncFn;
186
- }
187
- applyRetry() {
188
- if (this.settings.retryAttempts === null) {
189
- return;
190
- }
191
- this.applyRetryTimeout();
192
- const oldAsyncFn = this.asyncFn;
193
- const newAsyncFn = async () => {
194
- try {
195
- if (this.settings.retryAttempts === null) {
196
- throw new Error(`LazyPromise["attempts"] field is null`);
197
- }
198
- return await retryOrFail(async (attempt) => {
199
- try {
200
- return await oldAsyncFn();
201
- }
202
- catch (error) {
203
- this.eventBus.dispatch(new RetryAttemptAsyncEvent({
204
- attempt,
205
- error,
206
- }));
207
- throw error;
208
- }
209
- }, {
210
- backoffPolicy: this.settings.backoffPolicy ?? undefined,
211
- retryPolicy: this.settings.retryPolicy ?? undefined,
212
- maxAttempts: this.settings.retryAttempts,
213
- });
214
- }
215
- catch (error) {
216
- if (error instanceof RetryAsyncError) {
217
- this.eventBus.dispatch(new RetryFailureAsyncEvent({ error }));
218
- }
219
- throw error;
220
- }
221
- };
222
- this.asyncFn = newAsyncFn;
223
- }
224
- applyTotalTimeout() {
225
- if (this.settings.totalTimeout === null) {
226
- return;
227
- }
228
- const oldAsyncFn = this.asyncFn;
229
- const newAsyncFn = () => {
230
- try {
231
- if (this.settings.totalTimeout === null) {
232
- throw new Error(`LazyPromise["time"] field is null`);
233
- }
234
- return timeoutAndFail(oldAsyncFn, this.settings.totalTimeout);
235
- }
236
- catch (error) {
237
- if (error instanceof TimeoutAsyncError) {
238
- this.eventBus.dispatch(new TotalTimeoutFailureAsyncEvent({ error }));
239
- }
240
- throw error;
241
- }
242
- };
243
- this.asyncFn = newAsyncFn;
244
- }
245
- applyAbort() {
246
- if (this.settings.abortSignal === null) {
247
- return;
248
- }
249
- const oldAsyncFn = this.asyncFn;
250
- const newAsyncFn = async () => {
251
- try {
252
- if (this.settings.abortSignal === null) {
253
- throw new Error(`LazyPromise["abortSignal"] field is null`);
254
- }
255
- return await abortAndFail(oldAsyncFn, this.settings.abortSignal);
256
- }
257
- catch (error) {
258
- if (error instanceof AbortAsyncError) {
259
- this.eventBus.dispatch(new AbortAsyncEvent({ error }));
260
- }
261
- throw error;
262
- }
263
- };
264
- this.asyncFn = newAsyncFn;
265
- }
266
- applySettings() {
267
- this.applyRetry();
268
- this.applyTotalTimeout();
269
- this.applyAbort();
129
+ constructor(invokable, middlewares = []) {
130
+ this.invokable = new AsyncHooks(() => resolveAsyncLazyable(invokable), middlewares);
270
131
  }
271
132
  /**
272
- * The <i>setBackoffPolicy</i> method is used for setting a custom <i>{@link BackoffPolicy}</i>.
273
- * ```ts
274
- * import { LazyPromise, linearBackoffPolicy } from "@daiso-tech/core/async";
275
- * import { TimeSpan } from "@daiso-tech/core/utilities";
276
- *
277
- * const promise =
278
- * new LazyPromise(async () => {
279
- * console.log("A");
280
- * throw new Error("Error occured!");
281
- * })
282
- * .setRetryAttempts(3)
283
- * .setBackoffPolicy(linearBackoffPolicy())
284
- *
285
- * // Will log "A" 3 times and then retry error will be thrown.
286
- * await promise;
287
- * ```
133
+ * The `pipe` method returns a new `LazyPromise` instance with the additional `middlewares` applied.
288
134
  */
289
- setBackoffPolicy(policy) {
290
- return new LazyPromise(this.asyncFn, {
291
- ...this.settings,
292
- backoffPolicy: policy,
293
- });
135
+ pipe(middlewares) {
136
+ return new LazyPromise(this.invokable.pipe(middlewares));
294
137
  }
295
138
  /**
296
- * The <i>setRetryAttempts</i> method is used for setting max retry attempts.
297
- * @example
298
- * ```ts
299
- * import { LazyPromise } from "@daiso-tech/core/async";
300
- *
301
- * const promise =
302
- * new LazyPromise(async () => {
303
- * console.log("A");
304
- * throw new Error("Error occured!");
305
- * })
306
- * .setRetryAttempts(3)
307
- *
308
- * // Will log "A" 3 times and then retry error will be thrown.
309
- * await promise;
310
- * ```
139
+ * The `pipeWhen` method conditionally applies additional `middlewares`, returning a new `LazyPromise` instance only if the specified condition is met.
311
140
  */
312
- setRetryAttempts(attempts) {
313
- return new LazyPromise(this.asyncFn, {
314
- ...this.settings,
315
- retryAttempts: attempts,
316
- });
317
- }
318
- /**
319
- * The <i>setRetryPolicy</i> method is used for setting a custom <i>{@link BackoffPolicy}</i>.
320
- * @example
321
- * ```ts
322
- * import { LazyPromise } from "@daiso-tech/core/async";
323
- *
324
- * class ErrorA extends Error {}
325
- *
326
- * const promise =
327
- * new LazyPromise(async () => {
328
- * console.log("A");
329
- * throw new Error("Error occured!");
330
- * })
331
- * .setRetryAttempts(3)
332
- * // Will only retry an error that is instance ErrorA
333
- * .setRetryPolicy(error => error instanceof ErrorA)
334
- *
335
- * // Will log "A" 1 time and then error will be thrown.
336
- * await promise;
337
- * ```
338
- */
339
- setRetryPolicy(policy) {
340
- return new LazyPromise(this.asyncFn, {
341
- ...this.settings,
342
- retryPolicy: policy,
343
- });
141
+ pipeWhen(condition, middlewares) {
142
+ return new LazyPromise(this.invokable.pipeWhen(condition, middlewares));
344
143
  }
345
- /**
346
- * The <i>setRetryTimeout</i> method aborts the each retry if it exceeds the given <i>time</i>.
347
- * @example
348
- * ```ts
349
- * import { LazyPromise } from "@daiso-tech/core/async";
350
- * import { TimeSpan } from "@daiso-tech/core/utilities";
351
- *
352
- * const promise =
353
- * new LazyPromise(async () => {
354
- * await LazyPromise.delay(TimeSpan.fromMinutes(1));
355
- * })
356
- * .setRetryTimeout(TimeSpan.fromSeconds(1));
357
- *
358
- * // An timeout error will be thrown.
359
- * await promise;
360
- * ```
361
- */
362
- setRetryTimeout(time) {
363
- return new LazyPromise(this.asyncFn, {
364
- ...this.settings,
365
- retryTimeout: time,
366
- });
367
- }
368
- /**
369
- * The <i>setTotalTimeout</i> method aborts the <i>LazyPromise</i> if it exceeds the given <i>time</i> by throwning an error.
370
- * @example
371
- * ```ts
372
- * import { LazyPromise } from "@daiso-tech/core/async";
373
- * import { TimeSpan } from "@daiso-tech/core/utilities";
374
- *
375
- * const promise =
376
- * new LazyPromise(async () => {
377
- * await LazyPromise.delay(TimeSpan.fromMinutes(1));
378
- * })
379
- * .setRetryTimeout(TimeSpan.fromSeconds(1));
380
- *
381
- * // An timeout error will be thrown.
382
- * await promise;
383
- * ```
384
- */
385
- setTotalTimeout(time) {
386
- return new LazyPromise(this.asyncFn, {
387
- ...this.settings,
388
- totalTimeout: time,
389
- });
390
- }
391
- /**
392
- * The <i>setAbortSignal</i> method aborts the <i>LazyPromise</i> by the passed in <i>abortSignal</i>.
393
- * @example
394
- * ```ts
395
- * import { LazyPromise } from "@daiso-tech/core";
396
- * import { TimeSpan } from "@daiso-tech/core/utilities";
397
- *
398
- * const abortController = new AbortController();
399
- * const promise =
400
- * new LazyPromise(async () => {
401
- * await LazyPromise.delay(TimeSpan.fromMinutes(1));
402
- * })
403
- * .setAbortSignal(abortController.signal);
404
- *
405
- * setTimeout(() => {
406
- * abortController.abort();
407
- * }, 1000);
408
- *
409
- * // An timeout error will be thrown.
410
- * await promise;
411
- * ```
412
- */
413
- setAbortSignal(abortSignal) {
414
- return new LazyPromise(this.asyncFn, {
415
- ...this.settings,
416
- abortSignal,
417
- });
418
- }
419
- /**
420
- * @throws {AbortAsyncError} {@link AbortAsyncError}
421
- * @throws {TimeoutAsyncError} {@link TimeoutAsyncError}
422
- * @throws {RetryAsyncError} {@link RetryAsyncError}
423
- */
424
- then(onfulfilled,
425
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
426
- onrejected) {
427
- this.applySettings();
144
+ then(onfulfilled, onrejected) {
428
145
  if (this.promise === null) {
429
- this.promise = this.asyncFn();
146
+ this.promise = this.invokable.invoke();
430
147
  }
431
148
  // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
432
149
  return this.promise.then(onfulfilled, onrejected);
433
150
  }
434
151
  /**
435
- * The <i>defer</i> method executes the <i>LazyPromise</i> without awaiting it.
152
+ * The `defer` method executes the `LazyPromise` without awaiting it.
436
153
  * @example
437
154
  * ```ts
438
155
  * import { LazyPromise } from "@daiso-tech/core/async";
@@ -453,21 +170,7 @@ export class LazyPromise {
453
170
  * ```
454
171
  */
455
172
  defer() {
456
- const onFinally = () => {
457
- this.eventBus.dispatch(new FinallyAsyncEvent({}));
458
- this.eventBus.clear();
459
- };
460
- const onSuccess = (value) => {
461
- this.eventBus.dispatch(new SuccessAsyncEvent({ value }));
462
- onFinally();
463
- return value;
464
- };
465
- const onFailure = (error) => {
466
- this.eventBus.dispatch(new FailureAsyncEvent({ error }));
467
- onFinally();
468
- return error;
469
- };
470
- this.then(onSuccess, onFailure);
173
+ this.then(() => { });
471
174
  }
472
175
  }
473
176
  //# sourceMappingURL=lazy-promise.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-promise.js","sourceRoot":"","sources":["../../../../src/async/utilities/lazy-promise/lazy-promise.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO;AACH,6DAA6D;AAC7D,iBAAiB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO;AACH,6DAA6D;AAC7D,eAAe,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO;AACH,6DAA6D;AAC7D,eAAe,GAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACH,yBAAyB,EACzB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,GACf,MAAM,gCAAgC,CAAC;AACxC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OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAC3C,CAAC;QACD,qFAAqF;QACrF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACxB,CAAC;CACJ"}
@@ -0,0 +1 @@
1
+ export * from "../../../async/utilities/promise-queue/promise-queue.js";
@@ -0,0 +1,2 @@
1
+ export * from "../../../async/utilities/promise-queue/promise-queue.js";
2
+ //# sourceMappingURL=_module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_module.js","sourceRoot":"","sources":["../../../../src/async/utilities/promise-queue/_module.ts"],"names":[],"mappings":"AAAA,cAAc,kDAAkD,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @module Async
3
+ */
4
+ import type { TimeSpan } from "../../../utilities/_module-exports.js";
5
+ import { type InvokableFn, type Promisable } from "../../../utilities/_module-exports.js";
6
+ /**
7
+ * @internal
8
+ */
9
+ export type PromiseQueueSettings = {
10
+ maxConcurrency: number;
11
+ maxCapacity: number | null;
12
+ interval: TimeSpan;
13
+ };
14
+ /**
15
+ * @internal
16
+ */
17
+ export declare class PromiseQueue {
18
+ private readonly settings;
19
+ private readonly queue;
20
+ private readonly listeners;
21
+ constructor(settings: PromiseQueueSettings);
22
+ private start;
23
+ private getItems;
24
+ private process;
25
+ private enqueue;
26
+ private listenOnce;
27
+ private asPromise;
28
+ /**
29
+ * @throws {CapacityFullAsyncError} {@link CapacityFullAsyncError}
30
+ */
31
+ add<TValue>(func: InvokableFn<[signal: AbortSignal], Promisable<TValue>>, signal: AbortSignal): Promise<TValue>;
32
+ }