@daiso-tech/core 0.16.0 → 0.17.4

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 (339) hide show
  1. package/dist/cjs/async/_module.js +1 -1
  2. package/dist/cjs/async/_module.js.map +1 -1
  3. package/dist/cjs/async/backof-policies/_module.js +1 -0
  4. package/dist/cjs/async/backof-policies/_module.js.map +1 -1
  5. package/dist/cjs/async/utilities/_module.js +3 -0
  6. package/dist/cjs/async/utilities/_module.js.map +1 -1
  7. package/dist/cjs/async/utilities/lazy-promise/lazy-promise.js +16 -22
  8. package/dist/cjs/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  9. package/dist/cjs/cache/contracts/cache.events.js +168 -0
  10. package/dist/cjs/cache/contracts/cache.events.js.map +1 -1
  11. package/dist/cjs/cache/implementations/_shared/_module.js +1 -0
  12. package/dist/cjs/cache/implementations/_shared/_module.js.map +1 -1
  13. package/dist/cjs/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
  14. package/dist/cjs/cache/implementations/_shared/cache.test-suite.js.map +1 -1
  15. package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +7 -5
  16. package/dist/cjs/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
  17. package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/_module.js +2 -1
  18. package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -1
  19. package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js +56 -0
  20. package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js.map +1 -0
  21. package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +18 -14
  22. package/dist/cjs/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
  23. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js +1 -0
  24. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -1
  25. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js +26 -0
  26. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js.map +1 -0
  27. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +11 -3
  28. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  29. package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js +2 -1
  30. package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -1
  31. package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js +44 -0
  32. package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js.map +1 -0
  33. package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +21 -8
  34. package/dist/cjs/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
  35. package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js +1 -0
  36. package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -1
  37. package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js +32 -0
  38. package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js.map +1 -0
  39. package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +27 -20
  40. package/dist/cjs/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
  41. package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js +1 -0
  42. package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -1
  43. package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js +56 -0
  44. package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js.map +1 -0
  45. package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +19 -15
  46. package/dist/cjs/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
  47. package/dist/cjs/cache/implementations/derivables/_module.js +3 -1
  48. package/dist/cjs/cache/implementations/derivables/_module.js.map +1 -1
  49. package/dist/cjs/cache/implementations/derivables/cache-factory-settings.js +65 -0
  50. package/dist/cjs/cache/implementations/derivables/cache-factory-settings.js.map +1 -0
  51. package/dist/cjs/cache/implementations/derivables/cache-factory.js +29 -15
  52. package/dist/cjs/cache/implementations/derivables/cache-factory.js.map +1 -1
  53. package/dist/cjs/cache/implementations/derivables/cache-settings.js +56 -0
  54. package/dist/cjs/cache/implementations/derivables/cache-settings.js.map +1 -0
  55. package/dist/cjs/cache/implementations/derivables/cache.js +104 -93
  56. package/dist/cjs/cache/implementations/derivables/cache.js.map +1 -1
  57. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js +1 -1
  58. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js.map +1 -1
  59. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js +1 -1
  60. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js.map +1 -1
  61. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js +1 -1
  62. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js.map +1 -1
  63. package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js +20 -11
  64. package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  65. package/dist/cjs/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
  66. package/dist/cjs/collection/implementations/list-collection/list-collection.js.map +1 -1
  67. package/dist/cjs/event-bus/contracts/_module.js +2 -2
  68. package/dist/cjs/event-bus/contracts/_module.js.map +1 -1
  69. package/dist/cjs/event-bus/contracts/_shared.js +7 -0
  70. package/dist/cjs/event-bus/contracts/_shared.js.map +1 -1
  71. package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +52 -36
  72. package/dist/cjs/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
  73. package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js +156 -120
  74. package/dist/cjs/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
  75. package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js +2 -1
  76. package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -1
  77. package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js +26 -0
  78. package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js.map +1 -0
  79. package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +17 -9
  80. package/dist/cjs/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
  81. package/dist/cjs/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +3 -3
  82. package/dist/cjs/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
  83. package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js +2 -1
  84. package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js.map +1 -1
  85. package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js +38 -0
  86. package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js.map +1 -0
  87. package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +9 -5
  88. package/dist/cjs/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
  89. package/dist/cjs/event-bus/implementations/derivables/_module.js +3 -1
  90. package/dist/cjs/event-bus/implementations/derivables/_module.js.map +1 -1
  91. package/dist/cjs/event-bus/implementations/derivables/event-bus-factory-settings.js +59 -0
  92. package/dist/cjs/event-bus/implementations/derivables/event-bus-factory-settings.js.map +1 -0
  93. package/dist/cjs/event-bus/implementations/derivables/event-bus-factory.js +28 -16
  94. package/dist/cjs/event-bus/implementations/derivables/event-bus-factory.js.map +1 -1
  95. package/dist/cjs/event-bus/implementations/derivables/event-bus-settings.js +56 -0
  96. package/dist/cjs/event-bus/implementations/derivables/event-bus-settings.js.map +1 -0
  97. package/dist/cjs/event-bus/implementations/derivables/event-bus.js +74 -62
  98. package/dist/cjs/event-bus/implementations/derivables/event-bus.js.map +1 -1
  99. package/dist/cjs/serde/contracts/_module.js +4 -0
  100. package/dist/cjs/serde/contracts/_module.js.map +1 -1
  101. package/dist/cjs/serde/contracts/deserializer.contract.js +3 -0
  102. package/dist/cjs/serde/contracts/deserializer.contract.js.map +1 -0
  103. package/dist/cjs/serde/contracts/flexible-serde.contract.js +3 -0
  104. package/dist/cjs/serde/contracts/flexible-serde.contract.js.map +1 -0
  105. package/dist/cjs/serde/contracts/serializable.contract.js +3 -0
  106. package/dist/cjs/serde/contracts/serializable.contract.js.map +1 -0
  107. package/dist/cjs/serde/contracts/serializer.contract.js +3 -0
  108. package/dist/cjs/serde/contracts/serializer.contract.js.map +1 -0
  109. package/dist/cjs/serde/implementations/_module.js +1 -0
  110. package/dist/cjs/serde/implementations/_module.js.map +1 -1
  111. package/dist/cjs/serde/implementations/_shared/test-utilities/_module.js +1 -0
  112. package/dist/cjs/serde/implementations/_shared/test-utilities/_module.js.map +1 -1
  113. package/dist/cjs/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js +53 -0
  114. package/dist/cjs/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js.map +1 -0
  115. package/dist/cjs/serde/implementations/_shared/test-utilities/serde.test-suite.js +35 -60
  116. package/dist/cjs/serde/implementations/_shared/test-utilities/serde.test-suite.js.map +1 -1
  117. package/dist/cjs/serde/implementations/no-op-serde/_module.js +18 -0
  118. package/dist/cjs/serde/implementations/no-op-serde/_module.js.map +1 -0
  119. package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js +16 -0
  120. package/dist/cjs/serde/implementations/no-op-serde/no-op-serde.js.map +1 -0
  121. package/dist/cjs/serde/implementations/super-json-serde/super-json-serde.js +5 -2
  122. package/dist/cjs/serde/implementations/super-json-serde/super-json-serde.js.map +1 -1
  123. package/dist/cjs/utilities/contracts/_module.js +1 -0
  124. package/dist/cjs/utilities/contracts/_module.js.map +1 -1
  125. package/dist/cjs/utilities/contracts/buildable.contract.js +3 -0
  126. package/dist/cjs/utilities/contracts/buildable.contract.js.map +1 -0
  127. package/dist/cjs/utilities/errors.js +10 -10
  128. package/dist/cjs/utilities/errors.js.map +1 -1
  129. package/dist/cjs/utilities/functions.js +4 -0
  130. package/dist/cjs/utilities/functions.js.map +1 -1
  131. package/dist/cjs/utilities/time-span/time-span.js.map +1 -1
  132. package/dist/esm/async/_module.js +1 -1
  133. package/dist/esm/async/_module.js.map +1 -1
  134. package/dist/esm/async/backof-policies/_module.js +1 -0
  135. package/dist/esm/async/backof-policies/_module.js.map +1 -1
  136. package/dist/esm/async/utilities/_module.js +3 -0
  137. package/dist/esm/async/utilities/_module.js.map +1 -1
  138. package/dist/esm/async/utilities/lazy-promise/lazy-promise.js +16 -22
  139. package/dist/esm/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  140. package/dist/esm/cache/contracts/cache.events.js +158 -0
  141. package/dist/esm/cache/contracts/cache.events.js.map +1 -1
  142. package/dist/esm/cache/implementations/_shared/_module.js +1 -0
  143. package/dist/esm/cache/implementations/_shared/_module.js.map +1 -1
  144. package/dist/esm/cache/implementations/_shared/cache-adapter.test-suite.js.map +1 -1
  145. package/dist/esm/cache/implementations/_shared/cache.test-suite.js.map +1 -1
  146. package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js +7 -5
  147. package/dist/esm/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.js.map +1 -1
  148. package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js +2 -1
  149. package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/_module.js.map +1 -1
  150. package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js +52 -0
  151. package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.js.map +1 -0
  152. package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js +17 -13
  153. package/dist/esm/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.js.map +1 -1
  154. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js +1 -0
  155. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/_module.js.map +1 -1
  156. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js +22 -0
  157. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.js.map +1 -0
  158. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +11 -3
  159. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  160. package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js +2 -1
  161. package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/_module.js.map +1 -1
  162. package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js +40 -0
  163. package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.js.map +1 -0
  164. package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js +21 -8
  165. package/dist/esm/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.js.map +1 -1
  166. package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js +1 -0
  167. package/dist/esm/cache/implementations/adapters/redis-cache-adapter/_module.js.map +1 -1
  168. package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js +28 -0
  169. package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.js.map +1 -0
  170. package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js +28 -21
  171. package/dist/esm/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.js.map +1 -1
  172. package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js +1 -0
  173. package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/_module.js.map +1 -1
  174. package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js +52 -0
  175. package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.js.map +1 -0
  176. package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js +17 -13
  177. package/dist/esm/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.js.map +1 -1
  178. package/dist/esm/cache/implementations/derivables/_module.js +3 -1
  179. package/dist/esm/cache/implementations/derivables/_module.js.map +1 -1
  180. package/dist/esm/cache/implementations/derivables/cache-factory-settings.js +61 -0
  181. package/dist/esm/cache/implementations/derivables/cache-factory-settings.js.map +1 -0
  182. package/dist/esm/cache/implementations/derivables/cache-factory.js +30 -16
  183. package/dist/esm/cache/implementations/derivables/cache-factory.js.map +1 -1
  184. package/dist/esm/cache/implementations/derivables/cache-settings.js +52 -0
  185. package/dist/esm/cache/implementations/derivables/cache-settings.js.map +1 -0
  186. package/dist/esm/cache/implementations/derivables/cache.js +82 -71
  187. package/dist/esm/cache/implementations/derivables/cache.js.map +1 -1
  188. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js +1 -1
  189. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.js.map +1 -1
  190. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js +1 -1
  191. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-abort-iterable.js.map +1 -1
  192. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js +1 -1
  193. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-take-until-timeout-iterable.js.map +1 -1
  194. package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js +20 -11
  195. package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  196. package/dist/esm/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
  197. package/dist/esm/collection/implementations/list-collection/list-collection.js.map +1 -1
  198. package/dist/esm/event-bus/contracts/_module.js +2 -2
  199. package/dist/esm/event-bus/contracts/_module.js.map +1 -1
  200. package/dist/esm/event-bus/contracts/_shared.js +5 -0
  201. package/dist/esm/event-bus/contracts/_shared.js.map +1 -1
  202. package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js +45 -29
  203. package/dist/esm/event-bus/implementations/_shared/event-bus-adapter.test-suite.js.map +1 -1
  204. package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js +143 -107
  205. package/dist/esm/event-bus/implementations/_shared/event-bus.test-suite.js.map +1 -1
  206. package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js +2 -1
  207. package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/_module.js.map +1 -1
  208. package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js +22 -0
  209. package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.js.map +1 -0
  210. package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js +17 -9
  211. package/dist/esm/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.js.map +1 -1
  212. package/dist/esm/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js +3 -3
  213. package/dist/esm/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.js.map +1 -1
  214. package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js +2 -1
  215. package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.js.map +1 -1
  216. package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js +34 -0
  217. package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.js.map +1 -0
  218. package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js +10 -6
  219. package/dist/esm/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.js.map +1 -1
  220. package/dist/esm/event-bus/implementations/derivables/_module.js +3 -1
  221. package/dist/esm/event-bus/implementations/derivables/_module.js.map +1 -1
  222. package/dist/esm/event-bus/implementations/derivables/event-bus-factory-settings.js +55 -0
  223. package/dist/esm/event-bus/implementations/derivables/event-bus-factory-settings.js.map +1 -0
  224. package/dist/esm/event-bus/implementations/derivables/event-bus-factory.js +29 -17
  225. package/dist/esm/event-bus/implementations/derivables/event-bus-factory.js.map +1 -1
  226. package/dist/esm/event-bus/implementations/derivables/event-bus-settings.js +52 -0
  227. package/dist/esm/event-bus/implementations/derivables/event-bus-settings.js.map +1 -0
  228. package/dist/esm/event-bus/implementations/derivables/event-bus.js +76 -64
  229. package/dist/esm/event-bus/implementations/derivables/event-bus.js.map +1 -1
  230. package/dist/esm/serde/contracts/_module.js +4 -0
  231. package/dist/esm/serde/contracts/_module.js.map +1 -1
  232. package/dist/esm/serde/contracts/deserializer.contract.js +1 -0
  233. package/dist/esm/serde/contracts/deserializer.contract.js.map +1 -0
  234. package/dist/esm/serde/contracts/flexible-serde.contract.js +1 -0
  235. package/dist/esm/serde/contracts/flexible-serde.contract.js.map +1 -0
  236. package/dist/esm/serde/contracts/serializable.contract.js +1 -0
  237. package/dist/esm/serde/contracts/serializable.contract.js.map +1 -0
  238. package/dist/esm/serde/contracts/serializer.contract.js +1 -0
  239. package/dist/esm/serde/contracts/serializer.contract.js.map +1 -0
  240. package/dist/esm/serde/implementations/_module.js +1 -0
  241. package/dist/esm/serde/implementations/_module.js.map +1 -1
  242. package/dist/esm/serde/implementations/_shared/test-utilities/_module.js +1 -0
  243. package/dist/esm/serde/implementations/_shared/test-utilities/_module.js.map +1 -1
  244. package/dist/esm/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js +50 -0
  245. package/dist/esm/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.js.map +1 -0
  246. package/dist/esm/serde/implementations/_shared/test-utilities/serde.test-suite.js +35 -60
  247. package/dist/esm/serde/implementations/_shared/test-utilities/serde.test-suite.js.map +1 -1
  248. package/dist/esm/serde/implementations/no-op-serde/_module.js +2 -0
  249. package/dist/esm/serde/implementations/no-op-serde/_module.js.map +1 -0
  250. package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js +12 -0
  251. package/dist/esm/serde/implementations/no-op-serde/no-op-serde.js.map +1 -0
  252. package/dist/esm/serde/implementations/super-json-serde/super-json-serde.js +5 -2
  253. package/dist/esm/serde/implementations/super-json-serde/super-json-serde.js.map +1 -1
  254. package/dist/esm/utilities/contracts/_module.js +1 -0
  255. package/dist/esm/utilities/contracts/_module.js.map +1 -1
  256. package/dist/esm/utilities/contracts/buildable.contract.js +1 -0
  257. package/dist/esm/utilities/contracts/buildable.contract.js.map +1 -0
  258. package/dist/esm/utilities/errors.js +7 -7
  259. package/dist/esm/utilities/errors.js.map +1 -1
  260. package/dist/esm/utilities/functions.js +3 -0
  261. package/dist/esm/utilities/functions.js.map +1 -1
  262. package/dist/esm/utilities/time-span/time-span.js.map +1 -1
  263. package/dist/types/async/_module.d.ts +1 -1
  264. package/dist/types/async/backof-policies/_module.d.ts +1 -1
  265. package/dist/types/async/utilities/_module.d.ts +3 -0
  266. package/dist/types/async/utilities/lazy-promise/lazy-promise.d.ts +36 -46
  267. package/dist/types/cache/contracts/cache-factory.contract.d.ts +10 -23
  268. package/dist/types/cache/contracts/cache.contract.d.ts +365 -8
  269. package/dist/types/cache/contracts/cache.events.d.ts +156 -38
  270. package/dist/types/cache/implementations/_shared/_module.d.ts +1 -0
  271. package/dist/types/cache/implementations/_shared/cache-adapter.test-suite.d.ts +10 -8
  272. package/dist/types/cache/implementations/_shared/cache.test-suite.d.ts +15 -9
  273. package/dist/types/cache/implementations/adapters/kysely-sqlite-cache-adapter/kysely-sqlite-cache-adapter.d.ts +4 -3
  274. package/dist/types/cache/implementations/adapters/libsql-cache-adapter/_module.d.ts +2 -1
  275. package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter-settings.d.ts +48 -0
  276. package/dist/types/cache/implementations/adapters/libsql-cache-adapter/libsql-cache-adapter.d.ts +49 -37
  277. package/dist/types/cache/implementations/adapters/memory-cache-adapter/_module.d.ts +1 -0
  278. package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter-settings.d.ts +27 -0
  279. package/dist/types/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.d.ts +41 -17
  280. package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/_module.d.ts +2 -1
  281. package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter-settings.d.ts +51 -0
  282. package/dist/types/cache/implementations/adapters/mongodb-cache-adapter/mongodb-cache-adapter.d.ts +59 -45
  283. package/dist/types/cache/implementations/adapters/no-op-cache-adapter/no-op-cache-adapter.d.ts +1 -1
  284. package/dist/types/cache/implementations/adapters/redis-cache-adapter/_module.d.ts +1 -0
  285. package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter-settings.d.ts +32 -0
  286. package/dist/types/cache/implementations/adapters/redis-cache-adapter/redis-cache-adapter.d.ts +41 -26
  287. package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/_module.d.ts +1 -0
  288. package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter-settings.d.ts +48 -0
  289. package/dist/types/cache/implementations/adapters/sqlite-cache-adapter/sqlite-cache-adapter.d.ts +49 -37
  290. package/dist/types/cache/implementations/derivables/_module.d.ts +3 -1
  291. package/dist/types/cache/implementations/derivables/cache-factory-settings.d.ts +77 -0
  292. package/dist/types/cache/implementations/derivables/cache-factory.d.ts +59 -39
  293. package/dist/types/cache/implementations/derivables/cache-settings.d.ts +68 -0
  294. package/dist/types/cache/implementations/derivables/cache.d.ts +65 -36
  295. package/dist/types/collection/contracts/async-collection.contract.d.ts +1247 -666
  296. package/dist/types/collection/contracts/collection.contract.d.ts +1195 -638
  297. package/dist/types/collection/implementations/async-iterable-collection/_shared/async-retry-iterable.d.ts +1 -1
  298. package/dist/types/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +190 -4
  299. package/dist/types/collection/implementations/iterable-collection/iterable-collection.d.ts +138 -1
  300. package/dist/types/collection/implementations/list-collection/list-collection.d.ts +138 -1
  301. package/dist/types/event-bus/contracts/_module.d.ts +2 -2
  302. package/dist/types/event-bus/contracts/_shared.d.ts +11 -0
  303. package/dist/types/event-bus/contracts/event-bus-adapter.contract.d.ts +4 -6
  304. package/dist/types/event-bus/contracts/event-bus-factory.contract.d.ts +37 -31
  305. package/dist/types/event-bus/contracts/event-bus.contract.d.ts +24 -32
  306. package/dist/types/event-bus/implementations/_shared/event-bus-adapter.test-suite.d.ts +6 -3
  307. package/dist/types/event-bus/implementations/_shared/event-bus.test-suite.d.ts +10 -7
  308. package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/_module.d.ts +2 -1
  309. package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter-settings.d.ts +28 -0
  310. package/dist/types/event-bus/implementations/adapters/memory-event-bus-adapter/memory-event-bus-adapter.d.ts +48 -22
  311. package/dist/types/event-bus/implementations/adapters/no-op-event-bus-adapter/no-op-event-bus-adapter.d.ts +4 -4
  312. package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/_module.d.ts +2 -1
  313. package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter-settings.d.ts +36 -0
  314. package/dist/types/event-bus/implementations/adapters/redis-pub-sub-event-bus-adapter/redis-pub-sub-event-bus-adapter.d.ts +43 -31
  315. package/dist/types/event-bus/implementations/derivables/_module.d.ts +3 -1
  316. package/dist/types/event-bus/implementations/derivables/event-bus-factory-settings.d.ts +70 -0
  317. package/dist/types/event-bus/implementations/derivables/event-bus-factory.d.ts +39 -22
  318. package/dist/types/event-bus/implementations/derivables/event-bus-settings.d.ts +58 -0
  319. package/dist/types/event-bus/implementations/derivables/event-bus.d.ts +34 -22
  320. package/dist/types/serde/contracts/_module.d.ts +4 -0
  321. package/dist/types/serde/contracts/deserializer.contract.d.ts +13 -0
  322. package/dist/types/serde/contracts/flexible-serde.contract.d.ts +56 -0
  323. package/dist/types/serde/contracts/serde.contract.d.ts +5 -36
  324. package/dist/types/serde/contracts/serializable.contract.d.ts +10 -0
  325. package/dist/types/serde/contracts/serializer.contract.d.ts +10 -0
  326. package/dist/types/serde/implementations/_module.d.ts +1 -0
  327. package/dist/types/serde/implementations/_shared/test-utilities/_module.d.ts +1 -0
  328. package/dist/types/serde/implementations/_shared/test-utilities/flexible-serde.test-suite.d.ts +17 -0
  329. package/dist/types/serde/implementations/_shared/test-utilities/serde.test-suite.d.ts +2 -3
  330. package/dist/types/serde/implementations/no-op-serde/_module.d.ts +1 -0
  331. package/dist/types/serde/implementations/no-op-serde/no-op-serde.d.ts +13 -0
  332. package/dist/types/serde/implementations/super-json-serde/super-json-serde.d.ts +1 -1
  333. package/dist/types/utilities/contracts/_module.d.ts +1 -0
  334. package/dist/types/utilities/contracts/buildable.contract.d.ts +9 -0
  335. package/dist/types/utilities/errors.d.ts +3 -3
  336. package/dist/types/utilities/functions.d.ts +4 -0
  337. package/dist/types/utilities/time-span/time-span.d.ts +2 -2
  338. package/dist/types/utilities/types.d.ts +0 -1
  339. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module Cache
3
3
  */
4
- import type { IListenable } from "../../event-bus/contracts/_module";
4
+ import type { IEventListener } from "../../event-bus/contracts/_module";
5
5
  import type { OneOrMore } from "../../utilities/_module";
6
6
  import { type AsyncLazyable, type GetOrAddValue } from "../../utilities/_module";
7
7
  import type { CacheEvents } from "../../cache/contracts/_module";
@@ -11,7 +11,7 @@ import type { LazyPromise } from "../../async/_module";
11
11
  * The <i>ICacheListenable</i> contract defines a way for listening <i>{@link ICache}</i> crud operations.
12
12
  * @group Contracts
13
13
  */
14
- export type ICacheListenable<TType = unknown> = IListenable<CacheEvents<TType>>;
14
+ export type ICacheListener<TType = unknown> = IEventListener<CacheEvents<TType>>;
15
15
  /**
16
16
  * @group Contracts
17
17
  */
@@ -27,86 +27,404 @@ export type WithTtlValue<TType> = {
27
27
  * It commes with more convient methods compared to <i>ICacheAdapter</i>.
28
28
  * @group Contracts
29
29
  */
30
- export type ICache<TType = unknown> = ICacheListenable & {
30
+ export type ICache<TType = unknown> = ICacheListener & {
31
31
  /**
32
32
  * The <i>exists</i> method returns true when <i>key</i> is found otherwise false will be returned.
33
+ * @example
34
+ * ```ts
35
+ * import type { ICache } from "@daiso-tech/core";
36
+ *
37
+ * // Asume the inputed cache is empty
38
+ * async function main(cache: ICache): Promise<void> {
39
+ * await cache.exists("a");
40
+ * // false
41
+ * }
42
+ * ```
33
43
  */
34
44
  exists(key: string): LazyPromise<boolean>;
35
45
  /**
36
46
  * The <i>existsMany</i> method returns true for the <i>keys</i> that are found otherwise false will be returned.
47
+ * @example
48
+ * ```ts
49
+ * import type { ICache } from "@daiso-tech/core";
50
+ *
51
+ * // Asume the inputed cache is empty
52
+ * async function main(cache: ICache): Promise<void> {
53
+ * await cache.existsMany(["a", "b"]);
54
+ * // { a: false, b: false }
55
+ * }
56
+ * ```
37
57
  */
38
58
  existsMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
39
59
  /**
40
60
  * The <i>missing</i> method returns true when <i>key</i> is not found otherwise false will be returned.
61
+ * @example
62
+ * ```ts
63
+ * import type { ICache } from "@daiso-tech/core";
64
+ *
65
+ * // Asume the inputed cache is empty
66
+ * async function main(cache: ICache): Promise<void> {
67
+ * await cache.exists("a");
68
+ * // true
69
+ * }
70
+ * ```
41
71
  */
42
72
  missing(key: string): LazyPromise<boolean>;
43
73
  /**
44
74
  * The <i>missingMany</i> method returns true for the <i>keys</i> that are not found otherwise false will be returned.
75
+ * @example
76
+ * ```ts
77
+ * import type { ICache } from "@daiso-tech/core";
78
+ *
79
+ * // Asume the inputed cache is empty
80
+ * async function main(cache: ICache): Promise<void> {
81
+ * await cache.existsMany(["a", "b"]);
82
+ * // { a: true, b: true }
83
+ * }
84
+ * ```
45
85
  */
46
86
  missingMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
47
87
  /**
48
88
  * The <i>get</i> method returns the value when <i>key</i> is found otherwise null will be returned.
89
+ * @example
90
+ * ```ts
91
+ * import type { ICache } from "@daiso-tech/core";
92
+ *
93
+ * // Asume the inputed cache is empty
94
+ * async function main(cache: ICache): Promise<void> {
95
+ * await cache.get("a");
96
+ * // null
97
+ * }
98
+ * ```
49
99
  */
50
100
  get(key: string): LazyPromise<TType | null>;
51
101
  /**
52
102
  * The <i>getMany</i> returns the value for the <i>keys</i> that are found otherwise null will be returned.
103
+ * @example
104
+ * ```ts
105
+ * import type { ICache } from "@daiso-tech/core";
106
+ *
107
+ * // Asume the inputed cache is empty
108
+ * async function main(cache: ICache): Promise<void> {
109
+ * await cache.getMany(["a", "b"]);
110
+ * // { a: null, b: null }
111
+ * }
112
+ * ```
53
113
  */
54
114
  getMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, TType | null>>;
55
115
  /**
56
116
  * The <i>getOr</i> method returns the value when <i>key</i> is found otherwise <i>defaultValue</i> will be returned.
117
+ * @example
118
+ * ```ts
119
+ * import type { ICache } from "@daiso-tech/core";
120
+ *
121
+ * // Asume the inputed cache is empty
122
+ * async function main(cache: ICache): Promise<void> {
123
+ * await cache.getOr("a", -1);
124
+ * // -1
125
+ * }
126
+ * ```
57
127
  */
58
128
  getOr(key: string, defaultValue: AsyncLazyable<TType>): LazyPromise<TType>;
59
129
  /**
60
130
  * The <i>getOrMany</i> method returns the value for the keys that are found otherwise defaultValue will be returned.
131
+ * @example
132
+ * ```ts
133
+ * import type { ICache } from "@daiso-tech/core";
134
+ *
135
+ * // Asume the inputed cache is empty
136
+ * async function main(cache: ICache): Promise<void> {
137
+ * await cache.getOrMany({ a: -1, b: () => -2, c: async () => -3 });
138
+ * // { a: -1, b: -2, c: -3 }
139
+ * }
140
+ * ```
61
141
  */
62
142
  getOrMany<TKeys extends string>(keysWithDefaults: Record<TKeys, AsyncLazyable<TType>>): LazyPromise<Record<TKeys, TType>>;
63
143
  /**
64
144
  * The <i>getOrFail</i> method returns the value when <i>key</i> is found otherwise an error will be thrown.
65
145
  * @throws {KeyNotFoundCacheError} {@link KeyNotFoundCacheError}
146
+ * @example
147
+ * ```ts
148
+ * import type { ICache } from "@daiso-tech/core";
149
+ *
150
+ * // Asume the inputed cache is empty
151
+ * async function main(cache: ICache): Promise<void> {
152
+ * await cache.getOrFail("a");
153
+ * // An error will be thrown
154
+ * }
155
+ * ```
66
156
  */
67
157
  getOrFail(key: string): LazyPromise<TType>;
68
158
  /**
69
159
  * The <i>add</i> method adds a <i>key</i> with given <i>value</i> when key doesn't exists. Returns true when key doesn't exists otherwise false will be returned.
70
160
  * You can provide a <i>ttl</i> value. If null is passed, the item will not expire.
161
+ * @example
162
+ * ```ts
163
+ * import type { ICache } from "@daiso-tech/core";
164
+ *
165
+ * // Asume the inputed cache is empty
166
+ * async function main(cache: ICache): Promise<void> {
167
+ * await cache.add("a", 1);
168
+ * // true
169
+ *
170
+ * await cache.add("a", 2);
171
+ * // false
172
+ *
173
+ * await cache.get("a");
174
+ * // 1
175
+ * }
176
+ * ```
177
+ * @example
178
+ * ```ts
179
+ * import { type ICache, TimeSpan, delay } from "@daiso-tech/core";
180
+ *
181
+ * // Asume the inputed cache is empty
182
+ * async function main(cache: ICache): Promise<void> {
183
+ * const ttl = TimeSpan.fromSeconds(1);
184
+ *
185
+ * await cache.add("a", 1, ttl);
186
+ * // true
187
+ *
188
+ * await delay(ttl)
189
+ *
190
+ * await cache.add("a", 2);
191
+ * // true
192
+ *
193
+ * await cache.get("a");
194
+ * // 2
195
+ * }
196
+ * ```
71
197
  */
72
198
  add(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
73
199
  /**
74
200
  * The <i>addMany</i> method adds new keys. Returns true for the keys that where added otherwise false will be returned.
201
+ * @example
202
+ * ```ts
203
+ * import type { ICache } from "@daiso-tech/core";
204
+ *
205
+ * // Asume the inputed cache is empty
206
+ * async function main(cache: ICache): Promise<void> {
207
+ * await cache.addMany({ a: { value: 1 } });
208
+ * // { a: true }
209
+ *
210
+ * await cache.addMany({ a: { value: 2 } });
211
+ * // { a: false }
212
+ *
213
+ * await cache.get("a");
214
+ * // 1
215
+ * }
216
+ * ```
217
+ * @example
218
+ * ```ts
219
+ * import { type ICache, TimeSpan, delay } from "@daiso-tech/core";
220
+ *
221
+ * // Asume the inputed cache is empty
222
+ * async function main(cache: ICache): Promise<void> {
223
+ * const ttl = TimeSpan.fromSeconds(1);
224
+ *
225
+ * await cache.addMany({ a: { value: 1, ttl } });
226
+ * // { a: true }
227
+ *
228
+ * await delay(ttl)
229
+ *
230
+ * await cache.addMany({ a: { value: 2 } });
231
+ * // { a: true }
232
+ *
233
+ * await cache.get("a");
234
+ * // 2
235
+ * }
236
+ * ```
75
237
  */
76
238
  addMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
77
239
  /**
78
240
  * The <i>update</i> method updates the given <i>key</i> with given <i>value</i>. Returns true when key otherwise false will be returned.
241
+ * @example
242
+ * ```ts
243
+ * import type { ICache } from "@daiso-tech/core";
244
+ *
245
+ * // Asume the inputed cache is empty
246
+ * async function main(cache: ICache): Promise<void> {
247
+ * await cache.update("a", 1);
248
+ * // false
249
+ *
250
+ * await cache.add("a", 1);
251
+ *
252
+ *
253
+ * await cache.update("a", 2);
254
+ * // true
255
+ *
256
+ * await cache.get("a");
257
+ * // 2
258
+ * }
259
+ * ```
79
260
  */
80
261
  update(key: string, value: TType): LazyPromise<boolean>;
81
262
  /**
82
263
  * The <i>updateMany</i> method updates the given keys. Returns true for the keys that where updated otherwise false will be returned.
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * import type { ICache } from "@daiso-tech/core";
268
+ *
269
+ * // Asume the inputed cache is empty
270
+ * async function main(cache: ICache): Promise<void> {
271
+ * await cache.updateMany({ a: 1 });
272
+ * // false
273
+ *
274
+ * await cache.add("a", 1);
275
+ *
276
+ * await cache.updateMany({ a: 2 });
277
+ * // true
278
+ *
279
+ * await cache.get("a");
280
+ * // 2
281
+ * }
282
+ * ```
83
283
  */
84
284
  updateMany<TKeys extends string>(values: Record<TKeys, TType>): LazyPromise<Record<TKeys, boolean>>;
85
285
  /**
86
286
  * The <i>put</i> method replaces a <i>key</i> if the <i>key</i> exists including the ttl value or adds <i>key</i> that do not exists with a given <i>ttl</i>.
87
287
  * Returns true if the <i>key</i> where replaced otherwise false is returned.
88
- * You must provide a <i>ttl</i> value. If null is passed, the item will not expire.
288
+ * You can provide a <i>ttl</i> value for the replaced key. If <i>null</i> is passed, the item will not expires and <i>null</i> is the default value.
289
+ * @example
290
+ * ```ts
291
+ * import { type ICache, TimeSpan, delay } from "@daiso-tech/core";
292
+ *
293
+ * // Asume the inputed cache is empty
294
+ * async function main(cache: ICache): Promise<void> {
295
+ * await cache.put("a", 1);
296
+ * // false
297
+ *
298
+ * const ttl = TimeSpan.fromSeconds(1);
299
+ * await cache.put("a", 2, ttl);
300
+ * // true
301
+ *
302
+ * await cache.get("a");
303
+ * // 2
304
+ *
305
+ * await delay(ttl);
306
+ * await cache.get("a");
307
+ * // null
308
+ * }
309
+ * ```
89
310
  */
90
311
  put(key: string, value: TType, ttl?: TimeSpan | null): LazyPromise<boolean>;
91
312
  /**
92
313
  * The <i>putMany</i> method replaces the keys that exists including their ttl values or adds keys that do not exists.
93
314
  * Returns true for all the keys that where replaced otherwise false is returned.
315
+ * @example
316
+ * ```ts
317
+ * import { type ICache, TimeSpan, delay } from "@daiso-tech/core";
318
+ *
319
+ * // Asume the inputed cache is empty
320
+ * async function main(cache: ICache): Promise<void> {
321
+ * await cache.putMany({ a: { value: 1 } });
322
+ * // { a: false }
323
+ *
324
+ * const ttl = TimeSpan.fromSeconds(1);
325
+ * await cache.put({ a: { value: 2, ttl } });
326
+ * // { a: true }
327
+ *
328
+ * await cache.get("a");
329
+ * // 2
330
+ *
331
+ * await delay(ttl);
332
+ * await cache.get("a");
333
+ * // null
334
+ * }
335
+ * ```
94
336
  */
95
337
  putMany<TKeys extends string>(values: Record<TKeys, WithTtlValue<TType>>): LazyPromise<Record<TKeys, boolean>>;
96
338
  /**
97
339
  * The <i>remove</i> method removes the given <i>key</i> when found. Returns true if the key is found otherwise false is returned.
340
+ * @example
341
+ * ```ts
342
+ * import type { ICache } from "@daiso-tech/core";
343
+ *
344
+ * // Asume the inputed cache is empty
345
+ * async function main(cache: ICache): Promise<void> {
346
+ * await cache.remove("a");
347
+ * // false
348
+ * }
349
+ * ```
350
+ * @example
351
+ * ```ts
352
+ * import type { ICache } from "@daiso-tech/core";
353
+ *
354
+ * // Asume the inputed cache is empty
355
+ * async function main(cache: ICache): Promise<void> {
356
+ * await cache.put("a", 1);
357
+ *
358
+ * await cache.remove("a");
359
+ * // true
360
+ * }
361
+ * ```
98
362
  */
99
363
  remove(key: string): LazyPromise<boolean>;
100
364
  /**
101
365
  * The <i>removeMany</i> method removes keys. Returns true for the keys that are removed otherwise false is returned.
366
+ * @example
367
+ * ```ts
368
+ * import type { ICache } from "@daiso-tech/core";
369
+ *
370
+ * // Asume the inputed cache is empty
371
+ * async function main(cache: ICache): Promise<void> {
372
+ * await cache.removeMany(["a"]);
373
+ * // false
374
+ * }
375
+ * ```
376
+ * @example
377
+ * ```ts
378
+ * import type { ICache } from "@daiso-tech/core";
379
+ *
380
+ * // Asume the inputed cache is empty
381
+ * async function main(cache: ICache): Promise<void> {
382
+ * await cache.put("a", 1);
383
+ *
384
+ * await cache.removeMany(["a"]);
385
+ * // { a: true }
386
+ * }
387
+ * ```
102
388
  */
103
389
  removeMany<TKeys extends string>(keys: TKeys[]): LazyPromise<Record<TKeys, boolean>>;
104
390
  /**
105
391
  * The <i>getAndRemove</i> method removes the given <i>key</i> and returns it when found otherwise null will be returned.
392
+ * @example
393
+ * ```ts
394
+ * import type { ICache } from "@daiso-tech/core";
395
+ *
396
+ * // Asume the inputed cache is empty
397
+ * async function main(cache: ICache): Promise<void> {
398
+ * await cache.getAndRemove("a");
399
+ * // null
400
+ *
401
+ * await cache.put("a", 1)
402
+ *
403
+ * await cache.getAndRemove("a");
404
+ * // "a"
405
+ *
406
+ * await cache.get("a");
407
+ * // null
408
+ * }
409
+ * ```
106
410
  */
107
411
  getAndRemove(key: string): LazyPromise<TType | null>;
108
412
  /**
109
413
  * The <i>getOrAdd</i> method will retrieve the given <i>key</i> if found otherwise <i>valueToAdd</i> will be added and returned.
414
+ * The <i>valueToAdd<i> can be async or sync function.
415
+ * @example
416
+ * ```ts
417
+ * import type { ICache } from "@daiso-tech/core";
418
+ *
419
+ * // Asume the inputed cache is empty
420
+ * async function main(cache: ICache): Promise<void> {
421
+ * await cache.getOrAdd("a", 1);
422
+ * // 1
423
+ *
424
+ * await cache.getOrAdd("a", async () => -1);
425
+ * // 1
426
+ * }
427
+ * ```
110
428
  */
111
429
  getOrAdd(key: string, valueToAdd: AsyncLazyable<GetOrAddValue<TType>>, ttl?: TimeSpan | null): LazyPromise<TType>;
112
430
  /**
@@ -114,6 +432,24 @@ export type ICache<TType = unknown> = ICacheListenable & {
114
432
  * Returns true if key is incremented otherwise false will be returned.
115
433
  * An error will thrown if the key is not a number.
116
434
  * @throws {TypeCacheError} {@link TypeCacheError}
435
+ * @example
436
+ * ```ts
437
+ * import type { ICache } from "@daiso-tech/core";
438
+ *
439
+ * // Asume the inputed cache is empty
440
+ * async function main(cache: ICache): Promise<void> {
441
+ * await cache.increment("a", 1);
442
+ * // false
443
+ *
444
+ * await cache.put("a", 1);
445
+ *
446
+ * await cache.increment("a", 1);
447
+ * // true
448
+ *
449
+ * await cache.get("a");
450
+ * // 2
451
+ * }
452
+ * ```
117
453
  */
118
454
  increment(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
119
455
  /**
@@ -121,7 +457,24 @@ export type ICache<TType = unknown> = ICacheListenable & {
121
457
  * Returns true if key exists otherwise false will be returned.
122
458
  * An error will thrown if the key is not a number.
123
459
  * @throws {TypeCacheError} {@link TypeCacheError}
124
- * An error will thrown if the key is not a number.
460
+ * @example
461
+ * ```ts
462
+ * import type { ICache } from "@daiso-tech/core";
463
+ *
464
+ * // Asume the inputed cache is empty
465
+ * async function main(cache: ICache): Promise<void> {
466
+ * await cache.decrement("a", 1);
467
+ * // false
468
+ *
469
+ * await cache.put("a", 1);
470
+ *
471
+ * await cache.decrement("a", 1);
472
+ * // true
473
+ *
474
+ * await cache.get("a");
475
+ * // 0
476
+ * }
477
+ * ```
125
478
  */
126
479
  decrement(key: string, value?: Extract<TType, number>): LazyPromise<boolean>;
127
480
  /**
@@ -134,8 +487,8 @@ export type ICache<TType = unknown> = ICacheListenable & {
134
487
  * ```ts
135
488
  * import type { ICache } from "@daiso-tech/core";
136
489
  *
137
- * async function main(cache: ICache) {
138
- * // Will be "@global"
490
+ * // Asume the inputed cache is empty and the default rootGroup is "@global"
491
+ * async function main(cache: ICache): Promise<void> {
139
492
  * console.log(cache.getGroup())
140
493
  *
141
494
  * const cacheA = cache.withGroup("a");
@@ -159,8 +512,9 @@ export type IGroupableCache<TType = unknown> = ICache<TType> & {
159
512
  * This useful for multitennat applications.
160
513
  * @example
161
514
  * ```ts
162
- * import { type ICache } from "@daiso-tech/core";
515
+ * import type { ICache } from "@daiso-tech/core";
163
516
  *
517
+ * // Asume the inputed cache is empty and the default rootGroup is "@global"
164
518
  * async function main(cache: ICache): Promise<void> {
165
519
  * const cacheA = cache.withGroup("a");
166
520
  * await cacheA.add("a", 1);
@@ -170,6 +524,9 @@ export type IGroupableCache<TType = unknown> = ICache<TType> & {
170
524
  *
171
525
  * // Will print { a: 1, b: null }
172
526
  * console.log(await cacheA.getMany(["a", "b"]));
527
+ *
528
+ * // Will print { a: nullp, b: 2 }
529
+ * console.log(await cacheB.getMany(["a", "b"]));
173
530
  * }
174
531
  * ```
175
532
  */