@fgv/ts-utils 5.1.0-4 → 5.1.0-40

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 (303) hide show
  1. package/README.md +21 -0
  2. package/dist/index.js +2 -2
  3. package/dist/index.js.map +1 -0
  4. package/dist/packlets/base/brand.js.map +1 -0
  5. package/dist/packlets/base/index.js +2 -0
  6. package/dist/packlets/base/index.js.map +1 -0
  7. package/dist/packlets/base/mapResults.js.map +1 -0
  8. package/dist/packlets/base/messageAggregator.js.map +1 -0
  9. package/dist/packlets/base/normalize.js +54 -1
  10. package/dist/packlets/base/normalize.js.map +1 -0
  11. package/dist/packlets/base/result.js +326 -2
  12. package/dist/packlets/base/result.js.map +1 -0
  13. package/dist/packlets/base/shouldNotFail.js +123 -0
  14. package/dist/packlets/base/shouldNotFail.js.map +1 -0
  15. package/dist/packlets/base/utils.js.map +1 -0
  16. package/dist/packlets/base/uuid.js +55 -0
  17. package/dist/packlets/base/uuid.js.map +1 -0
  18. package/dist/packlets/collections/aggregatedResultMap.js.map +1 -0
  19. package/dist/packlets/collections/collectible.js.map +1 -0
  20. package/dist/packlets/collections/collector.js +23 -9
  21. package/dist/packlets/collections/collector.js.map +1 -0
  22. package/dist/packlets/collections/collectorValidator.js +6 -1
  23. package/dist/packlets/collections/collectorValidator.js.map +1 -0
  24. package/dist/packlets/collections/common.js.map +1 -0
  25. package/dist/packlets/collections/converters.js.map +1 -0
  26. package/dist/packlets/collections/convertingCollector.js.map +1 -0
  27. package/dist/packlets/collections/convertingCollectorValidator.js.map +1 -0
  28. package/dist/packlets/collections/convertingResultMap.js.map +1 -0
  29. package/dist/packlets/collections/index.js +1 -0
  30. package/dist/packlets/collections/index.js.map +1 -0
  31. package/dist/packlets/collections/keyValueConverters.js.map +1 -0
  32. package/dist/packlets/collections/readOnlyConvertingResultMap.js +18 -0
  33. package/dist/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
  34. package/dist/packlets/collections/readonlyResultMap.js.map +1 -0
  35. package/dist/packlets/collections/resultMap.js.map +1 -0
  36. package/dist/packlets/collections/resultMapValidator.js.map +1 -0
  37. package/dist/packlets/collections/retainingRingBuffer.js +159 -0
  38. package/dist/packlets/collections/retainingRingBuffer.js.map +1 -0
  39. package/dist/packlets/collections/utils.js.map +1 -0
  40. package/dist/packlets/collections/validatingCollector.js.map +1 -0
  41. package/dist/packlets/collections/validatingConvertingCollector.js.map +1 -0
  42. package/dist/packlets/collections/validatingConvertingResultMap.js.map +1 -0
  43. package/dist/packlets/collections/validatingResultMap.js.map +1 -0
  44. package/dist/packlets/conversion/advancedConverters.js.map +1 -0
  45. package/dist/packlets/conversion/baseConverter.js +107 -18
  46. package/dist/packlets/conversion/baseConverter.js.map +1 -0
  47. package/dist/packlets/conversion/basicConverters.js +24 -5
  48. package/dist/packlets/conversion/basicConverters.js.map +1 -0
  49. package/dist/packlets/conversion/converter.js +11 -1
  50. package/dist/packlets/conversion/converter.js.map +1 -0
  51. package/dist/packlets/conversion/converters.js.map +1 -0
  52. package/dist/packlets/conversion/defaultingConverter.js.map +1 -0
  53. package/dist/packlets/conversion/index.js.map +1 -0
  54. package/dist/packlets/conversion/objectConverter.js.map +1 -0
  55. package/dist/packlets/conversion/stringConverter.js.map +1 -0
  56. package/dist/packlets/hash/crcNormalizer.js.map +1 -0
  57. package/dist/packlets/hash/hashingNormalizer.js.map +1 -0
  58. package/dist/packlets/hash/index.js.map +1 -0
  59. package/dist/packlets/logging/bootLogger.js.map +1 -0
  60. package/dist/packlets/logging/index.js +2 -0
  61. package/dist/packlets/logging/index.js.map +1 -0
  62. package/dist/packlets/logging/logReporter.js.map +1 -0
  63. package/dist/packlets/logging/logger.js +51 -18
  64. package/dist/packlets/logging/logger.js.map +1 -0
  65. package/dist/packlets/logging/multiLogger.js +104 -0
  66. package/dist/packlets/logging/multiLogger.js.map +1 -0
  67. package/dist/packlets/logging/retainingLogger.js +114 -0
  68. package/dist/packlets/logging/retainingLogger.js.map +1 -0
  69. package/dist/packlets/logging-interface/index.js +28 -0
  70. package/dist/packlets/logging-interface/index.js.map +1 -0
  71. package/dist/packlets/validation/array.js.map +1 -0
  72. package/dist/packlets/validation/boolean.js.map +1 -0
  73. package/dist/packlets/validation/classes.js.map +1 -0
  74. package/dist/packlets/validation/common.js.map +1 -0
  75. package/dist/packlets/validation/compositeId.js.map +1 -0
  76. package/dist/packlets/validation/field.js.map +1 -0
  77. package/dist/packlets/validation/genericValidator.js.map +1 -0
  78. package/dist/packlets/validation/index.js.map +1 -0
  79. package/dist/packlets/validation/number.js.map +1 -0
  80. package/dist/packlets/validation/object.js.map +1 -0
  81. package/dist/packlets/validation/oneOf.js.map +1 -0
  82. package/dist/packlets/validation/string.js.map +1 -0
  83. package/dist/packlets/validation/traits.js.map +1 -0
  84. package/dist/packlets/validation/typeGuard.js.map +1 -0
  85. package/dist/packlets/validation/validator.js.map +1 -0
  86. package/dist/packlets/validation/validatorBase.js.map +1 -0
  87. package/dist/packlets/validation/validators.js.map +1 -0
  88. package/dist/ts-utils.d.ts +1089 -59
  89. package/dist/tsdoc-metadata.json +1 -1
  90. package/lib/index.d.ts +2 -2
  91. package/lib/index.d.ts.map +1 -0
  92. package/lib/index.js +2 -1
  93. package/lib/index.js.map +1 -0
  94. package/lib/packlets/base/brand.d.ts.map +1 -0
  95. package/lib/packlets/base/brand.js.map +1 -0
  96. package/lib/packlets/base/index.d.ts +2 -0
  97. package/lib/packlets/base/index.d.ts.map +1 -0
  98. package/lib/packlets/base/index.js +2 -0
  99. package/lib/packlets/base/index.js.map +1 -0
  100. package/lib/packlets/base/mapResults.d.ts.map +1 -0
  101. package/lib/packlets/base/mapResults.js.map +1 -0
  102. package/lib/packlets/base/messageAggregator.d.ts.map +1 -0
  103. package/lib/packlets/base/messageAggregator.js.map +1 -0
  104. package/lib/packlets/base/normalize.d.ts +24 -0
  105. package/lib/packlets/base/normalize.d.ts.map +1 -0
  106. package/lib/packlets/base/normalize.js +53 -0
  107. package/lib/packlets/base/normalize.js.map +1 -0
  108. package/lib/packlets/base/result.d.ts +295 -1
  109. package/lib/packlets/base/result.d.ts.map +1 -0
  110. package/lib/packlets/base/result.js +330 -3
  111. package/lib/packlets/base/result.js.map +1 -0
  112. package/lib/packlets/base/shouldNotFail.d.ts +53 -0
  113. package/lib/packlets/base/shouldNotFail.d.ts.map +1 -0
  114. package/lib/packlets/base/shouldNotFail.js +129 -0
  115. package/lib/packlets/base/shouldNotFail.js.map +1 -0
  116. package/lib/packlets/base/utils.d.ts +12 -0
  117. package/lib/packlets/base/utils.d.ts.map +1 -0
  118. package/lib/packlets/base/utils.js.map +1 -0
  119. package/lib/packlets/base/uuid.d.ts +27 -0
  120. package/lib/packlets/base/uuid.d.ts.map +1 -0
  121. package/lib/packlets/base/uuid.js +59 -0
  122. package/lib/packlets/base/uuid.js.map +1 -0
  123. package/lib/packlets/collections/aggregatedResultMap.d.ts.map +1 -0
  124. package/lib/packlets/collections/aggregatedResultMap.js.map +1 -0
  125. package/lib/packlets/collections/collectible.d.ts.map +1 -0
  126. package/lib/packlets/collections/collectible.js.map +1 -0
  127. package/lib/packlets/collections/collector.d.ts +23 -9
  128. package/lib/packlets/collections/collector.d.ts.map +1 -0
  129. package/lib/packlets/collections/collector.js +23 -9
  130. package/lib/packlets/collections/collector.js.map +1 -0
  131. package/lib/packlets/collections/collectorValidator.d.ts +29 -5
  132. package/lib/packlets/collections/collectorValidator.d.ts.map +1 -0
  133. package/lib/packlets/collections/collectorValidator.js +6 -1
  134. package/lib/packlets/collections/collectorValidator.js.map +1 -0
  135. package/lib/packlets/collections/common.d.ts.map +1 -0
  136. package/lib/packlets/collections/common.js.map +1 -0
  137. package/lib/packlets/collections/converters.d.ts.map +1 -0
  138. package/lib/packlets/collections/converters.js.map +1 -0
  139. package/lib/packlets/collections/convertingCollector.d.ts +21 -3
  140. package/lib/packlets/collections/convertingCollector.d.ts.map +1 -0
  141. package/lib/packlets/collections/convertingCollector.js.map +1 -0
  142. package/lib/packlets/collections/convertingCollectorValidator.d.ts +22 -3
  143. package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +1 -0
  144. package/lib/packlets/collections/convertingCollectorValidator.js.map +1 -0
  145. package/lib/packlets/collections/convertingResultMap.d.ts.map +1 -0
  146. package/lib/packlets/collections/convertingResultMap.js.map +1 -0
  147. package/lib/packlets/collections/index.d.ts +1 -0
  148. package/lib/packlets/collections/index.d.ts.map +1 -0
  149. package/lib/packlets/collections/index.js +1 -0
  150. package/lib/packlets/collections/index.js.map +1 -0
  151. package/lib/packlets/collections/keyValueConverters.d.ts.map +1 -0
  152. package/lib/packlets/collections/keyValueConverters.js.map +1 -0
  153. package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts +13 -1
  154. package/lib/packlets/collections/readOnlyConvertingResultMap.d.ts.map +1 -0
  155. package/lib/packlets/collections/readOnlyConvertingResultMap.js +19 -1
  156. package/lib/packlets/collections/readOnlyConvertingResultMap.js.map +1 -0
  157. package/lib/packlets/collections/readonlyResultMap.d.ts +18 -7
  158. package/lib/packlets/collections/readonlyResultMap.d.ts.map +1 -0
  159. package/lib/packlets/collections/readonlyResultMap.js.map +1 -0
  160. package/lib/packlets/collections/resultMap.d.ts.map +1 -0
  161. package/lib/packlets/collections/resultMap.js.map +1 -0
  162. package/lib/packlets/collections/resultMapValidator.d.ts.map +1 -0
  163. package/lib/packlets/collections/resultMapValidator.js.map +1 -0
  164. package/lib/packlets/collections/retainingRingBuffer.d.ts +147 -0
  165. package/lib/packlets/collections/retainingRingBuffer.d.ts.map +1 -0
  166. package/lib/packlets/collections/retainingRingBuffer.js +163 -0
  167. package/lib/packlets/collections/retainingRingBuffer.js.map +1 -0
  168. package/lib/packlets/collections/utils.d.ts.map +1 -0
  169. package/lib/packlets/collections/utils.js.map +1 -0
  170. package/lib/packlets/collections/validatingCollector.d.ts +7 -3
  171. package/lib/packlets/collections/validatingCollector.d.ts.map +1 -0
  172. package/lib/packlets/collections/validatingCollector.js.map +1 -0
  173. package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +1 -0
  174. package/lib/packlets/collections/validatingConvertingCollector.js.map +1 -0
  175. package/lib/packlets/collections/validatingConvertingResultMap.d.ts.map +1 -0
  176. package/lib/packlets/collections/validatingConvertingResultMap.js.map +1 -0
  177. package/lib/packlets/collections/validatingResultMap.d.ts +2 -1
  178. package/lib/packlets/collections/validatingResultMap.d.ts.map +1 -0
  179. package/lib/packlets/collections/validatingResultMap.js.map +1 -0
  180. package/lib/packlets/conversion/advancedConverters.d.ts.map +1 -0
  181. package/lib/packlets/conversion/advancedConverters.js.map +1 -0
  182. package/lib/packlets/conversion/baseConverter.d.ts +108 -19
  183. package/lib/packlets/conversion/baseConverter.d.ts.map +1 -0
  184. package/lib/packlets/conversion/baseConverter.js +107 -18
  185. package/lib/packlets/conversion/baseConverter.js.map +1 -0
  186. package/lib/packlets/conversion/basicConverters.d.ts +14 -0
  187. package/lib/packlets/conversion/basicConverters.d.ts.map +1 -0
  188. package/lib/packlets/conversion/basicConverters.js +24 -5
  189. package/lib/packlets/conversion/basicConverters.js.map +1 -0
  190. package/lib/packlets/conversion/converter.d.ts +9 -1
  191. package/lib/packlets/conversion/converter.d.ts.map +1 -0
  192. package/lib/packlets/conversion/converter.js +12 -0
  193. package/lib/packlets/conversion/converter.js.map +1 -0
  194. package/lib/packlets/conversion/converters.d.ts.map +1 -0
  195. package/lib/packlets/conversion/converters.js.map +1 -0
  196. package/lib/packlets/conversion/defaultingConverter.d.ts.map +1 -0
  197. package/lib/packlets/conversion/defaultingConverter.js.map +1 -0
  198. package/lib/packlets/conversion/index.d.ts.map +1 -0
  199. package/lib/packlets/conversion/index.js.map +1 -0
  200. package/lib/packlets/conversion/objectConverter.d.ts.map +1 -0
  201. package/lib/packlets/conversion/objectConverter.js.map +1 -0
  202. package/lib/packlets/conversion/stringConverter.d.ts.map +1 -0
  203. package/lib/packlets/conversion/stringConverter.js.map +1 -0
  204. package/lib/packlets/hash/crcNormalizer.d.ts.map +1 -0
  205. package/lib/packlets/hash/crcNormalizer.js.map +1 -0
  206. package/lib/packlets/hash/hashingNormalizer.d.ts.map +1 -0
  207. package/lib/packlets/hash/hashingNormalizer.js.map +1 -0
  208. package/lib/packlets/hash/index.d.ts.map +1 -0
  209. package/lib/packlets/hash/index.js.map +1 -0
  210. package/lib/packlets/logging/bootLogger.d.ts.map +1 -0
  211. package/lib/packlets/logging/bootLogger.js.map +1 -0
  212. package/lib/packlets/logging/index.d.ts +2 -0
  213. package/lib/packlets/logging/index.d.ts.map +1 -0
  214. package/lib/packlets/logging/index.js +2 -0
  215. package/lib/packlets/logging/index.js.map +1 -0
  216. package/lib/packlets/logging/logReporter.d.ts.map +1 -0
  217. package/lib/packlets/logging/logReporter.js.map +1 -0
  218. package/lib/packlets/logging/logger.d.ts +25 -70
  219. package/lib/packlets/logging/logger.d.ts.map +1 -0
  220. package/lib/packlets/logging/logger.js +54 -20
  221. package/lib/packlets/logging/logger.js.map +1 -0
  222. package/lib/packlets/logging/multiLogger.d.ts +54 -0
  223. package/lib/packlets/logging/multiLogger.d.ts.map +1 -0
  224. package/lib/packlets/logging/multiLogger.js +108 -0
  225. package/lib/packlets/logging/multiLogger.js.map +1 -0
  226. package/lib/packlets/logging/retainingLogger.d.ts +123 -0
  227. package/lib/packlets/logging/retainingLogger.d.ts.map +1 -0
  228. package/lib/packlets/logging/retainingLogger.js +118 -0
  229. package/lib/packlets/logging/retainingLogger.js.map +1 -0
  230. package/lib/packlets/logging-interface/index.d.ts +98 -0
  231. package/lib/packlets/logging-interface/index.d.ts.map +1 -0
  232. package/lib/packlets/logging-interface/index.js +32 -0
  233. package/lib/packlets/logging-interface/index.js.map +1 -0
  234. package/lib/packlets/validation/array.d.ts.map +1 -0
  235. package/lib/packlets/validation/array.js.map +1 -0
  236. package/lib/packlets/validation/boolean.d.ts.map +1 -0
  237. package/lib/packlets/validation/boolean.js.map +1 -0
  238. package/lib/packlets/validation/classes.d.ts.map +1 -0
  239. package/lib/packlets/validation/classes.js.map +1 -0
  240. package/lib/packlets/validation/common.d.ts.map +1 -0
  241. package/lib/packlets/validation/common.js.map +1 -0
  242. package/lib/packlets/validation/compositeId.d.ts.map +1 -0
  243. package/lib/packlets/validation/compositeId.js.map +1 -0
  244. package/lib/packlets/validation/field.d.ts.map +1 -0
  245. package/lib/packlets/validation/field.js.map +1 -0
  246. package/lib/packlets/validation/genericValidator.d.ts.map +1 -0
  247. package/lib/packlets/validation/genericValidator.js.map +1 -0
  248. package/lib/packlets/validation/index.d.ts.map +1 -0
  249. package/lib/packlets/validation/index.js.map +1 -0
  250. package/lib/packlets/validation/number.d.ts.map +1 -0
  251. package/lib/packlets/validation/number.js.map +1 -0
  252. package/lib/packlets/validation/object.d.ts.map +1 -0
  253. package/lib/packlets/validation/object.js.map +1 -0
  254. package/lib/packlets/validation/oneOf.d.ts.map +1 -0
  255. package/lib/packlets/validation/oneOf.js.map +1 -0
  256. package/lib/packlets/validation/string.d.ts.map +1 -0
  257. package/lib/packlets/validation/string.js.map +1 -0
  258. package/lib/packlets/validation/traits.d.ts.map +1 -0
  259. package/lib/packlets/validation/traits.js.map +1 -0
  260. package/lib/packlets/validation/typeGuard.d.ts.map +1 -0
  261. package/lib/packlets/validation/typeGuard.js.map +1 -0
  262. package/lib/packlets/validation/validator.d.ts.map +1 -0
  263. package/lib/packlets/validation/validator.js.map +1 -0
  264. package/lib/packlets/validation/validatorBase.d.ts +2 -1
  265. package/lib/packlets/validation/validatorBase.d.ts.map +1 -0
  266. package/lib/packlets/validation/validatorBase.js.map +1 -0
  267. package/lib/packlets/validation/validators.d.ts.map +1 -0
  268. package/lib/packlets/validation/validators.js.map +1 -0
  269. package/package.json +3 -3
  270. package/dist/test/helpers/jest/helpers/fsHelpers.js +0 -139
  271. package/dist/test/helpers/jest/helpers/index.js +0 -2
  272. package/dist/test/helpers/jest/index.js +0 -17
  273. package/dist/test/helpers/jest/matchers/index.js +0 -14
  274. package/dist/test/helpers/jest/matchers/toFail/index.js +0 -23
  275. package/dist/test/helpers/jest/matchers/toFail/predicate.js +0 -5
  276. package/dist/test/helpers/jest/matchers/toFailTest/index.js +0 -28
  277. package/dist/test/helpers/jest/matchers/toFailTest/predicate.js +0 -8
  278. package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.js +0 -24
  279. package/dist/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.js +0 -11
  280. package/dist/test/helpers/jest/matchers/toFailTestWith/index.js +0 -29
  281. package/dist/test/helpers/jest/matchers/toFailTestWith/predicate.js +0 -26
  282. package/dist/test/helpers/jest/matchers/toFailWith/index.js +0 -27
  283. package/dist/test/helpers/jest/matchers/toFailWith/predicate.js +0 -16
  284. package/dist/test/helpers/jest/matchers/toFailWithDetail/index.js +0 -27
  285. package/dist/test/helpers/jest/matchers/toFailWithDetail/predicate.js +0 -22
  286. package/dist/test/helpers/jest/matchers/toSucceed/index.js +0 -23
  287. package/dist/test/helpers/jest/matchers/toSucceed/predicate.js +0 -5
  288. package/dist/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.js +0 -24
  289. package/dist/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.js +0 -24
  290. package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/index.js +0 -53
  291. package/dist/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.js +0 -17
  292. package/dist/test/helpers/jest/matchers/toSucceedWith/index.js +0 -27
  293. package/dist/test/helpers/jest/matchers/toSucceedWith/predicate.js +0 -12
  294. package/dist/test/helpers/jest/matchers/toSucceedWithDetail/index.js +0 -27
  295. package/dist/test/helpers/jest/matchers/toSucceedWithDetail/predicate.js +0 -17
  296. package/dist/test/helpers/jest/resolvers/cli.js +0 -10
  297. package/dist/test/helpers/jest/resolvers/ide.js +0 -10
  298. package/dist/test/helpers/jest/ts-utils.js +0 -2
  299. package/dist/test/helpers/jest/types/index.js +0 -3
  300. package/dist/test/helpers/jest/utils/matcherHelpers.js +0 -47
  301. package/dist/test/helpers/jest/utils/snapshotResolver.js +0 -11
  302. package/dist/test/unit/collections/helpers.js +0 -106
  303. package/dist/test/unit/hashTextEncodeCompat.js +0 -23
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/collector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,cAAc,EAEd,MAAM,EAIP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEpG;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,GAAG,eAAe,CAAC;AAE5E;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAEjC,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CACpC,SAAQ,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACxD;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpC;;;OAGG;IACH,aAAa,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B,CAE1C,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC;IAEpC,wDAAwD;IACxD,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,SAAS,CAEpB,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CACpC,YAAW,kBAAkB,CAAC,KAAK,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,C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AI,IAAI,gBAAgB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAItD;;;OAGG;IACI,MAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC;IAIxC;;;OAGG;IACI,aAAa,IAAI,aAAa,CAAC,KAAK,CAAC;IAI5C;;OAEG;IACI,UAAU,IAAI,kBAAkB,CAAC,KAAK,CAAC;IAI9C;;;OAGG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAIzF,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,SAAS,IAAI,KAAK;CAGhF"}
@@ -34,7 +34,7 @@ const base_1 = require("../base");
34
34
  */
35
35
  class Collector {
36
36
  /**
37
- * {@inheritDoc Collections.ResultMap.size}
37
+ * Returns the number of entries in the map.
38
38
  */
39
39
  get size() {
40
40
  return this._byIndex.length;
@@ -90,13 +90,16 @@ class Collector {
90
90
  return (0, base_1.succeedWithDetail)(item, 'added');
91
91
  }
92
92
  /**
93
- * {@inheritDoc Collections.ResultMap.entries}
93
+ * Returns an iterator over the map entries.
94
+ * @returns An iterator over the map entries.
94
95
  */
95
96
  entries() {
96
97
  return this._byKey.entries();
97
98
  }
98
99
  /**
99
- * {@inheritDoc Collections.ResultMap.forEach}
100
+ * Calls a function for each entry in the map.
101
+ * @param callback - The function to call for each entry.
102
+ * @param arg - An optional argument to pass to the callback.
100
103
  */
101
104
  forEach(callback, arg) {
102
105
  for (const [key, value] of this._byKey.entries()) {
@@ -104,14 +107,20 @@ class Collector {
104
107
  }
105
108
  }
106
109
  /**
107
- * {@inheritDoc Collections.ResultMap.get}
110
+ * Gets a value by key.
111
+ * @param key - The key to look up.
112
+ * @returns Returns {@link DetailedSuccess | Success} with the value and detail `exists` if found,
113
+ * or {@link DetailedFailure | Failure} with detail `not-found` if the key does not exist.
108
114
  */
109
115
  get(key) {
110
116
  const item = this._byKey.get(key);
111
117
  return item ? (0, base_1.succeedWithDetail)(item, 'exists') : (0, base_1.failWithDetail)(`${key}: not found`, 'not-found');
112
118
  }
113
119
  /**
114
- * {@inheritDoc Collections.IReadOnlyCollector.getAt}
120
+ * Gets the item at a specified index.
121
+ * @param index - The index of the item to retrieve.
122
+ * @returns Returns {@link Success | Success} with the item if it exists, or {@link Failure | Failure}
123
+ * with an error if the index is out of range.
115
124
  */
116
125
  getAt(index) {
117
126
  if (typeof index !== 'number') {
@@ -149,25 +158,30 @@ class Collector {
149
158
  });
150
159
  }
151
160
  /**
152
- * {@inheritDoc Collections.ResultMap.has}
161
+ * Returns true if the map contains an entry with the given key.
162
+ * @param key - The key to check for.
163
+ * @returns `true` if the key exists, `false` otherwise.
153
164
  */
154
165
  has(key) {
155
166
  return this._byKey.has(key);
156
167
  }
157
168
  /**
158
- * {@inheritDoc Collections.ResultMap.keys}
169
+ * Returns an iterator over the map keys.
170
+ * @returns An iterator over the map keys.
159
171
  */
160
172
  keys() {
161
173
  return this._byKey.keys();
162
174
  }
163
175
  /**
164
- * {@inheritDoc Collections.ResultMap.values}
176
+ * Returns an iterator over the map values.
177
+ * @returns An iterator over the map values.
165
178
  */
166
179
  values() {
167
180
  return this._byKey.values();
168
181
  }
169
182
  /**
170
- * {@inheritDoc Collections.IReadOnlyCollector.valuesByIndex}
183
+ * Gets all items in the collection, ordered by index.
184
+ * @returns An array of items in the collection, ordered by index.
171
185
  */
172
186
  valuesByIndex() {
173
187
  return this._byIndex;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector.js","sourceRoot":"","sources":["../../../src/packlets/collections/collector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAQiB;AA8CjB;;;;;;;;GAQG;AACH,MAAa,SAAS;IAQpB;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,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E,CAAC;QACD,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC;QAE9B,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACrB,OAAO,IAAA,qBAAc,EAAC,GAAG,GAAG,mCAAmC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,UAAU,CAAC,iBAAiB,CAAwB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7F,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,GAA0B;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,IAAI;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,aAAa;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;IAES,OAAO,CAAC,SAAwC;QACxD,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC;IACvC,CAAC;CACF;AAnOD,8BAmOC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n captureResult,\n DetailedResult,\n failWithDetail,\n Result,\n fail,\n succeed,\n succeedWithDetail\n} from '../base';\nimport { CollectibleFactoryCallback, CollectibleKey, ICollectible } from './collectible';\nimport { KeyValueEntry } from './common';\nimport { IReadOnlyResultMap, ResultMapForEachCb, ResultMapResultDetail } from './readonlyResultMap';\n\n/**\n * Additional success or failure details for mutating collector calls.\n * @public\n */\nexport type CollectorResultDetail = ResultMapResultDetail | 'invalid-index';\n\n/**\n * A read-only interface exposing only the non-mutating methods of a {@link Collections.Collector | ICollector}.\n * @public\n */\nexport interface IReadOnlyCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> extends IReadOnlyResultMap<CollectibleKey<TITEM>, TITEM> {\n /**\n * Gets the item at a specified index.\n * @param index - The index of the item to retrieve.\n * @returns Returns {@link Success | Success} with the item if it exists, or {@link Failure | Failure}\n * with an error if the index is out of range.\n */\n getAt(index: number): Result<TITEM>;\n\n /**\n * Gets all items in the collection, ordered by index.\n * @returns An array of items in the collection, ordered by index.\n */\n valuesByIndex(): ReadonlyArray<TITEM>;\n}\n\n/**\n * Parameters for constructing a {@link Collections.Collector | ICollector}.\n * @public\n */\nexport interface ICollectorConstructorParams<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> {\n /** Optional initial items to populate the collector. */\n items?: TITEM[];\n}\n\n/**\n * A {@link Collections.Collector | Collector} that is a specialized collection\n * which contains items of type {@link Collections.ICollectible | ICollectible},\n * which have a unique key and a write-once index.\n *\n * Items are assigned an index sequentially as they are added to the collection.\n * Once added, items are immutable - they cannot be removed or replaced.\n * @public\n */\nexport class Collector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> implements IReadOnlyCollector<TITEM>\n{\n private readonly _byKey: Map<CollectibleKey<TITEM>, TITEM>;\n private readonly _byIndex: TITEM[];\n\n /**\n * Returns the number of entries in the map.\n */\n public get size(): number {\n return this._byIndex.length;\n }\n\n /**\n * Constructs a new {@link Collections.Collector | Collector}.\n * @param params - Optional {@link Collections.ICollectorConstructorParams | initialization parameters} used\n * to construct the collector.\n */\n public constructor(params?: ICollectorConstructorParams<TITEM>) {\n this._byKey = new Map<CollectibleKey<TITEM>, TITEM>();\n this._byIndex = [];\n for (const item of params?.items ?? []) {\n this.add(item).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Collections.Collector | Collector} instance.\n * @param params - Optional {@link Collections.ICollectorConstructorParams | initialization parameters} used\n * to create the collector.\n * @returns Returns {@link Success | Success} with the new collector if it was created successfully,\n * or {@link Failure | Failure} with an error if the collector could not be created.\n */\n public static createCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n >(params?: ICollectorConstructorParams<TITEM>): Result<Collector<TITEM>> {\n return captureResult(() => new Collector(params));\n }\n\n /**\n * Adds an item to the collection, failing if a different item with the same key already exists. Note\n * that adding an object that is already in the collection again will succeed without updating the collection.\n * @param item - The item to add.\n * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added\n * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with\n * an error message and appropriate detail if the item could not be added.\n */\n public add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail> {\n const existing = this._byKey.get(item.key);\n if (existing === item) {\n return succeedWithDetail(item, 'exists');\n } else if (existing) {\n return failWithDetail(`${item.key}: already exists`, 'exists');\n }\n const indexResult = item.setIndex(this._byIndex.length);\n if (indexResult.isFailure()) {\n return failWithDetail(`${item.key}: ${indexResult.message}`, 'invalid-index');\n } else if (item.index !== this._byIndex.length) {\n return failWithDetail(`${item.key}: index mismatch - built item has ${item.index}`, 'invalid-index');\n }\n this._byKey.set(item.key, item);\n this._byIndex.push(item);\n return succeedWithDetail(item, 'added');\n }\n\n /**\n * Returns an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n public entries(): IterableIterator<KeyValueEntry<CollectibleKey<TITEM>, TITEM>> {\n return this._byKey.entries();\n }\n\n /**\n * Calls a function for each entry in the map.\n * @param callback - The function to call for each entry.\n * @param arg - An optional argument to pass to the callback.\n */\n public forEach(callback: ResultMapForEachCb<CollectibleKey<TITEM>, TITEM>, arg?: unknown): void {\n for (const [key, value] of this._byKey.entries()) {\n callback(value, key, this, arg);\n }\n }\n\n /**\n * Gets a value by key.\n * @param key - The key to look up.\n * @returns Returns {@link DetailedSuccess | Success} with the value and detail `exists` if found,\n * or {@link DetailedFailure | Failure} with detail `not-found` if the key does not exist.\n */\n public get(key: CollectibleKey<TITEM>): DetailedResult<TITEM, ResultMapResultDetail> {\n const item = this._byKey.get(key);\n return item ? succeedWithDetail(item, 'exists') : failWithDetail(`${key}: not found`, 'not-found');\n }\n\n /**\n * Gets the item at a specified index.\n * @param index - The index of the item to retrieve.\n * @returns Returns {@link Success | Success} with the item if it exists, or {@link Failure | Failure}\n * with an error if the index is out of range.\n */\n public getAt(index: number): Result<TITEM> {\n if (typeof index !== 'number') {\n // Handle Symbol conversion safely\n const indexStr = typeof index === 'symbol' ? (index as symbol).toString() : String(index);\n return fail(`${indexStr}: collector index must be a number.`);\n }\n\n // Check that the number is a finite integer (handles NaN, Infinity, and non-integers)\n if (!Number.isFinite(index) || !Number.isInteger(index)) {\n return fail(`${index}: collector index must be a finite integer.`);\n }\n\n if (index < 0 || index >= this._byIndex.length) {\n return fail(`${index}: collector index out of range.`);\n }\n\n return succeed(this._byIndex[index]);\n }\n\n /**\n * Gets an existing item with a key matching that of a supplied item, or adds the supplied\n * item to the collector if no item with that key exists.\n * @param item - The item to get or add.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item return and detail `added` indicates that the\n * item was added. Returns {@link DetailedFailure | Failure} with an error and appropriate\n * detail if the item could not be added.\n */\n public getOrAdd(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Gets an existing item with a key matching the supplied key, or adds a new item to the collector\n * using a factory callback if no item with that key exists.\n * @param key - The key of the item to add.\n * @param factory - The factory callback to create the item.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item return and detail `added` indicates that the\n * item was added. Returns {@link DetailedFailure | Failure} with an error and appropriate\n * detail if the item could not be added.\n */\n public getOrAdd(\n key: CollectibleKey<TITEM>,\n factory: CollectibleFactoryCallback<TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail>;\n\n public getOrAdd(\n keyOrItem: CollectibleKey<TITEM> | TITEM,\n factory?: CollectibleFactoryCallback<TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail> {\n const key = !this._isItem(keyOrItem) ? keyOrItem : keyOrItem.key;\n const existing = this._byKey.get(key);\n if (existing) {\n return succeedWithDetail(existing, 'exists');\n }\n\n const itemResult = !this._isItem(keyOrItem)\n ? factory!(keyOrItem, this._byIndex.length)\n : succeed(keyOrItem);\n if (itemResult.isFailure()) {\n return failWithDetail(`${key}: ${itemResult.message}`, 'invalid-value');\n }\n const item = itemResult.value;\n\n if (item.key !== key) {\n return failWithDetail(`${key}: key mismatch - built item has ${key}`, 'invalid-key');\n }\n\n return itemResult.withFailureDetail<CollectorResultDetail>('invalid-index').onSuccess((item) => {\n return this.add(item);\n });\n }\n\n /**\n * Returns true if the map contains an entry with the given key.\n * @param key - The key to check for.\n * @returns `true` if the key exists, `false` otherwise.\n */\n public has(key: CollectibleKey<TITEM>): boolean {\n return this._byKey.has(key);\n }\n\n /**\n * Returns an iterator over the map keys.\n * @returns An iterator over the map keys.\n */\n public keys(): IterableIterator<CollectibleKey<TITEM>> {\n return this._byKey.keys();\n }\n\n /**\n * Returns an iterator over the map values.\n * @returns An iterator over the map values.\n */\n public values(): IterableIterator<TITEM> {\n return this._byKey.values();\n }\n\n /**\n * Gets all items in the collection, ordered by index.\n * @returns An array of items in the collection, ordered by index.\n */\n public valuesByIndex(): ReadonlyArray<TITEM> {\n return this._byIndex;\n }\n\n /**\n * Gets a read-only version of this collector.\n */\n public toReadOnly(): IReadOnlyCollector<TITEM> {\n return this;\n }\n\n /**\n * Gets an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n public [Symbol.iterator](): IterableIterator<KeyValueEntry<CollectibleKey<TITEM>, TITEM>> {\n return this._byKey[Symbol.iterator]();\n }\n\n protected _isItem(keyOrItem: CollectibleKey<TITEM> | TITEM): keyOrItem is TITEM {\n return typeof keyOrItem !== 'string';\n }\n}\n"]}
@@ -24,7 +24,14 @@ export interface IReadOnlyCollectorValidator<TITEM extends ICollectible<any, any
24
24
  */
25
25
  has(key: string): boolean;
26
26
  /**
27
- * {@inheritDoc Collections.Collector.getOrAdd}
27
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
28
+ * using a factory callback if no item with that key exists.
29
+ * @param key - The weakly-typed key of the item to get or add.
30
+ * @param factory - The factory callback to create the item.
31
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
32
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
33
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
34
+ * appropriate detail if the item could not be added.
28
35
  */
29
36
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
30
37
  }
@@ -53,7 +60,12 @@ export declare class CollectorValidator<TITEM extends ICollectible<any, any>> im
53
60
  */
54
61
  constructor(params: ICollectorValidatorCreateParams<TITEM>);
55
62
  /**
56
- * {@inheritDoc Collections.Collector.add}
63
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
64
+ * that adding an object that is already in the collection again will succeed without updating the collection.
65
+ * @param item - The item to add.
66
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
67
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
68
+ * an error message and appropriate detail if the item could not be added.
57
69
  */
58
70
  add(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
59
71
  /**
@@ -61,12 +73,24 @@ export declare class CollectorValidator<TITEM extends ICollectible<any, any>> im
61
73
  */
62
74
  get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
63
75
  /**
64
- * {@inheritDoc Collections.Collector.getOrAdd}
76
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
77
+ * using a factory callback if no item with that key exists.
78
+ * @param key - The weakly-typed key of the item to get or add.
79
+ * @param factory - The factory callback to create the item.
80
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
81
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
82
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
83
+ * appropriate detail if the item could not be added.
65
84
  */
66
85
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
67
86
  /**
68
- * {@inheritDoc Collections.Collector.getOrAdd}
69
- * @param item - The item to add to the collector.
87
+ * Gets an existing item with a key matching that of the supplied item, or adds the supplied
88
+ * item to the collector if no item with that key exists.
89
+ * @param item - The weakly-typed item to get or add.
90
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
91
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
92
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
93
+ * appropriate detail if the item could not be added.
70
94
  */
71
95
  getOrAdd(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;
72
96
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectorValidator.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/collectorValidator.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,2BAA2B,CAE1C,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CACpC,SAAQ,2BAA2B,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACjE;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAE/D;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;IAE/D;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE1B;;;;;;;;;OASG;IACH,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAC3D,cAAc,CAAC,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;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,UAAU,IAAI,2BAA2B,CAAC,KAAK,CAAC;IAIvD;;;;;;;;OAQG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,qBAAqB,CAAC;CAMtF"}
@@ -40,7 +40,12 @@ class CollectorValidator {
40
40
  this.converters = params.converters;
41
41
  }
42
42
  /**
43
- * {@inheritDoc Collections.Collector.add}
43
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
44
+ * that adding an object that is already in the collection again will succeed without updating the collection.
45
+ * @param item - The item to add.
46
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
47
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
48
+ * an error message and appropriate detail if the item could not be added.
44
49
  */
45
50
  add(item) {
46
51
  return this._convertValue(item).onSuccess((i) => {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectorValidator.js","sourceRoot":"","sources":["../../../src/packlets/collections/collectorValidator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAgEH;;;;GAIG;AACH,MAAa,kBAAkB;IAO7B,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACtC,CAAC;IAID;;;OAGG;IACH,YAAmB,MAA8C;QAC/D,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;;;;;OAOG;IACI,GAAG,CAAC,IAAa;QACtB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC,CA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) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult } from '../base';\nimport { IReadOnlyResultMap, ResultMapResultDetail } from './readonlyResultMap';\nimport { ResultMapValueFactory } from './resultMap';\nimport { KeyValueConverters } from './keyValueConverters';\nimport { Collector, CollectorResultDetail } from './collector';\nimport { IReadOnlyResultMapValidator } from './resultMapValidator';\nimport { CollectibleKey, ICollectible } from './collectible';\n\n/**\n * A read-only interface exposing non-mutating methods of a\n * {@link Collections.CollectorValidator | CollectorValidator}.\n * @public\n */\nexport interface IReadOnlyCollectorValidator<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> extends IReadOnlyResultMapValidator<CollectibleKey<TITEM>, TITEM> {\n /**\n * {@inheritDoc Collections.ReadOnlyResultMapValidator.map}\n */\n readonly map: IReadOnlyResultMap<CollectibleKey<TITEM>, TITEM>;\n\n /**\n * {@inheritDoc Collections.Collector.get}\n */\n get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;\n\n /**\n * {@inheritDoc Collections.ResultMap.has}\n */\n has(key: string): boolean;\n\n /**\n * Gets an existing item with a key matching the supplied key, or adds a new item to the collector\n * using a factory callback if no item with that key exists.\n * @param key - The weakly-typed key of the item to get or add.\n * @param factory - The factory callback to create the item.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item was returned and detail `added` indicates\n * that the item was added. Returns {@link DetailedFailure | Failure} with an error and\n * appropriate detail if the item could not be added.\n */\n getOrAdd(\n key: string,\n factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail>;\n}\n\n/**\n * Parameters for constructing a {@link Collections.CollectorValidator | CollectorValidator}.\n * @public\n */\nexport interface ICollectorValidatorCreateParams<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> {\n /** The collector to validate access to. */\n readonly collector: Collector<TITEM>;\n /** The key-value converters for validation. */\n readonly converters: KeyValueConverters<CollectibleKey<TITEM>, TITEM>;\n}\n\n/**\n * A {@link Collections.Collector | Collector} wrapper which validates weakly-typed keys\n * and values before calling the wrapped collector.\n * @public\n */\nexport class CollectorValidator<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>\n> implements IReadOnlyCollectorValidator<TITEM>\n{\n public readonly converters: KeyValueConverters<CollectibleKey<TITEM>, TITEM>;\n\n public get map(): IReadOnlyResultMap<CollectibleKey<TITEM>, TITEM> {\n return this._collector.toReadOnly();\n }\n\n protected _collector: Collector<TITEM>;\n\n /**\n * Constructs a new {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator}.\n * @param params - Required parameters for constructing the collector validator.\n */\n public constructor(params: ICollectorValidatorCreateParams<TITEM>) {\n this._collector = params.collector;\n this.converters = params.converters;\n }\n\n /**\n * Adds an item to the collection, failing if a different item with the same key already exists. Note\n * that adding an object that is already in the collection again will succeed without updating the collection.\n * @param item - The item to add.\n * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added\n * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with\n * an error message and appropriate detail if the item could not be added.\n */\n public add(item: unknown): DetailedResult<TITEM, CollectorResultDetail> {\n return this._convertValue(item).onSuccess((i) => {\n return this._collector.add(i);\n });\n }\n\n /**\n * {@inheritDoc Collections.Collector.get}\n */\n public get(key: string): DetailedResult<TITEM, ResultMapResultDetail> {\n return this.converters.convertKey(key).onSuccess((k) => {\n return this._collector.get(k);\n });\n }\n\n /**\n * Gets an existing item with a key matching the supplied key, or adds a new item to the collector\n * using a factory callback if no item with that key exists.\n * @param key - The weakly-typed key of the item to get or add.\n * @param factory - The factory callback to create the item.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item was returned and detail `added` indicates\n * that the item was added. Returns {@link DetailedFailure | Failure} with an error and\n * appropriate detail if the item could not be added.\n */\n public getOrAdd(\n key: string,\n factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Gets an existing item with a key matching that of the supplied item, or adds the supplied\n * item to the collector if no item with that key exists.\n * @param item - The weakly-typed item to get or add.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item was returned and detail `added` indicates\n * that the item was added. Returns {@link DetailedFailure | Failure} with an error and\n * appropriate detail if the item could not be added.\n */\n public getOrAdd(item: unknown): DetailedResult<TITEM, CollectorResultDetail>;\n\n public getOrAdd(\n keyOrItem: string | unknown,\n factoryCb?: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail> {\n if (factoryCb === undefined) {\n return this._convertValue(keyOrItem).onSuccess((item) => this._collector.getOrAdd(item));\n } else {\n return this.converters\n .convertKey(keyOrItem)\n .withDetail<CollectorResultDetail>('invalid-key', 'success')\n .onSuccess((key) => this._collector.getOrAdd(key, factoryCb));\n }\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.has}\n */\n public has(key: string): boolean {\n return this._collector.has(key as CollectibleKey<TITEM>);\n }\n\n /**\n * {@inheritDoc Collections.Collector.toReadOnly}\n */\n public toReadOnly(): IReadOnlyCollectorValidator<TITEM> {\n return this;\n }\n\n /**\n * Helper to convert a value, returning a {@link DetailedResult | DetailedResult}\n * and formatting the error message.\n * @param value - The value to convert.\n * @returns {@link DetailedSuccess | DetailedSuccess} with the converted value\n * and detail `success` if conversion is successful, or\n * {@link DetailedFailure | DetailedFailure} with the error message and detail `invalid-value`\n * if conversion fails.\n */\n protected _convertValue(value: unknown): DetailedResult<TITEM, CollectorResultDetail> {\n return this.converters\n .convertValue(value)\n .withErrorFormat((message) => `invalid item: ${message}`)\n .withDetail<CollectorResultDetail>('invalid-value', 'success');\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/common.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/packlets/collections/common.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Generic key-value entry.\n * @public\n */\nexport type KeyValueEntry<TK extends string = string, TV = unknown> = [TK, TV];\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/converters.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAc,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,6BAA6B,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE;IAClE,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5B,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,EACjD,MAAM,EAAE,6BAA6B,CAAC,EAAE,EAAE,EAAE,CAAC,GAC5C,SAAS,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAQ3C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../src/packlets/collections/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAqBH,sCAUC;AA7BD,kCAA0C;AAC1C,8CAAsD;AAYtD;;;;;GAKG;AACH,SAAgB,aAAa,CAC3B,MAA6C;IAE7C,OAAO,uBAAU,CAAC,OAAO,CAAC,CAAC,IAAa,EAAiC,EAAE;QACzE,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,GAAO,EAAE,EAAE;YACpD,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,KAAS,EAAE,EAAE;gBACxD,OAAO,cAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACpC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, Success } from '../base';\nimport { Converter, Converters } from '../conversion';\nimport { KeyValueEntry } from './common';\n\n/**\n * Initialization parameters for the {@link Collections.Converters.keyValueEntry | keyValueEntry} converter.\n * @public\n */\nexport interface IKeyValueEntryConverterParams<TK extends string, TV> {\n key: Converter<TK, unknown>;\n value: Converter<TV, unknown>;\n}\n\n/**\n * A {@link Converter | Converter} for {@link Collections.KeyValueEntry | KeyValueEntry} instances.\n * @param params - Conversion parameters.\n * @returns A converter for which validates key value entries using the supplied validators.\n * @public\n */\nexport function keyValueEntry<TK extends string, TV>(\n params: IKeyValueEntryConverterParams<TK, TV>\n): Converter<KeyValueEntry<TK, TV>, unknown> {\n return Converters.generic((from: unknown): Result<KeyValueEntry<TK, TV>> => {\n return params.key.convert(from).onSuccess((key: TK) => {\n return params.value.convert(from).onSuccess((value: TV) => {\n return Success.with([key, value]);\n });\n });\n });\n}\n"]}
@@ -37,7 +37,12 @@ export declare class ConvertingCollector<TITEM extends ICollectible<any, any>, T
37
37
  */
38
38
  static createConvertingCollector<TITEM extends ICollectible<any, any>, TSRC = TITEM>(params: IConvertingCollectorConstructorParams<TITEM, TSRC>): Result<ConvertingCollector<TITEM, TSRC>>;
39
39
  /**
40
- * {@inheritDoc Collections.Collector.add}
40
+ * Adds an item to the collection, failing if a different item with the same key already exists. Note
41
+ * that adding an object that is already in the collection again will succeed without updating the collection.
42
+ * @param item - The item to add.
43
+ * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added
44
+ * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with
45
+ * an error message and appropriate detail if the item could not be added.
41
46
  */
42
47
  add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
43
48
  /**
@@ -60,11 +65,24 @@ export declare class ConvertingCollector<TITEM extends ICollectible<any, any>, T
60
65
  */
61
66
  add(key: CollectibleKey<TITEM>, cb: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
62
67
  /**
63
- * {@inheritDoc Collections.Collector.getOrAdd}
68
+ * Gets an existing item with a key matching that of the supplied item, or adds the supplied
69
+ * item to the collector if no item with that key exists.
70
+ * @param item - The item to get or add.
71
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
72
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
73
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
74
+ * appropriate detail if the item could not be added.
64
75
  */
65
76
  getOrAdd(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;
66
77
  /**
67
- * {@inheritDoc Collections.Collector.getOrAdd}
78
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
79
+ * using a factory callback if no item with that key exists.
80
+ * @param key - The key of the item to get or add.
81
+ * @param callback - The factory callback to create the item.
82
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
83
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
84
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
85
+ * appropriate detail if the item could not be added.
68
86
  */
69
87
  getOrAdd(key: CollectibleKey<TITEM>, callback: CollectibleFactoryCallback<TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
70
88
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertingCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/convertingCollector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,cAAc,EAAkB,MAAM,EAAqB,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,qCAAqC,CAEpD,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,IAAI,GAAG,KAAK;IAEZ;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzC;;OAEG;IACH,OAAO,CA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IAAI,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC,CAAC;aACD,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YAClB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;OAOG;IACO,YAAY,CACpB,QAAkD;QAElD,OAAO,OAAO,QAAQ,KAAK,UAAU,CAAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACO,eAAe,CACvB,SAAwC,EACxC,QAAmD;QAEnD,OAAO,QAAQ,KAAK,SAAS,CAAC;IAChC,CAAC;IAED;;;;;;;;OAQG;IACO,UAAU,CAClB,GAA0B,EAC1B,QAAkD;QAElD,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1G,CAAC;CACF;AA5LD,kDA4LC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, DetailedResult, failWithDetail, Result, succeedWithDetail } from '../base';\nimport { ICollectible, CollectibleFactoryCallback, CollectibleFactory, CollectibleKey } from './collectible';\nimport { Collector, CollectorResultDetail } from './collector';\nimport { KeyValueEntry } from './common';\n\n/**\n * Parameters for constructing a {@link Collections.ConvertingCollector | ConvertingCollector}.\n * @public\n */\nexport interface IConvertingCollectorConstructorParams<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>,\n TSRC = TITEM\n> {\n /**\n * The default {@link Collections.CollectibleFactory | factory} to create items.\n */\n factory: CollectibleFactory<TITEM, TSRC>;\n /**\n * An optional array of entries to add to the collector.\n */\n entries?: KeyValueEntry<CollectibleKey<TITEM>, TSRC>[];\n}\n\n/**\n * A {@link Collector | collector} that collects {@link Collections.ICollectible | ICollectible} items,\n * optionally converting them from a source representation to the target representation using a factory\n * supplied at default or at the time of collection.\n * @public\n */\nexport class ConvertingCollector<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>,\n TSRC = TITEM\n> extends Collector<TITEM> {\n private _factory: CollectibleFactory<TITEM, TSRC>;\n\n /**\n * Constructs a new {@link Collections.ConvertingCollector | ConvertingCollector}.\n * @param params - Parameters for constructing the collector.\n */\n public constructor(params: IConvertingCollectorConstructorParams<TITEM, TSRC>) {\n super();\n this._factory = params.factory;\n params.entries?.forEach((entry) => {\n this.getOrAdd(entry[0], entry[1]).orThrow();\n });\n }\n\n /**\n * Creates a new {@link Collections.ConvertingCollector | ConvertingCollector}.\n * @param params - Required parameters for constructing the collector.\n * @returns Returns {@link Success | Success} with the new collector if it is created, or {@link Failure | Failure}\n * with an error if the collector cannot be created.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public static createConvertingCollector<TITEM extends ICollectible<any, any>, TSRC = TITEM>(\n params: IConvertingCollectorConstructorParams<TITEM, TSRC>\n ): Result<ConvertingCollector<TITEM, TSRC>> {\n return captureResult(() => new ConvertingCollector(params));\n }\n\n /**\n * Adds an item to the collection, failing if a different item with the same key already exists. Note\n * that adding an object that is already in the collection again will succeed without updating the collection.\n * @param item - The item to add.\n * @returns Returns {@link DetailedSuccess | Success} with the item and detail `added` if it was added\n * or detail `exists` if the item was already in the map. Returns {@link DetailedFailure | Failure} with\n * an error message and appropriate detail if the item could not be added.\n */\n public add(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Adds an item to the collector using the default {@link Collections.CollectibleFactory | factory}\n * at a specified key, failing if an item with that key already exists.\n * @param key - The key of the item to add.\n * @param item - The source representation of the item to be added.\n * @returns Returns {@link Success | Success} with the item if it is added, or {@link Failure | Failure} with\n * an error if the item cannot be created and indexed.\n * @public\n */\n public add(key: CollectibleKey<TITEM>, item: TSRC): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Adds an item to the collector using a supplied {@link Collections.CollectibleFactoryCallback | factory callback}\n * at a specified key, failing if an item with that key already exists or if the created item is invalid.\n * @param key - The key of the item to add.\n * @param cb - The factory callback to create the item.\n * @returns Returns {@link Success | Success} with the item if it is added, or {@link Failure | Failure} with\n * an error if the item cannot be created and indexed.\n */\n public add(\n key: CollectibleKey<TITEM>,\n cb: CollectibleFactoryCallback<TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail>;\n\n public add(\n keyOrItem: CollectibleKey<TITEM> | TITEM,\n itemOrCb?: TSRC | CollectibleFactoryCallback<TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail> {\n if (this._overloadIsItem(keyOrItem, itemOrCb)) {\n return super.add(keyOrItem);\n }\n return this._buildItem(keyOrItem, itemOrCb!)\n .withFailureDetail<CollectorResultDetail>('invalid-value')\n .onSuccess((item) => {\n return super.add(item);\n });\n }\n\n /**\n * Gets an existing item with a key matching that of the supplied item, or adds the supplied\n * item to the collector if no item with that key exists.\n * @param item - The item to get or add.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item was returned and detail `added` indicates\n * that the item was added. Returns {@link DetailedFailure | Failure} with an error and\n * appropriate detail if the item could not be added.\n */\n public getOrAdd(item: TITEM): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Gets an existing item with a key matching the supplied key, or adds a new item to the collector\n * using a factory callback if no item with that key exists.\n * @param key - The key of the item to get or add.\n * @param callback - The factory callback to create the item.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item was returned and detail `added` indicates\n * that the item was added. Returns {@link DetailedFailure | Failure} with an error and\n * appropriate detail if the item could not be added.\n */\n public getOrAdd(\n key: CollectibleKey<TITEM>,\n callback: CollectibleFactoryCallback<TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Gets an item by key if it exists, or creates a new item and adds it using the default {@link Collections.CollectibleFactory | factory} if not.\n * @param key - The key of the item to retrieve.\n * @param item - The source representation of the item to be added if it does not exist.\n * @returns Returns {@link Success | Success} with the item if it exists or could be created, or {@link Failure | Failure} with an error if the\n * item cannot be created and indexed.\n */\n public getOrAdd(key: CollectibleKey<TITEM>, item: TSRC): DetailedResult<TITEM, CollectorResultDetail>;\n\n public getOrAdd(\n keyOrItem: CollectibleKey<TITEM> | TITEM,\n itemOrCb?: TSRC | CollectibleFactoryCallback<TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail> {\n if (this._overloadIsItem(keyOrItem, itemOrCb)) {\n return super.getOrAdd(keyOrItem);\n }\n\n if (this.has(keyOrItem)) {\n return this.get(keyOrItem);\n }\n\n return this._buildItem(keyOrItem, itemOrCb!)\n .withFailureDetail<CollectorResultDetail>('invalid-value')\n .onSuccess((item) => {\n if (item.key !== keyOrItem) {\n return failWithDetail<TITEM, CollectorResultDetail>(\n `${keyOrItem}: key mismatch - item has unexpected key ${item.key}`,\n 'invalid-key'\n );\n }\n return succeedWithDetail(item, 'success');\n })\n .onSuccess((item) => {\n return super.add(item);\n });\n }\n\n /**\n * Helper method for derived classes to determine if a supplied\n * itemOrCb parameter is a factory callback.\n * @param itemOrCb - Overloaded parameter is either `CollectibleKey<TITEM>` or\n * a {@link Collections.CollectibleFactoryCallback | factory callback}.\n * @returns Returns `true` if the parameter is a factory callback, `false` otherwise.\n * @public\n */\n protected _isFactoryCB(\n itemOrCb: TSRC | CollectibleFactoryCallback<TITEM>\n ): itemOrCb is CollectibleFactoryCallback<TITEM> {\n return typeof itemOrCb === 'function';\n }\n\n /**\n * Helper method for derived classes to determine if a supplied\n * keyOrItem parameter is an item.\n * @param keyOrItem - Overloaded parameter is either `CollectibleKey<TITEM>` or `TITEM`.\n * @param itemOrCb - Overloaded parameter is either `TSRC`, a {@link Collections.CollectibleFactoryCallback | factory callback}\n * or `undefined`.\n * @returns Returns `true` if the parameter is an item, `false` otherwise.\n * @public\n */\n protected _overloadIsItem(\n keyOrItem: CollectibleKey<TITEM> | TITEM,\n itemOrCb?: TSRC | CollectibleFactoryCallback<TITEM>\n ): keyOrItem is TITEM {\n return itemOrCb === undefined;\n }\n\n /**\n * Helper method for derived classes to build an item from a key and a source representation using\n * a default or supplied factory.\n * @param key - The key of the item to build.\n * @param itemOrCb - The source representation of the item to build, or a factory callback to create it.\n * @returns Returns {@link Success | Success} with the item if it is built, or {@link Failure | Failure}\n * with an error if the item cannot be built.\n * @public\n */\n protected _buildItem(\n key: CollectibleKey<TITEM>,\n itemOrCb: TSRC | CollectibleFactoryCallback<TITEM>\n ): Result<TITEM> {\n return this._isFactoryCB(itemOrCb) ? itemOrCb(key, this.size) : this._factory(key, this.size, itemOrCb);\n }\n}\n"]}
@@ -32,7 +32,12 @@ export declare class ConvertingCollectorValidator<TITEM extends ICollectible<any
32
32
  */
33
33
  constructor(params: IConvertingCollectorValidatorCreateParams<TITEM, TSRC>);
34
34
  /**
35
- * {@inheritDoc Collections.ConvertingCollector.add}
35
+ * Adds an item to the collector using the default factory at a specified key,
36
+ * failing if an item with that key already exists.
37
+ * @param key - The weakly-typed key of the item to add.
38
+ * @param value - The source representation of the item to be added.
39
+ * @returns Returns {@link Success | Success} with the item if it is added, or {@link Failure | Failure} with
40
+ * an error if the item cannot be created and indexed.
36
41
  */
37
42
  add(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
38
43
  /**
@@ -45,11 +50,25 @@ export declare class ConvertingCollectorValidator<TITEM extends ICollectible<any
45
50
  */
46
51
  get(key: string): DetailedResult<TITEM, ResultMapResultDetail>;
47
52
  /**
48
- * {@inheritDoc Collections.ConvertingCollector.getOrAdd}
53
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
54
+ * by converting the supplied weakly-typed value if no item with that key exists.
55
+ * @param key - The weakly-typed key of the item to get or add.
56
+ * @param value - The weakly-typed source value to convert and add if the key does not exist.
57
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
58
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
59
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
60
+ * appropriate detail if the item could not be added.
49
61
  */
50
62
  getOrAdd(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;
51
63
  /**
52
- * {@inheritDoc Collections.Collector.getOrAdd}
64
+ * Gets an existing item with a key matching the supplied key, or adds a new item to the collector
65
+ * using a factory callback if no item with that key exists.
66
+ * @param key - The weakly-typed key of the item to get or add.
67
+ * @param factory - The factory callback to create the item.
68
+ * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -
69
+ * detail `exists` indicates that an existing item was returned and detail `added` indicates
70
+ * that the item was added. Returns {@link DetailedFailure | Failure} with an error and
71
+ * appropriate detail if the item could not be added.
53
72
  */
54
73
  getOrAdd(key: string, factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>): DetailedResult<TITEM, CollectorResultDetail>;
55
74
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertingCollectorValidator.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/convertingCollectorValidator.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAkB,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,yCAAyC,CAExD,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,IAAI,GAAG,KAAK;IAEZ,sDAAsD;IACtD,SAAS,EAAE,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5C,+CAA+C;IAC/C,UAAU,EAAE,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;CAC7D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B,CAEvC,KAAK,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACpC,IAAI,GAAG,KAAK,CACZ,YAAW,2BAA2B,CAAC,KAAK,CAAC;IAE7C,SAAgB,UAAU,EAAE,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;IAE5E,IAAW,GAAG,IAAI,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAEjE;IAED,SAAS,CAAC,UAAU,EAAE,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEvD;;;OAGG;gBACgB,MAAM,EAAE,yCAAyC,CAAC,KAAK,EAAE,IAAI,CAAC;IAKjF;;;;;;;OAOG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAErF;;;OAGG;IACI,GAAG,CACR,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAC3D,cAAc,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAW/C;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAMrE;;;;;;;;;OASG;IACI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAE1F;;;;;;;;;OASG;IACI,QAAQ,CACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAC3D,cAAc,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAsB/C;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,UAAU,IAAI,2BAA2B,CAAC,KAAK,CAAC;IAIvD;;;;;;OAMG;IACH,SAAS,CAAC,6BAA6B,CACrC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAAC,KAAK,CAAC,GACjD,KAAK,IAAI,0BAA0B,CAAC,KAAK,CAAC;CAG9C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertingCollectorValidator.js","sourceRoot":"","sources":["../../../src/packlets/collections/convertingCollectorValidator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAyD;AAwBzD;;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,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAClD,IAAI,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;gBAC1B,OAAO,IAAA,qBAAc,EAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,GAAW;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAA4B,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACI,UAAU;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACO,6BAA6B,CACrC,KAAkD;QAElD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;IACrC,CAAC;CACF;AArID,oEAqIC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult, failWithDetail } from '../base';\nimport { IReadOnlyResultMap, ResultMapResultDetail } from './readonlyResultMap';\nimport { ResultMapValueFactory } from './resultMap';\nimport { KeyValueConverters } from './keyValueConverters';\nimport { CollectibleFactoryCallback, CollectibleKey, ICollectible } from './collectible';\nimport { CollectorResultDetail } from './collector';\nimport { ConvertingCollector } from './convertingCollector';\nimport { IReadOnlyCollectorValidator } from './collectorValidator';\n\n/**\n * Parameters for constructing a {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator}.\n * @public\n */\nexport interface IConvertingCollectorValidatorCreateParams<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>,\n TSRC = TITEM\n> {\n /** The converting collector to validate access to. */\n collector: ConvertingCollector<TITEM, TSRC>;\n /** The key-value converters for validation. */\n converters: KeyValueConverters<CollectibleKey<TITEM>, TSRC>;\n}\n\n/**\n * A {@link Collections.ConvertingCollector | ConvertingCollector} wrapper which validates weakly-typed keys\n * and values before calling the wrapped collector. Unlike the basic {@link Collections.CollectorValidator | CollectorValidator},\n * the converting collector expects the items to be in the source type of the converting collector, not the target type.\n * @public\n */\nexport class ConvertingCollectorValidator<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TITEM extends ICollectible<any, any>,\n TSRC = TITEM\n> implements IReadOnlyCollectorValidator<TITEM>\n{\n public readonly converters: KeyValueConverters<CollectibleKey<TITEM>, TSRC>;\n\n public get map(): IReadOnlyResultMap<CollectibleKey<TITEM>, TITEM> {\n return this._collector.toReadOnly();\n }\n\n protected _collector: ConvertingCollector<TITEM, TSRC>;\n\n /**\n * Constructs a new {@link Collections.ConvertingCollectorValidator | ConvertingCollectorValidator}.\n * @param params - Required parameters for constructing the collector validator.\n */\n public constructor(params: IConvertingCollectorValidatorCreateParams<TITEM, TSRC>) {\n this._collector = params.collector;\n this.converters = params.converters;\n }\n\n /**\n * Adds an item to the collector using the default factory at a specified key,\n * failing if an item with that key already exists.\n * @param key - The weakly-typed key of the item to add.\n * @param value - The source representation of the item to be added.\n * @returns Returns {@link Success | Success} with the item if it is added, or {@link Failure | Failure} with\n * an error if the item cannot be created and indexed.\n */\n public add(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Adds an item to the collector using a supplied factory callback\n * at a specified key, validating the key first.\n */\n public add(\n key: string,\n factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail>;\n public add(\n key: string,\n valueOrFactory: unknown | ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail> {\n if (this.has(key)) {\n return failWithDetail(`${key}: already exists`, 'exists');\n }\n return this.getOrAdd(key, valueOrFactory);\n }\n\n /**\n * {@inheritDoc Collections.Collector.get}\n */\n public get(key: string): DetailedResult<TITEM, ResultMapResultDetail> {\n return this.converters.convertKey(key).onSuccess((k) => {\n return this._collector.get(k);\n });\n }\n\n /**\n * Gets an existing item with a key matching the supplied key, or adds a new item to the collector\n * by converting the supplied weakly-typed value if no item with that key exists.\n * @param key - The weakly-typed key of the item to get or add.\n * @param value - The weakly-typed source value to convert and add if the key does not exist.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item was returned and detail `added` indicates\n * that the item was added. Returns {@link DetailedFailure | Failure} with an error and\n * appropriate detail if the item could not be added.\n */\n public getOrAdd(key: string, value: unknown): DetailedResult<TITEM, CollectorResultDetail>;\n\n /**\n * Gets an existing item with a key matching the supplied key, or adds a new item to the collector\n * using a factory callback if no item with that key exists.\n * @param key - The weakly-typed key of the item to get or add.\n * @param factory - The factory callback to create the item.\n * @returns Returns {@link DetailedSuccess | Success} with the item stored in the collector -\n * detail `exists` indicates that an existing item was returned and detail `added` indicates\n * that the item was added. Returns {@link DetailedFailure | Failure} with an error and\n * appropriate detail if the item could not be added.\n */\n public getOrAdd(\n key: string,\n factory: ResultMapValueFactory<CollectibleKey<TITEM>, TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail>;\n\n public getOrAdd(\n key: string,\n valueOrFactory: unknown | CollectibleFactoryCallback<TITEM>\n ): DetailedResult<TITEM, CollectorResultDetail> {\n if (!this._isCollectibleFactoryCallback(valueOrFactory)) {\n const converted = this.converters.convertEntry([key, valueOrFactory]);\n if (converted.isFailure()) {\n return failWithDetail(converted.message, converted.detail);\n }\n const [vk, vs] = converted.value;\n return this._collector.getOrAdd(vk, vs);\n } else {\n const converted = this.converters.convertKey(key);\n if (converted.isFailure()) {\n return failWithDetail(converted.message, converted.detail);\n }\n return this._collector.getOrAdd(converted.value, valueOrFactory);\n }\n }\n\n /**\n * {@inheritDoc Collections.ResultMap.has}\n */\n public has(key: string): boolean {\n return this._collector.has(key as CollectibleKey<TITEM>);\n }\n\n /**\n * {@inheritDoc Collections.Collector.toReadOnly}\n */\n public toReadOnly(): IReadOnlyCollectorValidator<TITEM> {\n return this;\n }\n\n /**\n * Determines if a value is a {@link Collections.CollectibleFactoryCallback | CollectibleFactoryCallback}.\n * @param value - The value to check.\n * @returns `true` if the value is a {@link Collections.CollectibleFactoryCallback | CollectibleFactoryCallback},\n * `false` otherwise.\n * @public\n */\n protected _isCollectibleFactoryCallback(\n value: unknown | CollectibleFactoryCallback<TITEM>\n ): value is CollectibleFactoryCallback<TITEM> {\n return typeof value === 'function';\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertingResultMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/convertingResultMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,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C;CAGlD;AAED;;;;;;GAMG;AACH,qBAAa,mBAAmB,CAC9B,EAAE,SAAS,MAAM,EACjB,IAAI,EACJ,OAAO,EACP,OAAO,SAAS,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,CAC3D,SAAQ,2BAA2B,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC;IACtD;;;OAGG;IACH,SAAgB,MAAM,EAAE,iCAAiC,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAEtF;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAExC;;;OAGG;gBACgB,MAAM,EAAE,qCAAqC,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;IAM5F;;;;OAIG;WACoB,MAAM,CAC3B,EAAE,SAAS,MAAM,EACjB,IAAI,EACJ,OAAO,EACP,OAAO,SAAS,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,EAE3D,MAAM,EAAE,qCAAqC,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,GACxE,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAI1D;;;;;OAKG;IACa,gBAAgB,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI;IAI/C;;;;OAIG;IACa,WAAW,IAAI,IAAI;CAGpC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertingResultMap.js","sourceRoot":"","sources":["../../../src/packlets/collections/convertingResultMap.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgE;AAGhE,+EAIuC;AAwBvC;;;;GAIG;AACH,MAAa,iCAAiC;IAU5C;;;;OAIG;IACH,YAAmB,KAAc,E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;;;;GAMG;AACH,MAAa,mBAKX,SAAQ,yDAA8C;IAYtD;;;OAGG;IACH,YAAmB,MAAyE;QAC1F,KAAK,CAAC,MAA0E,CAAC,CAAC;QAClF,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,iCAAiC,CAA6B,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACtG,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAU,MAAM,CAM3B,MAAyE;QAEzE,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;OAKG;IACa,gBAAgB,CAAC,GAAO;QACtC,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACa,WAAW;QACzB,KAAK,CAAC,WAAW,EAAE,CAAC;IACtB,CAAC;CACF;AA7DD,kDA6DC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, DetailedResult, Result } from '../base';\nimport { KeyValueEntry } from './common';\nimport { IReadOnlyResultMap, ResultMapForEachCb, ResultMapResultDetail } from './readonlyResultMap';\nimport {\n ReadOnlyConvertingResultMap,\n ConvertingResultMapValueConverter,\n IReadOnlyConvertingResultMapConstructorParams\n} from './readOnlyConvertingResultMap';\nimport { IResultMap, ResultMapValueFactory } from './resultMap';\n\n/**\n * Parameters for constructing a {@link Collections.ConvertingResultMap | ConvertingResultMap}.\n * @public\n */\nexport interface IConvertingResultMapConstructorParams<\n TK extends string,\n TSRC,\n TTARGET,\n TSRCMAP extends IResultMap<TK, TSRC> = IResultMap<TK, TSRC>\n> {\n /**\n * The inner map containing source values.\n */\n inner: TSRCMAP;\n\n /**\n * The converter function to transform source values to target values.\n */\n converter: ConvertingResultMapValueConverter<TK, TSRC, TTARGET>;\n}\n\n/**\n * A wrapper around a mutable result map that invalidates cache entries\n * in the parent {@link Collections.ConvertingResultMap | ConvertingResultMap} when mutations occur.\n * @public\n */\nexport class CacheInvalidatingResultMapWrapper<\n TK extends string,\n TSRC,\n TTARGET,\n TSRCMAP extends IResultMap<TK, TSRC> = IResultMap<TK, TSRC>\n> implements IResultMap<TK, TSRC>\n{\n private readonly _inner: TSRCMAP;\n private readonly _parent: ConvertingResultMap<TK, TSRC, TTARGET, TSRCMAP>;\n\n /**\n * Constructs a new cache-invalidating wrapper.\n * @param inner - The inner map to wrap.\n * @param parent - The parent converting map whose cache should be invalidated.\n */\n public constructor(inner: TSRCMAP, parent: ConvertingResultMap<TK, TSRC, TTARGET, TSRCMAP>) {\n this._inner = inner;\n this._parent = parent;\n }\n\n /**\n * The number of entries in the map.\n */\n public get size(): number {\n return this._inner.size;\n }\n\n /**\n * Adds a key/value pair to the map if the key does not already exist.\n * Invalidates the cache entry for the key.\n * @param key - The key to add.\n * @param value - The value to add.\n * @returns The result of the add operation.\n */\n public add(key: TK, value: TSRC): DetailedResult<TSRC, ResultMapResultDetail> {\n this._parent._clearCacheEntry(key);\n return this._inner.add(key, value);\n }\n\n /**\n * Sets a key/value pair in the map.\n * Invalidates the cache entry for the key.\n * @param key - The key to set.\n * @param value - The value to set.\n * @returns The result of the set operation.\n */\n public set(key: TK, value: TSRC): DetailedResult<TSRC, ResultMapResultDetail> {\n this._parent._clearCacheEntry(key);\n return this._inner.set(key, value);\n }\n\n /**\n * Updates an existing key in the map.\n * Invalidates the cache entry for the key.\n * @param key - The key to update.\n * @param value - The new value.\n * @returns The result of the update operation.\n */\n public update(key: TK, value: TSRC): DetailedResult<TSRC, ResultMapResultDetail> {\n this._parent._clearCacheEntry(key);\n return this._inner.update(key, value);\n }\n\n /**\n * Deletes a key from the map.\n * Invalidates the cache entry for the key.\n * @param key - The key to delete.\n * @returns The result of the delete operation.\n */\n public delete(key: TK): DetailedResult<TSRC, ResultMapResultDetail> {\n this._parent._clearCacheEntry(key);\n return this._inner.delete(key);\n }\n\n /**\n * Gets a value from the map.\n * @param key - The key to retrieve.\n * @returns The result of the get operation.\n */\n public get(key: TK): DetailedResult<TSRC, ResultMapResultDetail> {\n return this._inner.get(key);\n }\n\n /**\n * Gets a value from the map, or adds a supplied value if it does not exist.\n * Invalidates the cache entry for the key if a new value is added.\n * @param key - The key to retrieve or add.\n * @param value - The value to add if the key does not exist.\n * @returns The result of the operation.\n */\n public getOrAdd(key: TK, value: TSRC): DetailedResult<TSRC, ResultMapResultDetail>;\n\n /**\n * Gets a value from the map, or adds a value created by a factory if it does not exist.\n * Invalidates the cache entry for the key if a new value is added.\n * @param key - The key to retrieve or add.\n * @param factory - A factory function to create the value if the key does not exist.\n * @returns The result of the operation.\n */\n public getOrAdd(\n key: TK,\n factory: ResultMapValueFactory<TK, TSRC>\n ): DetailedResult<TSRC, ResultMapResultDetail>;\n\n public getOrAdd(\n key: TK,\n valueOrFactory: TSRC | ResultMapValueFactory<TK, TSRC>\n ): DetailedResult<TSRC, ResultMapResultDetail> {\n const result =\n typeof valueOrFactory === 'function'\n ? this._inner.getOrAdd(key, valueOrFactory as ResultMapValueFactory<TK, TSRC>)\n : this._inner.getOrAdd(key, valueOrFactory);\n\n if (result.isSuccess() && result.detail === 'added') {\n this._parent._clearCacheEntry(key);\n }\n return result;\n }\n\n /**\n * Checks if the map contains a key.\n * @param key - The key to check.\n * @returns `true` if the key exists, `false` otherwise.\n */\n public has(key: TK): boolean {\n return this._inner.has(key);\n }\n\n /**\n * Clears all entries from the map.\n * Clears the entire cache.\n */\n public clear(): void {\n this._parent._clearCache();\n this._inner.clear();\n }\n\n /**\n * Returns an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n public entries(): IterableIterator<KeyValueEntry<TK, TSRC>> {\n return this._inner.entries();\n }\n\n /**\n * Returns an iterator over the map keys.\n * @returns An iterator over the map keys.\n */\n public keys(): IterableIterator<TK> {\n return this._inner.keys();\n }\n\n /**\n * Returns an iterator over the map values.\n * @returns An iterator over the map values.\n */\n public values(): IterableIterator<TSRC> {\n return this._inner.values();\n }\n\n /**\n * Calls a callback for each entry in the map.\n * @param cb - The callback to call for each entry.\n * @param thisArg - Optional `this` argument for the callback.\n */\n public forEach(cb: ResultMapForEachCb<TK, TSRC>, thisArg?: unknown): void {\n this._inner.forEach(cb, thisArg);\n }\n\n /**\n * Gets an iterator over the map entries.\n * @returns An iterator over the map entries.\n */\n public [Symbol.iterator](): IterableIterator<KeyValueEntry<TK, TSRC>> {\n return this._inner[Symbol.iterator]();\n }\n\n /**\n * Gets a read-only version of this map.\n * @returns A read-only version of this map.\n */\n public toReadOnly(): IReadOnlyResultMap<TK, TSRC> {\n return this._inner.toReadOnly();\n }\n}\n\n/**\n * A result map that wraps an inner {@link Collections.IResultMap | IResultMap} of source type\n * and returns lazily-converted, cached values of a target type. Exposes the inner map\n * via a {@link Collections.CacheInvalidatingResultMapWrapper | source} property that\n * invalidates cache entries when mutations occur.\n * @public\n */\nexport class ConvertingResultMap<\n TK extends string,\n TSRC,\n TTARGET,\n TSRCMAP extends IResultMap<TK, TSRC> = IResultMap<TK, TSRC>\n> extends ReadOnlyConvertingResultMap<TK, TSRC, TTARGET> {\n /**\n * A wrapper around the inner map that invalidates cache entries when mutations occur.\n * Use this property to add, update, or delete source values.\n */\n public readonly source: CacheInvalidatingResultMapWrapper<TK, TSRC, TTARGET, TSRCMAP>;\n\n /**\n * The inner map, typed as the specific source map type.\n */\n protected readonly _typedInner: TSRCMAP;\n\n /**\n * Constructs a new {@link Collections.ConvertingResultMap | ConvertingResultMap}.\n * @param params - Parameters for constructing the map.\n */\n public constructor(params: IConvertingResultMapConstructorParams<TK, TSRC, TTARGET, TSRCMAP>) {\n super(params as IReadOnlyConvertingResultMapConstructorParams<TK, TSRC, TTARGET>);\n this._typedInner = params.inner;\n this.source = new CacheInvalidatingResultMapWrapper<TK, TSRC, TTARGET, TSRCMAP>(params.inner, this);\n }\n\n /**\n * Creates a new {@link Collections.ConvertingResultMap | ConvertingResultMap}.\n * @param params - Parameters for constructing the map.\n * @returns `Success` with the new map, or `Failure` with error details if an error occurred.\n */\n public static override create<\n TK extends string,\n TSRC,\n TTARGET,\n TSRCMAP extends IResultMap<TK, TSRC> = IResultMap<TK, TSRC>\n >(\n params: IConvertingResultMapConstructorParams<TK, TSRC, TTARGET, TSRCMAP>\n ): Result<ConvertingResultMap<TK, TSRC, TTARGET, TSRCMAP>> {\n return captureResult(() => new ConvertingResultMap(params));\n }\n\n /**\n * Clears a single entry from the cache.\n * This method is public to allow the cache-invalidating wrapper to call it.\n * @param key - The key to clear from the cache.\n * @internal\n */\n public override _clearCacheEntry(key: TK): void {\n super._clearCacheEntry(key);\n }\n\n /**\n * Clears all entries from the cache.\n * This method is public to allow the cache-invalidating wrapper to call it.\n * @internal\n */\n public override _clearCache(): void {\n super._clearCache();\n }\n}\n"]}
@@ -10,6 +10,7 @@ export * from './common';
10
10
  export * from './keyValueConverters';
11
11
  export * from './readonlyResultMap';
12
12
  export * from './readOnlyConvertingResultMap';
13
+ export * from './retainingRingBuffer';
13
14
  export * from './resultMap';
14
15
  export * from './resultMapValidator';
15
16
  export * from './validatingCollector';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -71,6 +71,7 @@ __exportStar(require("./common"), exports);
71
71
  __exportStar(require("./keyValueConverters"), exports);
72
72
  __exportStar(require("./readonlyResultMap"), exports);
73
73
  __exportStar(require("./readOnlyConvertingResultMap"), exports);
74
+ __exportStar(require("./retainingRingBuffer"), exports);
74
75
  __exportStar(require("./resultMap"), exports);
75
76
  __exportStar(require("./resultMapValidator"), exports);
76
77
  __exportStar(require("./validatingCollector"), exports);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/collections/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAAiC;AAqBxB,sBAAK;AAnBd,gDAA8B;AAC9B,wDAAsC;AACtC,wDAAsC;AACtC,8CAA4B;AAC5B,uDAAqC;AACrC,iEAA+C;AAC/C,kEAAgD;AAChD,2CAAyB;AACzB,uDAAqC;AACrC,sDAAoC;AACpC,gEAA8C;AAC9C,wDAAsC;AACtC,8CAA4B;AAC5B,uDAAqC;AACrC,wDAAsC;AACtC,kEAAgD;AAChD,wDAAsC;AACtC,wDAAsC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Utils from './utils';\n\nexport * from './collectible';\nexport * from './convertingCollector';\nexport * from './convertingResultMap';\nexport * from './collector';\nexport * from './collectorValidator';\nexport * from './convertingCollectorValidator';\nexport * from './validatingConvertingCollector';\nexport * from './common';\nexport * from './keyValueConverters';\nexport * from './readonlyResultMap';\nexport * from './readOnlyConvertingResultMap';\nexport * from './retainingRingBuffer';\nexport * from './resultMap';\nexport * from './resultMapValidator';\nexport * from './validatingCollector';\nexport * from './validatingConvertingResultMap';\nexport * from './validatingResultMap';\nexport * from './aggregatedResultMap';\n\nexport { Utils };\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyValueConverters.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/keyValueConverters.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,cAAc,EAGd,MAAM,EAGP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAc,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,mCAAmC,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IAC3F;;;OAGG;IACH,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAElF;;;OAGG;IACH,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;CACrF;AAED;;;;GAIG;AACH,qBAAa,kBAAkB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO;IACtE;;OAEG;IACH,SAAgB,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACrE;;OAEG;IACH,SAAgB,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAEvE;;;OA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C9C,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;YAC9B,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;iBACvB,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE;gBACf,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAClB,OAAO,IAAA,wBAAiB,EAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YACzC,CAAC,CAAC;iBACD,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,cAAc,CAAC,IAAA,cAAO,EAAC,SAAS,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AAhFD,gDAgFC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n DetailedResult,\n failWithDetail,\n MessageAggregator,\n Result,\n succeed,\n succeedWithDetail\n} from '../base';\nimport { Converter, ConverterFunc, Converters } from '../conversion';\nimport { Validator } from '../validation';\nimport { KeyValueEntry } from './common';\nimport { ResultMapResultDetail } from './readonlyResultMap';\n\n/**\n * Parameters for constructing a {@link Collections.KeyValueConverters | KeyValueConverters} instance.\n * @public\n */\nexport interface IKeyValueConverterConstructorParams<TK extends string = string, TV = unknown> {\n /**\n * Required key {@link Validator | validator}, {@link Converter | converter},\n * or {@link Conversion.ConverterFunc | converter function}.\n */\n key: Validator<TK, unknown> | Converter<TK, unknown> | ConverterFunc<TK, unknown>;\n\n /**\n * Required value {@link Validator | validator}, {@link Converter | converter},\n * or {@link Conversion.ConverterFunc | converter function}.\n */\n value: Validator<TV, unknown> | Converter<TV, unknown> | ConverterFunc<TV, unknown>;\n}\n\n/**\n * Helper class for converting strongly-typed keys, values, or entries\n * from unknown values.\n * @public\n */\nexport class KeyValueConverters<TK extends string = string, TV = unknown> {\n /**\n * Required key {@link Validator | validator} or {@link Converter | converter}.\n */\n public readonly key: Validator<TK, unknown> | Converter<TK, unknown>;\n /**\n * Required value {@link Validator | validator} or {@link Converter | converter}.\n */\n public readonly value: Validator<TV, unknown> | Converter<TV, unknown>;\n\n /**\n * Constructs a new key-value validator.\n * @param params - Key and value converters or validators.\n */\n public constructor({ key, value }: IKeyValueConverterConstructorParams<TK, TV>) {\n this.key = typeof key === 'function' ? Converters.generic(key) : key;\n this.value = typeof value === 'function' ? Converters.generic(value) : value;\n }\n\n /**\n * Converts a supplied unknown to a valid key value of type `<TK>`.\n * @param key - The unknown to be converted.\n * @returns `Success` with the converted key value and 'success' detail if the key is valid,\n * or `Failure` with an error message and 'invalid-key' detail if the key is invalid.\n */\n public convertKey(key: unknown): DetailedResult<TK, ResultMapResultDetail> {\n return this.key.convert(key).withFailureDetail('invalid-key');\n }\n\n /**\n * Converts a supplied unknown to a valid value of type `<TV>`.\n * @param key - The unknown to be converted.\n * @returns `Success` with the converted value and 'success' detail if the value is valid,\n * or `Failure` with an error message and 'invalid-value' detail if the value is invalid.\n */\n public convertValue(key: unknown): DetailedResult<TV, ResultMapResultDetail> {\n return this.value.convert(key).withFailureDetail('invalid-value');\n }\n\n /**\n * Converts a supplied unknown to a valid entry of type `[<TK>, <TV>]`.\n * @param entry - The unknown to be converted.\n * @returns `Success` with the converted entry and 'success' detail if the entry\n * is valid, or `Failure` with an error message and 'invalid-key' or 'invalid-value' detail if\n * the entry is invalid\n */\n public convertEntry(entry: unknown): DetailedResult<KeyValueEntry<TK, TV>, ResultMapResultDetail> {\n if (Array.isArray(entry) && entry.length === 2) {\n const errors = new MessageAggregator();\n const key = this.convertKey(entry[0]).aggregateError(errors).orDefault();\n const value = this.convertValue(entry[1]).aggregateError(errors).orDefault();\n if (key && value) {\n return succeedWithDetail([key, value], 'success');\n }\n const detail = key ? 'invalid-value' : 'invalid-key';\n return failWithDetail(`invalid entry: ${errors.toString()}`, detail);\n }\n /* c8 ignore next 2 */\n return failWithDetail(`malformed entry: \"${JSON.stringify(entry)}\"`, 'invalid-value');\n }\n\n /**\n * Converts a supplied iterable of unknowns to valid key-value pairs.\n * @param entries - The iterable of unknowns to be converted.\n * @returns `Success` with an array of converted key-value pairs if all entries are valid,\n * or `Failure` with an error message if any entry is invalid.\n */\n public convertEntries(entries: Iterable<unknown>): Result<KeyValueEntry<TK, TV>[]> {\n const errors = new MessageAggregator();\n const converted: KeyValueEntry<TK, TV>[] = [];\n for (const element of entries) {\n this.convertEntry(element)\n .onSuccess((e) => {\n converted.push(e);\n return succeedWithDetail(e, 'success');\n })\n .aggregateError(errors);\n }\n return errors.returnOrReport(succeed(converted));\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { DetailedResult, Result } from '../base';
2
- import { ILogger } from '../logging';
2
+ import { Converter } from '../conversion';
3
+ import { ILogger } from '../logging-interface';
3
4
  import { KeyValueEntry } from './common';
4
5
  import { IReadOnlyResultMap, ResultMapForEachCb, ResultMapResultDetail } from './readonlyResultMap';
5
6
  /**
@@ -15,6 +16,17 @@ export type ConvertingResultMapValueConverter<TK extends string, TSRC, TTARGET>
15
16
  * @public
16
17
  */
17
18
  export type ConversionErrorHandling = 'ignore' | 'warn' | 'fail';
19
+ /**
20
+ * Exhaustive list of all {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.
21
+ * @public
22
+ */
23
+ export declare const allConversionErrorHandling: readonly ConversionErrorHandling[];
24
+ /**
25
+ * A ready-made {@link Converter | Converter} for
26
+ * {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.
27
+ * @public
28
+ */
29
+ export declare const conversionErrorHandling: Converter<ConversionErrorHandling, ReadonlyArray<ConversionErrorHandling>>;
18
30
  /**
19
31
  * Parameters for constructing a {@link Collections.ReadOnlyConvertingResultMap | ReadOnlyConvertingResultMap}.
20
32
  * @public
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnlyConvertingResultMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/collections/readOnlyConvertingResultMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,cAAc,EAAkB,MAAM,EAAqB,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,SAAS,EAAc,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEpG;;;GAGG;AACH,MAAM,MAAM,iCAAiC,CAAC,EAAE,SAAS,MAAM,EAAE,IAAI,EAAE,OAAO,IAAI,CAChF,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,EAAE,KACJ,MAAM,CAAC,OAAO,CAAC,CAAC;AAErB;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAuBjE;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,uBAAuB,EAAkC,CAAC;AAE5G;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,C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OFTWARE.
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.ReadOnlyConvertingResultMap = void 0;
24
+ exports.ReadOnlyConvertingResultMap = exports.conversionErrorHandling = exports.allConversionErrorHandling = void 0;
25
25
  const base_1 = require("../base");
26
+ const conversion_1 = require("../conversion");
27
+ // Untyped (literal-tuple-inferred) source of truth for allConversionErrorHandling, kept separate from
28
+ // the widened public export below so the exhaustiveness check actually inspects the literal values
29
+ // instead of being widened away to {@link Collections.ConversionErrorHandling | ConversionErrorHandling} before the check runs.
30
+ const conversionErrorHandlingValues = ['ignore', 'warn', 'fail'];
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ const _conversionErrorHandlingExhaustivenessCheck = true;
33
+ /**
34
+ * Exhaustive list of all {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.
35
+ * @public
36
+ */
37
+ exports.allConversionErrorHandling = conversionErrorHandlingValues;
38
+ /**
39
+ * A ready-made {@link Converter | Converter} for
40
+ * {@link Collections.ConversionErrorHandling | ConversionErrorHandling} values.
41
+ * @public
42
+ */
43
+ exports.conversionErrorHandling = conversion_1.Converters.enumeratedValue(exports.allConversionErrorHandling);
26
44
  /**
27
45
  * A read-only result map that wraps an inner {@link Collections.IReadOnlyResultMap | IReadOnlyResultMap}
28
46
  * of source type and returns lazily-converted, cached values of a target type.