@fgv/ts-utils 5.0.0-2 → 5.0.0-20

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 (311) hide show
  1. package/.vscode/launch.json +16 -0
  2. package/.vscode/settings.json +36 -0
  3. package/config/api-extractor.json +343 -0
  4. package/config/rig.json +16 -0
  5. package/dist/ts-utils.d.ts +20 -8
  6. package/dist/tsdoc-metadata.json +1 -1
  7. package/lib/packlets/base/result.d.ts +8 -0
  8. package/lib/packlets/base/result.js +11 -0
  9. package/lib/packlets/hash/crcNormalizer.js +3 -1
  10. package/lib/packlets/validation/array.d.ts +2 -1
  11. package/lib/packlets/validation/array.js +2 -1
  12. package/lib/packlets/validation/common.d.ts +0 -8
  13. package/lib/packlets/validation/field.d.ts +1 -1
  14. package/lib/packlets/validation/field.js +1 -1
  15. package/lib/packlets/validation/genericValidator.d.ts +1 -6
  16. package/lib/packlets/validation/genericValidator.js +11 -11
  17. package/lib/packlets/validation/object.d.ts +1 -1
  18. package/lib/packlets/validation/object.js +1 -1
  19. package/lib/packlets/validation/oneOf.d.ts +2 -1
  20. package/lib/packlets/validation/oneOf.js +2 -1
  21. package/lib/packlets/validation/typeGuard.d.ts +3 -2
  22. package/lib/packlets/validation/typeGuard.js +2 -1
  23. package/lib/packlets/validation/validator.d.ts +7 -0
  24. package/lib/packlets/validation/validatorBase.d.ts +2 -1
  25. package/lib/packlets/validation/validatorBase.js +1 -1
  26. package/lib/packlets/validation/validators.d.ts +2 -2
  27. package/lib/packlets/validation/validators.js +3 -3
  28. package/lib/test/helpers/jest/helpers/fsHelpers.d.ts +52 -0
  29. package/lib/test/helpers/jest/helpers/fsHelpers.js +180 -0
  30. package/lib/test/helpers/jest/helpers/index.d.ts +2 -0
  31. package/lib/test/helpers/jest/helpers/index.js +18 -0
  32. package/lib/test/helpers/jest/index.d.ts +3 -0
  33. package/lib/test/helpers/jest/index.js +27 -0
  34. package/lib/test/helpers/jest/matchers/index.d.ts +16 -0
  35. package/lib/test/helpers/jest/matchers/index.js +19 -0
  36. package/lib/test/helpers/jest/matchers/toFail/index.d.ts +16 -0
  37. package/lib/test/helpers/jest/matchers/toFail/index.js +25 -0
  38. package/lib/test/helpers/jest/matchers/toFail/predicate.d.ts +4 -0
  39. package/lib/test/helpers/jest/matchers/toFail/predicate.js +9 -0
  40. package/lib/test/helpers/jest/matchers/toFailTest/index.d.ts +16 -0
  41. package/lib/test/helpers/jest/matchers/toFailTest/index.js +30 -0
  42. package/lib/test/helpers/jest/matchers/toFailTest/predicate.d.ts +3 -0
  43. package/lib/test/helpers/jest/matchers/toFailTest/predicate.js +12 -0
  44. package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.d.ts +17 -0
  45. package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/index.js +26 -0
  46. package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.d.ts +4 -0
  47. package/lib/test/helpers/jest/matchers/toFailTestAndMatchSnapshot/predicate.js +15 -0
  48. package/lib/test/helpers/jest/matchers/toFailTestWith/index.d.ts +18 -0
  49. package/lib/test/helpers/jest/matchers/toFailTestWith/index.js +31 -0
  50. package/lib/test/helpers/jest/matchers/toFailTestWith/predicate.d.ts +4 -0
  51. package/lib/test/helpers/jest/matchers/toFailTestWith/predicate.js +30 -0
  52. package/lib/test/helpers/jest/matchers/toFailWith/index.d.ts +18 -0
  53. package/lib/test/helpers/jest/matchers/toFailWith/index.js +29 -0
  54. package/lib/test/helpers/jest/matchers/toFailWith/predicate.d.ts +4 -0
  55. package/lib/test/helpers/jest/matchers/toFailWith/predicate.js +20 -0
  56. package/lib/test/helpers/jest/matchers/toFailWithDetail/index.d.ts +19 -0
  57. package/lib/test/helpers/jest/matchers/toFailWithDetail/index.js +29 -0
  58. package/lib/test/helpers/jest/matchers/toFailWithDetail/predicate.d.ts +4 -0
  59. package/lib/test/helpers/jest/matchers/toFailWithDetail/predicate.js +26 -0
  60. package/lib/test/helpers/jest/matchers/toSucceed/index.d.ts +16 -0
  61. package/lib/test/helpers/jest/matchers/toSucceed/index.js +25 -0
  62. package/lib/test/helpers/jest/matchers/toSucceed/predicate.d.ts +4 -0
  63. package/lib/test/helpers/jest/matchers/toSucceed/predicate.js +9 -0
  64. package/lib/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.d.ts +17 -0
  65. package/lib/test/helpers/jest/matchers/toSucceedAndMatchInlineSnapshot/index.js +26 -0
  66. package/lib/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.d.ts +17 -0
  67. package/lib/test/helpers/jest/matchers/toSucceedAndMatchSnapshot/index.js +26 -0
  68. package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/index.d.ts +19 -0
  69. package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/index.js +55 -0
  70. package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.d.ts +4 -0
  71. package/lib/test/helpers/jest/matchers/toSucceedAndSatisfy/predicate.js +21 -0
  72. package/lib/test/helpers/jest/matchers/toSucceedWith/index.d.ts +18 -0
  73. package/lib/test/helpers/jest/matchers/toSucceedWith/index.js +29 -0
  74. package/lib/test/helpers/jest/matchers/toSucceedWith/predicate.d.ts +4 -0
  75. package/lib/test/helpers/jest/matchers/toSucceedWith/predicate.js +16 -0
  76. package/lib/test/helpers/jest/matchers/toSucceedWithDetail/index.d.ts +18 -0
  77. package/lib/test/helpers/jest/matchers/toSucceedWithDetail/index.js +29 -0
  78. package/lib/test/helpers/jest/matchers/toSucceedWithDetail/predicate.d.ts +4 -0
  79. package/lib/test/helpers/jest/matchers/toSucceedWithDetail/predicate.js +21 -0
  80. package/lib/test/helpers/jest/resolvers/cli.d.ts +5 -0
  81. package/lib/test/helpers/jest/resolvers/cli.js +48 -0
  82. package/lib/test/helpers/jest/resolvers/ide.d.ts +5 -0
  83. package/lib/test/helpers/jest/resolvers/ide.js +48 -0
  84. package/lib/test/helpers/jest/ts-utils.d.ts +2 -0
  85. package/lib/test/helpers/jest/ts-utils.js +18 -0
  86. package/lib/test/helpers/jest/types/index.d.ts +79 -0
  87. package/lib/test/helpers/jest/types/index.js +4 -0
  88. package/lib/test/helpers/jest/utils/matcherHelpers.d.ts +6 -0
  89. package/lib/test/helpers/jest/utils/matcherHelpers.js +53 -0
  90. package/lib/test/helpers/jest/utils/snapshotResolver.d.ts +4 -0
  91. package/lib/test/helpers/jest/utils/snapshotResolver.js +19 -0
  92. package/lib/test/unit/collections/collectible.test.d.ts +2 -0
  93. package/lib/test/unit/collections/collector.test.d.ts +2 -0
  94. package/lib/test/unit/collections/collectors.test.d.ts +2 -0
  95. package/lib/test/unit/collections/convertingCollector.test.d.ts +2 -0
  96. package/lib/test/unit/collections/helpers.d.ts +44 -0
  97. package/lib/test/unit/collections/helpers.js +115 -0
  98. package/lib/test/unit/collections/resultMap.test.d.ts +2 -0
  99. package/lib/test/unit/collections/validatingCollector.test.d.ts +2 -0
  100. package/lib/test/unit/collections/validatingConvertingCollector.test.d.ts +2 -0
  101. package/lib/test/unit/collections/validatingResultMap.test.d.ts +2 -0
  102. package/lib/test/unit/converter.test.d.ts +2 -0
  103. package/lib/test/unit/converters.test.d.ts +2 -0
  104. package/lib/test/unit/defaultingConverter.test.d.ts +2 -0
  105. package/lib/test/unit/file-tree/fileItem.test.d.ts +2 -0
  106. package/lib/test/unit/file-tree/fileTree.test.d.ts +2 -0
  107. package/lib/test/unit/file-tree/fsTree.test.d.ts +2 -0
  108. package/lib/test/unit/file-tree/inMemoryTree.test.d.ts +2 -0
  109. package/lib/test/unit/file-tree/sample/rootFile.json +1 -0
  110. package/lib/test/unit/file-tree/sample/some/other/path/file2.json +1 -0
  111. package/lib/test/unit/file-tree/sample/some/path/below/file4.json +1 -0
  112. package/lib/test/unit/file-tree/sample/some/path/file1.json +1 -0
  113. package/lib/test/unit/file-tree/sample/some/path/file3.json +1 -0
  114. package/lib/test/unit/hash.test.d.ts +2 -0
  115. package/lib/test/unit/logger.test.d.ts +2 -0
  116. package/lib/test/unit/mapResults.test.d.ts +3 -0
  117. package/lib/test/unit/messageAggregator.test.d.ts +3 -0
  118. package/lib/test/unit/normalize.test.d.ts +2 -0
  119. package/lib/test/unit/result.test.d.ts +3 -0
  120. package/lib/test/unit/utils.test.d.ts +3 -0
  121. package/lib/test/unit/validation/array.test.d.ts +2 -0
  122. package/lib/test/unit/validation/boolean.test.d.ts +2 -0
  123. package/lib/test/unit/validation/genericValidator.test.d.ts +2 -0
  124. package/lib/test/unit/validation/number.test.d.ts +2 -0
  125. package/lib/test/unit/validation/object.test.d.ts +2 -0
  126. package/lib/test/unit/validation/oneOf.test.d.ts +2 -0
  127. package/lib/test/unit/validation/recordOf.test.d.ts +2 -0
  128. package/lib/test/unit/validation/recursiveValidation.test.d.ts +2 -0
  129. package/lib/test/unit/validation/string.test.d.ts +2 -0
  130. package/lib/test/unit/validation/traits.test.d.ts +2 -0
  131. package/lib/test/unit/validation/typeGuard.test.d.ts +2 -0
  132. package/lib/test/unit/validation/validators.test.d.ts +2 -0
  133. package/package.json +9 -9
  134. package/src/index.ts +63 -0
  135. package/src/packlets/base/brand.ts +28 -0
  136. package/src/packlets/base/index.ts +31 -0
  137. package/src/packlets/base/logger.ts +156 -0
  138. package/src/packlets/base/mapResults.ts +302 -0
  139. package/src/packlets/base/messageAggregator.ts +120 -0
  140. package/src/packlets/base/normalize.ts +144 -0
  141. package/src/packlets/base/result.ts +961 -0
  142. package/src/packlets/base/utils.ts +236 -0
  143. package/src/packlets/collections/collectible.ts +238 -0
  144. package/src/packlets/collections/collector.ts +273 -0
  145. package/src/packlets/collections/collectorValidator.ts +178 -0
  146. package/src/packlets/collections/common.ts +27 -0
  147. package/src/packlets/collections/convertingCollector.ts +223 -0
  148. package/src/packlets/collections/convertingCollectorValidator.ts +164 -0
  149. package/src/packlets/collections/index.ts +39 -0
  150. package/src/packlets/collections/keyValueConverters.ts +142 -0
  151. package/src/packlets/collections/readonlyResultMap.ts +99 -0
  152. package/src/packlets/collections/resultMap.ts +322 -0
  153. package/src/packlets/collections/resultMapValidator.ts +188 -0
  154. package/src/packlets/collections/utils.ts +33 -0
  155. package/src/packlets/collections/validatingCollector.ts +123 -0
  156. package/src/packlets/collections/validatingConvertingCollector.ts +113 -0
  157. package/src/packlets/collections/validatingResultMap.ts +94 -0
  158. package/src/packlets/conversion/baseConverter.ts +330 -0
  159. package/src/packlets/conversion/converter.ts +260 -0
  160. package/src/packlets/conversion/converters.ts +1039 -0
  161. package/src/packlets/conversion/defaultingConverter.ts +188 -0
  162. package/src/packlets/conversion/index.ts +30 -0
  163. package/src/packlets/conversion/objectConverter.ts +259 -0
  164. package/src/packlets/conversion/stringConverter.ts +165 -0
  165. package/src/packlets/file-tree/directoryItem.ts +84 -0
  166. package/src/packlets/file-tree/fileItem.ts +119 -0
  167. package/src/packlets/file-tree/fileTree.ts +152 -0
  168. package/src/packlets/file-tree/fileTreeAccessors.ts +176 -0
  169. package/src/packlets/file-tree/fsTree.ts +118 -0
  170. package/src/packlets/file-tree/in-memory/inMemoryTree.ts +171 -0
  171. package/src/packlets/file-tree/in-memory/index.ts +23 -0
  172. package/src/packlets/file-tree/in-memory/treeBuilder.ts +203 -0
  173. package/src/packlets/file-tree/index.ts +31 -0
  174. package/src/packlets/hash/crcNormalizer.ts +81 -0
  175. package/src/packlets/hash/hashingNormalizer.ts +102 -0
  176. package/src/packlets/hash/index.ts +24 -0
  177. package/src/packlets/validation/array.ts +84 -0
  178. package/src/packlets/validation/boolean.ts +63 -0
  179. package/src/packlets/validation/classes.ts +38 -0
  180. package/src/packlets/validation/common.ts +28 -0
  181. package/src/packlets/validation/field.ts +99 -0
  182. package/src/packlets/validation/genericValidator.ts +204 -0
  183. package/src/packlets/validation/index.ts +31 -0
  184. package/src/packlets/validation/number.ts +66 -0
  185. package/src/packlets/validation/object.ts +208 -0
  186. package/src/packlets/validation/oneOf.ts +78 -0
  187. package/src/packlets/validation/string.ts +66 -0
  188. package/src/packlets/validation/traits.ts +113 -0
  189. package/src/packlets/validation/typeGuard.ts +83 -0
  190. package/src/packlets/validation/validator.ts +157 -0
  191. package/src/packlets/validation/validatorBase.ts +66 -0
  192. package/src/packlets/validation/validators.ts +254 -0
  193. package/CHANGELOG.md +0 -135
  194. package/lib/index.d.ts.map +0 -1
  195. package/lib/index.js.map +0 -1
  196. package/lib/packlets/base/brand.d.ts.map +0 -1
  197. package/lib/packlets/base/brand.js.map +0 -1
  198. package/lib/packlets/base/index.d.ts.map +0 -1
  199. package/lib/packlets/base/index.js.map +0 -1
  200. package/lib/packlets/base/logger.d.ts.map +0 -1
  201. package/lib/packlets/base/logger.js.map +0 -1
  202. package/lib/packlets/base/mapResults.d.ts.map +0 -1
  203. package/lib/packlets/base/mapResults.js.map +0 -1
  204. package/lib/packlets/base/messageAggregator.d.ts.map +0 -1
  205. package/lib/packlets/base/messageAggregator.js.map +0 -1
  206. package/lib/packlets/base/normalize.d.ts.map +0 -1
  207. package/lib/packlets/base/normalize.js.map +0 -1
  208. package/lib/packlets/base/result.d.ts.map +0 -1
  209. package/lib/packlets/base/result.js.map +0 -1
  210. package/lib/packlets/base/utils.d.ts.map +0 -1
  211. package/lib/packlets/base/utils.js.map +0 -1
  212. package/lib/packlets/collections/collectible.d.ts.map +0 -1
  213. package/lib/packlets/collections/collectible.js.map +0 -1
  214. package/lib/packlets/collections/collector.d.ts.map +0 -1
  215. package/lib/packlets/collections/collector.js.map +0 -1
  216. package/lib/packlets/collections/collectorValidator.d.ts.map +0 -1
  217. package/lib/packlets/collections/collectorValidator.js.map +0 -1
  218. package/lib/packlets/collections/common.d.ts.map +0 -1
  219. package/lib/packlets/collections/common.js.map +0 -1
  220. package/lib/packlets/collections/convertingCollector.d.ts.map +0 -1
  221. package/lib/packlets/collections/convertingCollector.js.map +0 -1
  222. package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +0 -1
  223. package/lib/packlets/collections/convertingCollectorValidator.js.map +0 -1
  224. package/lib/packlets/collections/index.d.ts.map +0 -1
  225. package/lib/packlets/collections/index.js.map +0 -1
  226. package/lib/packlets/collections/keyValueConverters.d.ts.map +0 -1
  227. package/lib/packlets/collections/keyValueConverters.js.map +0 -1
  228. package/lib/packlets/collections/readonlyResultMap.d.ts.map +0 -1
  229. package/lib/packlets/collections/readonlyResultMap.js.map +0 -1
  230. package/lib/packlets/collections/resultMap.d.ts.map +0 -1
  231. package/lib/packlets/collections/resultMap.js.map +0 -1
  232. package/lib/packlets/collections/resultMapValidator.d.ts.map +0 -1
  233. package/lib/packlets/collections/resultMapValidator.js.map +0 -1
  234. package/lib/packlets/collections/utils.d.ts.map +0 -1
  235. package/lib/packlets/collections/utils.js.map +0 -1
  236. package/lib/packlets/collections/validatingCollector.d.ts.map +0 -1
  237. package/lib/packlets/collections/validatingCollector.js.map +0 -1
  238. package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +0 -1
  239. package/lib/packlets/collections/validatingConvertingCollector.js.map +0 -1
  240. package/lib/packlets/collections/validatingResultMap.d.ts.map +0 -1
  241. package/lib/packlets/collections/validatingResultMap.js.map +0 -1
  242. package/lib/packlets/conversion/baseConverter.d.ts.map +0 -1
  243. package/lib/packlets/conversion/baseConverter.js.map +0 -1
  244. package/lib/packlets/conversion/converter.d.ts.map +0 -1
  245. package/lib/packlets/conversion/converter.js.map +0 -1
  246. package/lib/packlets/conversion/converters.d.ts.map +0 -1
  247. package/lib/packlets/conversion/converters.js.map +0 -1
  248. package/lib/packlets/conversion/defaultingConverter.d.ts.map +0 -1
  249. package/lib/packlets/conversion/defaultingConverter.js.map +0 -1
  250. package/lib/packlets/conversion/index.d.ts.map +0 -1
  251. package/lib/packlets/conversion/index.js.map +0 -1
  252. package/lib/packlets/conversion/objectConverter.d.ts.map +0 -1
  253. package/lib/packlets/conversion/objectConverter.js.map +0 -1
  254. package/lib/packlets/conversion/stringConverter.d.ts.map +0 -1
  255. package/lib/packlets/conversion/stringConverter.js.map +0 -1
  256. package/lib/packlets/file-tree/directoryItem.d.ts.map +0 -1
  257. package/lib/packlets/file-tree/directoryItem.js.map +0 -1
  258. package/lib/packlets/file-tree/fileItem.d.ts.map +0 -1
  259. package/lib/packlets/file-tree/fileItem.js.map +0 -1
  260. package/lib/packlets/file-tree/fileTree.d.ts.map +0 -1
  261. package/lib/packlets/file-tree/fileTree.js.map +0 -1
  262. package/lib/packlets/file-tree/fileTreeAccessors.d.ts.map +0 -1
  263. package/lib/packlets/file-tree/fileTreeAccessors.js.map +0 -1
  264. package/lib/packlets/file-tree/fsTree.d.ts.map +0 -1
  265. package/lib/packlets/file-tree/fsTree.js.map +0 -1
  266. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts.map +0 -1
  267. package/lib/packlets/file-tree/in-memory/inMemoryTree.js.map +0 -1
  268. package/lib/packlets/file-tree/in-memory/index.d.ts.map +0 -1
  269. package/lib/packlets/file-tree/in-memory/index.js.map +0 -1
  270. package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts.map +0 -1
  271. package/lib/packlets/file-tree/in-memory/treeBuilder.js.map +0 -1
  272. package/lib/packlets/file-tree/index.d.ts.map +0 -1
  273. package/lib/packlets/file-tree/index.js.map +0 -1
  274. package/lib/packlets/hash/crcNormalizer.d.ts.map +0 -1
  275. package/lib/packlets/hash/crcNormalizer.js.map +0 -1
  276. package/lib/packlets/hash/hashingNormalizer.d.ts.map +0 -1
  277. package/lib/packlets/hash/hashingNormalizer.js.map +0 -1
  278. package/lib/packlets/hash/index.d.ts.map +0 -1
  279. package/lib/packlets/hash/index.js.map +0 -1
  280. package/lib/packlets/validation/array.d.ts.map +0 -1
  281. package/lib/packlets/validation/array.js.map +0 -1
  282. package/lib/packlets/validation/boolean.d.ts.map +0 -1
  283. package/lib/packlets/validation/boolean.js.map +0 -1
  284. package/lib/packlets/validation/classes.d.ts.map +0 -1
  285. package/lib/packlets/validation/classes.js.map +0 -1
  286. package/lib/packlets/validation/common.d.ts.map +0 -1
  287. package/lib/packlets/validation/common.js.map +0 -1
  288. package/lib/packlets/validation/field.d.ts.map +0 -1
  289. package/lib/packlets/validation/field.js.map +0 -1
  290. package/lib/packlets/validation/genericValidator.d.ts.map +0 -1
  291. package/lib/packlets/validation/genericValidator.js.map +0 -1
  292. package/lib/packlets/validation/index.d.ts.map +0 -1
  293. package/lib/packlets/validation/index.js.map +0 -1
  294. package/lib/packlets/validation/number.d.ts.map +0 -1
  295. package/lib/packlets/validation/number.js.map +0 -1
  296. package/lib/packlets/validation/object.d.ts.map +0 -1
  297. package/lib/packlets/validation/object.js.map +0 -1
  298. package/lib/packlets/validation/oneOf.d.ts.map +0 -1
  299. package/lib/packlets/validation/oneOf.js.map +0 -1
  300. package/lib/packlets/validation/string.d.ts.map +0 -1
  301. package/lib/packlets/validation/string.js.map +0 -1
  302. package/lib/packlets/validation/traits.d.ts.map +0 -1
  303. package/lib/packlets/validation/traits.js.map +0 -1
  304. package/lib/packlets/validation/typeGuard.d.ts.map +0 -1
  305. package/lib/packlets/validation/typeGuard.js.map +0 -1
  306. package/lib/packlets/validation/validator.d.ts.map +0 -1
  307. package/lib/packlets/validation/validator.js.map +0 -1
  308. package/lib/packlets/validation/validatorBase.d.ts.map +0 -1
  309. package/lib/packlets/validation/validatorBase.js.map +0 -1
  310. package/lib/packlets/validation/validators.d.ts.map +0 -1
  311. package/lib/packlets/validation/validators.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=fileItem.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=fileTree.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=fsTree.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=inMemoryTree.test.d.ts.map
@@ -0,0 +1 @@
1
+ { "myNameIs": "root" }
@@ -0,0 +1 @@
1
+ { "helloMyNameIs": "file2" }
@@ -0,0 +1 @@
1
+ { "helloMyNameIs": "file4" }
@@ -0,0 +1 @@
1
+ { "helloMyNameIs": "file1" }
@@ -0,0 +1 @@
1
+ { "helloMyNameIs": "file3" }
@@ -0,0 +1,2 @@
1
+ import '../helpers/jest';
2
+ //# sourceMappingURL=hash.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../helpers/jest';
2
+ //# sourceMappingURL=logger.test.d.ts.map
@@ -0,0 +1,3 @@
1
+ import 'jest-extended';
2
+ import '../helpers/jest';
3
+ //# sourceMappingURL=mapResults.test.d.ts.map
@@ -0,0 +1,3 @@
1
+ import 'jest-extended';
2
+ import '../helpers/jest';
3
+ //# sourceMappingURL=messageAggregator.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../helpers/jest';
2
+ //# sourceMappingURL=normalize.test.d.ts.map
@@ -0,0 +1,3 @@
1
+ import 'jest-extended';
2
+ import '../helpers/jest';
3
+ //# sourceMappingURL=result.test.d.ts.map
@@ -0,0 +1,3 @@
1
+ import 'jest-extended';
2
+ import '../helpers/jest';
3
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=array.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=boolean.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=genericValidator.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=number.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=object.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=oneOf.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=recordOf.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=recursiveValidation.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=string.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=traits.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=typeGuard.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ import '../../helpers/jest';
2
+ //# sourceMappingURL=validators.test.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-utils",
3
- "version": "5.0.0-2",
3
+ "version": "5.0.0-20",
4
4
  "description": "Assorted Typescript Utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-utils.d.ts",
@@ -17,10 +17,10 @@
17
17
  "homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-utils#readme",
18
18
  "devDependencies": {
19
19
  "@jest/expect-utils": "^29.7.0",
20
- "@microsoft/api-documenter": "^7.26.29",
21
- "@microsoft/api-extractor": "^7.49.1",
20
+ "@microsoft/api-documenter": "^7.26.31",
21
+ "@microsoft/api-extractor": "^7.52.10",
22
22
  "@types/jest": "^29.5.14",
23
- "@types/luxon": "^3.6.2",
23
+ "@types/luxon": "^3.7.1",
24
24
  "@types/mustache": "^4.2.5",
25
25
  "@types/node": "^20.14.9",
26
26
  "@typescript-eslint/eslint-plugin": "^7.14.1",
@@ -33,16 +33,16 @@
33
33
  "jest-extended": "^4.0.2",
34
34
  "jest-matcher-utils": "^29.7.0",
35
35
  "rimraf": "^5.0.7",
36
- "ts-jest": "^29.4.0",
36
+ "ts-jest": "^29.4.1",
37
37
  "ts-node": "^10.9.2",
38
- "typescript": "^5.7.3",
38
+ "typescript": "^5.8.3",
39
39
  "eslint-plugin-n": "^16.6.2",
40
40
  "jest-snapshot": "~29.7.0",
41
- "@rushstack/heft": "~0.74.0",
42
- "@rushstack/heft-node-rig": "~2.9.0",
41
+ "@rushstack/heft": "~0.74.2",
42
+ "@rushstack/heft-node-rig": "~2.9.3",
43
43
  "@rushstack/eslint-config": "~4.4.0",
44
44
  "@types/heft-jest": "1.0.6",
45
- "@rushstack/heft-jest-plugin": "~0.16.9",
45
+ "@rushstack/heft-jest-plugin": "~0.16.11",
46
46
  "eslint-plugin-tsdoc": "~0.4.0"
47
47
  },
48
48
  "scripts": {
package/src/index.ts ADDED
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Copyright (c) 2020 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ import * as Collections from './packlets/collections';
24
+ import * as Conversion from './packlets/conversion';
25
+ import * as Hash from './packlets/hash';
26
+ import * as FileTree from './packlets/file-tree';
27
+ import * as Validation from './packlets/validation';
28
+
29
+ import {
30
+ Collector,
31
+ ICollectible,
32
+ ConvertingCollector,
33
+ IReadOnlyResultMap,
34
+ ResultMap,
35
+ ValidatingCollector,
36
+ ValidatingConvertingCollector,
37
+ ValidatingResultMap
38
+ } from './packlets/collections';
39
+ import { Converter, Converters, ObjectConverter, StringConverter } from './packlets/conversion';
40
+ import { Validator, Validators } from './packlets/validation';
41
+
42
+ export * from './packlets/base';
43
+ export {
44
+ Collections,
45
+ Collector,
46
+ ConvertingCollector,
47
+ Conversion,
48
+ Converter,
49
+ Converters,
50
+ FileTree,
51
+ Hash,
52
+ ICollectible,
53
+ IReadOnlyResultMap,
54
+ ObjectConverter,
55
+ ResultMap,
56
+ StringConverter,
57
+ ValidatingCollector,
58
+ ValidatingConvertingCollector,
59
+ ValidatingResultMap,
60
+ Validation,
61
+ Validator,
62
+ Validators
63
+ };
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright (c) 2021 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ /**
24
+ * Helper type to brand a simple type to prevent inappropriate use
25
+ * @public
26
+ */
27
+ // eslint-disable-next-line @typescript-eslint/naming-convention
28
+ export type Brand<T, B> = T & { __brand: B };
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright (c) 2020 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ import * as Logging from './logger';
24
+
25
+ export * from './brand';
26
+ export * from './mapResults';
27
+ export * from './messageAggregator';
28
+ export { Normalizer } from './normalize';
29
+ export * from './result';
30
+ export * from './utils';
31
+ export { Logging };
@@ -0,0 +1,156 @@
1
+ /*
2
+ * Copyright (c) 2020 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+ import { Failure, Success, fail, succeed } from './result';
23
+
24
+ /**
25
+ * @public
26
+ */
27
+ export type LogLevel = 'detail' | 'info' | 'warning' | 'error' | 'silent';
28
+
29
+ /**
30
+ * @public
31
+ */
32
+ // eslint-disable-next-line @typescript-eslint/naming-convention
33
+ export interface Logger {
34
+ log(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
35
+ detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
36
+ info(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
37
+ warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined>;
38
+ warnAndFail<T>(message?: unknown, ...parameters: unknown[]): Failure<T>;
39
+ error<T>(message?: unknown, ...parameters: unknown[]): Failure<T>;
40
+ }
41
+
42
+ /**
43
+ * @public
44
+ */
45
+ export abstract class LoggerBase {
46
+ public logLevel: LogLevel = 'info';
47
+
48
+ public constructor(logLevel?: LogLevel) {
49
+ this.logLevel = logLevel ?? 'info';
50
+ }
51
+
52
+ public detail(message?: unknown, ...parameters: unknown[]): Success<string | undefined> {
53
+ if (this.logLevel === 'detail') {
54
+ return this.log(message, parameters);
55
+ }
56
+ return succeed(undefined);
57
+ }
58
+
59
+ public info(message?: unknown, ...parameters: unknown[]): Success<string | undefined> {
60
+ if (this.logLevel === 'detail' || this.logLevel === 'info') {
61
+ return this.log(message, parameters);
62
+ }
63
+ return succeed(undefined);
64
+ }
65
+
66
+ public warn(message?: unknown, ...parameters: unknown[]): Success<string | undefined> {
67
+ if (this.logLevel !== 'error' && this.logLevel !== 'silent') {
68
+ return this.log(message, parameters);
69
+ }
70
+ return succeed(undefined);
71
+ }
72
+
73
+ public warnAndFail<T>(message?: unknown, ...parameters: unknown[]): Failure<T> {
74
+ const formatted = this._format(message, ...parameters);
75
+ if (this.logLevel !== 'error' && this.logLevel !== 'silent') {
76
+ const result = this.log(formatted);
77
+ return fail(result.value ?? formatted);
78
+ }
79
+ return fail(formatted);
80
+ }
81
+
82
+ public error<T>(message?: unknown, ...parameters: unknown[]): Failure<T> {
83
+ const formatted = this._format(message, ...parameters);
84
+ if (this.logLevel !== 'silent') {
85
+ const result = this.log(formatted);
86
+ return fail(result.value ?? formatted);
87
+ }
88
+ return fail(formatted);
89
+ }
90
+
91
+ public log(message?: unknown, ...parameters: unknown[]): Success<string | undefined> {
92
+ const messageString = this._format(message, ...parameters);
93
+ if (this.logLevel === 'silent') {
94
+ return this._innerSilent(messageString);
95
+ }
96
+ return this._innerLog(messageString);
97
+ }
98
+
99
+ protected _format(message?: unknown, ...parameters: unknown[]): string {
100
+ const raw = [message, ...parameters];
101
+ const filtered = raw.filter((m): m is string => m !== undefined);
102
+ const strings = filtered.map((m) => m.toString());
103
+ const joined = strings.join('');
104
+ return joined;
105
+ }
106
+
107
+ protected _innerSilent(__message: string): Success<string | undefined> {
108
+ return succeed(undefined);
109
+ }
110
+
111
+ protected abstract _innerLog(message: string): Success<string | undefined>;
112
+ }
113
+
114
+ /**
115
+ * @public
116
+ */
117
+ export class InMemoryLogger extends LoggerBase {
118
+ protected _messages: string[] = [];
119
+ protected _silent: string[] = [];
120
+
121
+ public constructor(logLevel?: LogLevel) {
122
+ super(logLevel);
123
+ }
124
+
125
+ public get messages(): string[] {
126
+ return this._messages;
127
+ }
128
+ public get silent(): string[] {
129
+ return this._silent;
130
+ }
131
+
132
+ public clear(): void {
133
+ this._messages = [];
134
+ this._silent = [];
135
+ }
136
+
137
+ protected _innerLog(message: string): Success<string | undefined> {
138
+ this._messages.push(message);
139
+ return succeed(message);
140
+ }
141
+
142
+ protected _innerSilent(message: string): Success<string | undefined> {
143
+ this._silent.push(message);
144
+ return succeed(undefined);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * @public
150
+ */
151
+ export class NoOpLogger extends LoggerBase {
152
+ protected _innerLog(message: string): Success<string | undefined> {
153
+ // no-op
154
+ return succeed(message);
155
+ }
156
+ }