liminal 0.1.0-beta.25

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 (519) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +26 -0
  3. package/esm/_dnt.shims.d.ts +2 -0
  4. package/esm/_dnt.shims.d.ts.map +1 -0
  5. package/esm/_dnt.shims.js +58 -0
  6. package/esm/_dnt.shims.js.map +1 -0
  7. package/esm/client/Adapter.d.ts +46 -0
  8. package/esm/client/Adapter.d.ts.map +1 -0
  9. package/esm/client/Adapter.js +2 -0
  10. package/esm/client/Adapter.js.map +1 -0
  11. package/esm/client/Liminal.d.ts +19 -0
  12. package/esm/client/Liminal.d.ts.map +1 -0
  13. package/esm/client/Liminal.js +154 -0
  14. package/esm/client/Liminal.js.map +1 -0
  15. package/esm/client/Tool.d.ts +15 -0
  16. package/esm/client/Tool.d.ts.map +1 -0
  17. package/esm/client/Tool.js +23 -0
  18. package/esm/client/Tool.js.map +1 -0
  19. package/esm/client/constants.d.ts +2 -0
  20. package/esm/client/constants.d.ts.map +1 -0
  21. package/esm/client/constants.js +7 -0
  22. package/esm/client/constants.js.map +1 -0
  23. package/esm/client/mod.d.ts +5 -0
  24. package/esm/client/mod.d.ts.map +1 -0
  25. package/esm/client/mod.js +6 -0
  26. package/esm/client/mod.js.map +1 -0
  27. package/esm/core/DescriptionContext.d.ts +11 -0
  28. package/esm/core/DescriptionContext.d.ts.map +1 -0
  29. package/esm/core/DescriptionContext.js +103 -0
  30. package/esm/core/DescriptionContext.js.map +1 -0
  31. package/esm/core/L.d.ts +4 -0
  32. package/esm/core/L.d.ts.map +1 -0
  33. package/esm/core/L.js +4 -0
  34. package/esm/core/L.js.map +1 -0
  35. package/esm/core/ReduceDependencies.d.ts +6 -0
  36. package/esm/core/ReduceDependencies.d.ts.map +1 -0
  37. package/esm/core/ReduceDependencies.js +2 -0
  38. package/esm/core/ReduceDependencies.js.map +1 -0
  39. package/esm/core/Type.d.ts +30 -0
  40. package/esm/core/Type.d.ts.map +1 -0
  41. package/esm/core/Type.js +2 -0
  42. package/esm/core/Type.js.map +1 -0
  43. package/esm/core/TypeVisitor.d.ts +15 -0
  44. package/esm/core/TypeVisitor.d.ts.map +1 -0
  45. package/esm/core/TypeVisitor.js +12 -0
  46. package/esm/core/TypeVisitor.js.map +1 -0
  47. package/esm/core/annotations/Annotation.d.ts +7 -0
  48. package/esm/core/annotations/Annotation.d.ts.map +1 -0
  49. package/esm/core/annotations/Annotation.js +2 -0
  50. package/esm/core/annotations/Annotation.js.map +1 -0
  51. package/esm/core/annotations/Assertion.d.ts +8 -0
  52. package/esm/core/annotations/Assertion.d.ts.map +1 -0
  53. package/esm/core/annotations/Assertion.js +8 -0
  54. package/esm/core/annotations/Assertion.js.map +1 -0
  55. package/esm/core/annotations/Description.d.ts +7 -0
  56. package/esm/core/annotations/Description.d.ts.map +1 -0
  57. package/esm/core/annotations/Description.js +8 -0
  58. package/esm/core/annotations/Description.js.map +1 -0
  59. package/esm/core/annotations/Param.d.ts +13 -0
  60. package/esm/core/annotations/Param.d.ts.map +1 -0
  61. package/esm/core/annotations/Param.js +11 -0
  62. package/esm/core/annotations/Param.js.map +1 -0
  63. package/esm/core/annotations/Template.d.ts +10 -0
  64. package/esm/core/annotations/Template.d.ts.map +1 -0
  65. package/esm/core/annotations/Template.js +2 -0
  66. package/esm/core/annotations/Template.js.map +1 -0
  67. package/esm/core/annotations/mod.d.ts +6 -0
  68. package/esm/core/annotations/mod.d.ts.map +1 -0
  69. package/esm/core/annotations/mod.js +7 -0
  70. package/esm/core/annotations/mod.js.map +1 -0
  71. package/esm/core/assert.d.ts +22 -0
  72. package/esm/core/assert.d.ts.map +1 -0
  73. package/esm/core/assert.js +155 -0
  74. package/esm/core/assert.js.map +1 -0
  75. package/esm/core/declareIntrinsic.d.ts +4 -0
  76. package/esm/core/declareIntrinsic.d.ts.map +1 -0
  77. package/esm/core/declareIntrinsic.js +26 -0
  78. package/esm/core/declareIntrinsic.js.map +1 -0
  79. package/esm/core/deserialize.d.ts +3 -0
  80. package/esm/core/deserialize.d.ts.map +1 -0
  81. package/esm/core/deserialize.js +32 -0
  82. package/esm/core/deserialize.js.map +1 -0
  83. package/esm/core/display.d.ts +3 -0
  84. package/esm/core/display.d.ts.map +1 -0
  85. package/esm/core/display.js +75 -0
  86. package/esm/core/display.js.map +1 -0
  87. package/esm/core/inspect.node.d.ts +5 -0
  88. package/esm/core/inspect.node.d.ts.map +1 -0
  89. package/esm/core/inspect.node.js +7 -0
  90. package/esm/core/inspect.node.js.map +1 -0
  91. package/esm/core/intrinsics.d.ts +19 -0
  92. package/esm/core/intrinsics.d.ts.map +1 -0
  93. package/esm/core/intrinsics.js +64 -0
  94. package/esm/core/intrinsics.js.map +1 -0
  95. package/esm/core/intrinsics_util.d.ts +6 -0
  96. package/esm/core/intrinsics_util.d.ts.map +1 -0
  97. package/esm/core/intrinsics_util.js +46 -0
  98. package/esm/core/intrinsics_util.js.map +1 -0
  99. package/esm/core/isType.d.ts +4 -0
  100. package/esm/core/isType.d.ts.map +1 -0
  101. package/esm/core/isType.js +18 -0
  102. package/esm/core/isType.js.map +1 -0
  103. package/esm/core/mod.d.ts +13 -0
  104. package/esm/core/mod.d.ts.map +1 -0
  105. package/esm/core/mod.js +14 -0
  106. package/esm/core/mod.js.map +1 -0
  107. package/esm/core/signature.d.ts +4 -0
  108. package/esm/core/signature.d.ts.map +1 -0
  109. package/esm/core/signature.js +93 -0
  110. package/esm/core/signature.js.map +1 -0
  111. package/esm/core/utility/Flatten.d.ts +8 -0
  112. package/esm/core/utility/Flatten.d.ts.map +1 -0
  113. package/esm/core/utility/Flatten.js +6 -0
  114. package/esm/core/utility/Flatten.js.map +1 -0
  115. package/esm/core/utility/Intersection.d.ts +12 -0
  116. package/esm/core/utility/Intersection.d.ts.map +1 -0
  117. package/esm/core/utility/Intersection.js +5 -0
  118. package/esm/core/utility/Intersection.js.map +1 -0
  119. package/esm/core/utility/Option.d.ts +3 -0
  120. package/esm/core/utility/Option.d.ts.map +1 -0
  121. package/esm/core/utility/Option.js +5 -0
  122. package/esm/core/utility/Option.js.map +1 -0
  123. package/esm/core/utility/Record.d.ts +3 -0
  124. package/esm/core/utility/Record.d.ts.map +1 -0
  125. package/esm/core/utility/Record.js +6 -0
  126. package/esm/core/utility/Record.js.map +1 -0
  127. package/esm/core/utility/Set.d.ts +4 -0
  128. package/esm/core/utility/Set.d.ts.map +1 -0
  129. package/esm/core/utility/Set.js +7 -0
  130. package/esm/core/utility/Set.js.map +1 -0
  131. package/esm/core/utility/TaggedUnion.d.ts +13 -0
  132. package/esm/core/utility/TaggedUnion.d.ts.map +1 -0
  133. package/esm/core/utility/TaggedUnion.js +8 -0
  134. package/esm/core/utility/TaggedUnion.js.map +1 -0
  135. package/esm/core/utility/Tuple.d.ts +9 -0
  136. package/esm/core/utility/Tuple.d.ts.map +1 -0
  137. package/esm/core/utility/Tuple.js +11 -0
  138. package/esm/core/utility/Tuple.js.map +1 -0
  139. package/esm/core/utility/mod.d.ts +8 -0
  140. package/esm/core/utility/mod.d.ts.map +1 -0
  141. package/esm/core/utility/mod.js +9 -0
  142. package/esm/core/utility/mod.js.map +1 -0
  143. package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts +29 -0
  144. package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.d.ts.map +1 -0
  145. package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.js +47 -0
  146. package/esm/deps/jsr.io/@std/assert/1.0.10/almost_equals.js.map +1 -0
  147. package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts +24 -0
  148. package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.d.ts.map +1 -0
  149. package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.js +47 -0
  150. package/esm/deps/jsr.io/@std/assert/1.0.10/array_includes.js.map +1 -0
  151. package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts +16 -0
  152. package/esm/deps/jsr.io/@std/assert/1.0.10/assert.d.ts.map +1 -0
  153. package/esm/deps/jsr.io/@std/assert/1.0.10/assert.js +23 -0
  154. package/esm/deps/jsr.io/@std/assert/1.0.10/assert.js.map +1 -0
  155. package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts +26 -0
  156. package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.d.ts.map +1 -0
  157. package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.js +31 -0
  158. package/esm/deps/jsr.io/@std/assert/1.0.10/assertion_error.js.map +1 -0
  159. package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts +17 -0
  160. package/esm/deps/jsr.io/@std/assert/1.0.10/equal.d.ts.map +1 -0
  161. package/esm/deps/jsr.io/@std/assert/1.0.10/equal.js +184 -0
  162. package/esm/deps/jsr.io/@std/assert/1.0.10/equal.js.map +1 -0
  163. package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts +35 -0
  164. package/esm/deps/jsr.io/@std/assert/1.0.10/equals.d.ts.map +1 -0
  165. package/esm/deps/jsr.io/@std/assert/1.0.10/equals.js +59 -0
  166. package/esm/deps/jsr.io/@std/assert/1.0.10/equals.js.map +1 -0
  167. package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts +18 -0
  168. package/esm/deps/jsr.io/@std/assert/1.0.10/exists.d.ts.map +1 -0
  169. package/esm/deps/jsr.io/@std/assert/1.0.10/exists.js +28 -0
  170. package/esm/deps/jsr.io/@std/assert/1.0.10/exists.js.map +1 -0
  171. package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts +15 -0
  172. package/esm/deps/jsr.io/@std/assert/1.0.10/fail.d.ts.map +1 -0
  173. package/esm/deps/jsr.io/@std/assert/1.0.10/fail.js +21 -0
  174. package/esm/deps/jsr.io/@std/assert/1.0.10/fail.js.map +1 -0
  175. package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts +18 -0
  176. package/esm/deps/jsr.io/@std/assert/1.0.10/false.d.ts.map +1 -0
  177. package/esm/deps/jsr.io/@std/assert/1.0.10/false.js +23 -0
  178. package/esm/deps/jsr.io/@std/assert/1.0.10/false.js.map +1 -0
  179. package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts +20 -0
  180. package/esm/deps/jsr.io/@std/assert/1.0.10/greater.d.ts.map +1 -0
  181. package/esm/deps/jsr.io/@std/assert/1.0.10/greater.js +30 -0
  182. package/esm/deps/jsr.io/@std/assert/1.0.10/greater.js.map +1 -0
  183. package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts +20 -0
  184. package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.d.ts.map +1 -0
  185. package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.js +30 -0
  186. package/esm/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.js.map +1 -0
  187. package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts +23 -0
  188. package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.d.ts.map +1 -0
  189. package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.js +53 -0
  190. package/esm/deps/jsr.io/@std/assert/1.0.10/instance_of.js.map +1 -0
  191. package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts +25 -0
  192. package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.d.ts.map +1 -0
  193. package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.js +54 -0
  194. package/esm/deps/jsr.io/@std/assert/1.0.10/is_error.js.map +1 -0
  195. package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts +19 -0
  196. package/esm/deps/jsr.io/@std/assert/1.0.10/less.d.ts.map +1 -0
  197. package/esm/deps/jsr.io/@std/assert/1.0.10/less.js +29 -0
  198. package/esm/deps/jsr.io/@std/assert/1.0.10/less.js.map +1 -0
  199. package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts +20 -0
  200. package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.d.ts.map +1 -0
  201. package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.js +30 -0
  202. package/esm/deps/jsr.io/@std/assert/1.0.10/less_or_equal.js.map +1 -0
  203. package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts +18 -0
  204. package/esm/deps/jsr.io/@std/assert/1.0.10/match.d.ts.map +1 -0
  205. package/esm/deps/jsr.io/@std/assert/1.0.10/match.js +27 -0
  206. package/esm/deps/jsr.io/@std/assert/1.0.10/match.js.map +1 -0
  207. package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts +44 -0
  208. package/esm/deps/jsr.io/@std/assert/1.0.10/mod.d.ts.map +1 -0
  209. package/esm/deps/jsr.io/@std/assert/1.0.10/mod.js +46 -0
  210. package/esm/deps/jsr.io/@std/assert/1.0.10/mod.js.map +1 -0
  211. package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts +21 -0
  212. package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.d.ts.map +1 -0
  213. package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.js +34 -0
  214. package/esm/deps/jsr.io/@std/assert/1.0.10/not_equals.js.map +1 -0
  215. package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts +20 -0
  216. package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.d.ts.map +1 -0
  217. package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.js +30 -0
  218. package/esm/deps/jsr.io/@std/assert/1.0.10/not_instance_of.js.map +1 -0
  219. package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts +18 -0
  220. package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.d.ts.map +1 -0
  221. package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.js +27 -0
  222. package/esm/deps/jsr.io/@std/assert/1.0.10/not_match.js.map +1 -0
  223. package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts +23 -0
  224. package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.d.ts.map +1 -0
  225. package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.js +33 -0
  226. package/esm/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.js.map +1 -0
  227. package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts +29 -0
  228. package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.d.ts.map +1 -0
  229. package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.js +161 -0
  230. package/esm/deps/jsr.io/@std/assert/1.0.10/object_match.js.map +1 -0
  231. package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts +42 -0
  232. package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.d.ts.map +1 -0
  233. package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.js +54 -0
  234. package/esm/deps/jsr.io/@std/assert/1.0.10/rejects.js.map +1 -0
  235. package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts +24 -0
  236. package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.d.ts.map +1 -0
  237. package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.js +58 -0
  238. package/esm/deps/jsr.io/@std/assert/1.0.10/strict_equals.js.map +1 -0
  239. package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts +18 -0
  240. package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.d.ts.map +1 -0
  241. package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.js +27 -0
  242. package/esm/deps/jsr.io/@std/assert/1.0.10/string_includes.js.map +1 -0
  243. package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts +45 -0
  244. package/esm/deps/jsr.io/@std/assert/1.0.10/throws.d.ts.map +1 -0
  245. package/esm/deps/jsr.io/@std/assert/1.0.10/throws.js +45 -0
  246. package/esm/deps/jsr.io/@std/assert/1.0.10/throws.js.map +1 -0
  247. package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts +15 -0
  248. package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.d.ts.map +1 -0
  249. package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.js +21 -0
  250. package/esm/deps/jsr.io/@std/assert/1.0.10/unimplemented.js.map +1 -0
  251. package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts +15 -0
  252. package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.d.ts.map +1 -0
  253. package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.js +21 -0
  254. package/esm/deps/jsr.io/@std/assert/1.0.10/unreachable.js.map +1 -0
  255. package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.d.ts +17 -0
  256. package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.d.ts.map +1 -0
  257. package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.js +184 -0
  258. package/esm/deps/jsr.io/@std/encoding/1.0.6/_base32_common.js.map +1 -0
  259. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts +2 -0
  260. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.d.ts.map +1 -0
  261. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js +27 -0
  262. package/esm/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.js.map +1 -0
  263. package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.d.ts +59 -0
  264. package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.d.ts.map +1 -0
  265. package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.js +153 -0
  266. package/esm/deps/jsr.io/@std/encoding/1.0.6/ascii85.js.map +1 -0
  267. package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.d.ts +38 -0
  268. package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.d.ts.map +1 -0
  269. package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.js +70 -0
  270. package/esm/deps/jsr.io/@std/encoding/1.0.6/base32.js.map +1 -0
  271. package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.d.ts +38 -0
  272. package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.d.ts.map +1 -0
  273. package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.js +132 -0
  274. package/esm/deps/jsr.io/@std/encoding/1.0.6/base58.js.map +1 -0
  275. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.d.ts +38 -0
  276. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.d.ts.map +1 -0
  277. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.js +164 -0
  278. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64.js.map +1 -0
  279. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.d.ts +38 -0
  280. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.d.ts.map +1 -0
  281. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.js +82 -0
  282. package/esm/deps/jsr.io/@std/encoding/1.0.6/base64url.js.map +1 -0
  283. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts +37 -0
  284. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.d.ts.map +1 -0
  285. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.js +110 -0
  286. package/esm/deps/jsr.io/@std/encoding/1.0.6/hex.js.map +1 -0
  287. package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.d.ts +22 -0
  288. package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.d.ts.map +1 -0
  289. package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.js +23 -0
  290. package/esm/deps/jsr.io/@std/encoding/1.0.6/mod.js.map +1 -0
  291. package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.d.ts +118 -0
  292. package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.d.ts.map +1 -0
  293. package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.js +208 -0
  294. package/esm/deps/jsr.io/@std/encoding/1.0.6/varint.js.map +1 -0
  295. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +82 -0
  296. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
  297. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js +111 -0
  298. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js.map +1 -0
  299. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +140 -0
  300. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
  301. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js +277 -0
  302. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js.map +1 -0
  303. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +99 -0
  304. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
  305. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js +180 -0
  306. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js.map +1 -0
  307. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts +2 -0
  308. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
  309. package/esm/deps/jsr.io/@std/internal/1.0.5/format.js +38 -0
  310. package/esm/deps/jsr.io/@std/internal/1.0.5/format.js.map +1 -0
  311. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +159 -0
  312. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
  313. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js +208 -0
  314. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js.map +1 -0
  315. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts +16 -0
  316. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
  317. package/esm/deps/jsr.io/@std/internal/1.0.5/types.js +3 -0
  318. package/esm/deps/jsr.io/@std/internal/1.0.5/types.js.map +1 -0
  319. package/esm/json_schema/Hydrated.d.ts +4 -0
  320. package/esm/json_schema/Hydrated.d.ts.map +1 -0
  321. package/esm/json_schema/Hydrated.js +49 -0
  322. package/esm/json_schema/Hydrated.js.map +1 -0
  323. package/esm/json_schema/JSONSchema.d.ts +50 -0
  324. package/esm/json_schema/JSONSchema.d.ts.map +1 -0
  325. package/esm/json_schema/JSONSchema.js +46 -0
  326. package/esm/json_schema/JSONSchema.js.map +1 -0
  327. package/esm/json_schema/MetaType.d.ts +4 -0
  328. package/esm/json_schema/MetaType.d.ts.map +1 -0
  329. package/esm/json_schema/MetaType.js +25 -0
  330. package/esm/json_schema/MetaType.js.map +1 -0
  331. package/esm/json_schema/MetaTypeMigration.d.ts +19 -0
  332. package/esm/json_schema/MetaTypeMigration.d.ts.map +1 -0
  333. package/esm/json_schema/MetaTypeMigration.js +15 -0
  334. package/esm/json_schema/MetaTypeMigration.js.map +1 -0
  335. package/esm/json_schema/PathLike.d.ts +4 -0
  336. package/esm/json_schema/PathLike.d.ts.map +1 -0
  337. package/esm/json_schema/PathLike.js +3 -0
  338. package/esm/json_schema/PathLike.js.map +1 -0
  339. package/esm/json_schema/mod.d.ts +7 -0
  340. package/esm/json_schema/mod.d.ts.map +1 -0
  341. package/esm/json_schema/mod.js +8 -0
  342. package/esm/json_schema/mod.js.map +1 -0
  343. package/esm/json_schema/toJSONSchema.d.ts +4 -0
  344. package/esm/json_schema/toJSONSchema.d.ts.map +1 -0
  345. package/esm/json_schema/toJSONSchema.js +117 -0
  346. package/esm/json_schema/toJSONSchema.js.map +1 -0
  347. package/esm/mod.d.ts +4 -0
  348. package/esm/mod.d.ts.map +1 -0
  349. package/esm/mod.js +4 -0
  350. package/esm/mod.js.map +1 -0
  351. package/esm/package.json +3 -0
  352. package/esm/providers/OpenAI/OpenAIAdapter.d.ts +17 -0
  353. package/esm/providers/OpenAI/OpenAIAdapter.d.ts.map +1 -0
  354. package/esm/providers/OpenAI/OpenAIAdapter.js +56 -0
  355. package/esm/providers/OpenAI/OpenAIAdapter.js.map +1 -0
  356. package/esm/providers/OpenAI/OpenAIResponseFormat.d.ts +18 -0
  357. package/esm/providers/OpenAI/OpenAIResponseFormat.d.ts.map +1 -0
  358. package/esm/providers/OpenAI/OpenAIResponseFormat.js +26 -0
  359. package/esm/providers/OpenAI/OpenAIResponseFormat.js.map +1 -0
  360. package/esm/providers/OpenAI/TokenAllowance.d.ts +17 -0
  361. package/esm/providers/OpenAI/TokenAllowance.d.ts.map +1 -0
  362. package/esm/providers/OpenAI/TokenAllowance.js +32 -0
  363. package/esm/providers/OpenAI/TokenAllowance.js.map +1 -0
  364. package/esm/providers/OpenAI/mod.d.ts +6 -0
  365. package/esm/providers/OpenAI/mod.d.ts.map +1 -0
  366. package/esm/providers/OpenAI/mod.js +7 -0
  367. package/esm/providers/OpenAI/mod.js.map +1 -0
  368. package/esm/providers/OpenAI/openai_util.d.ts +4 -0
  369. package/esm/providers/OpenAI/openai_util.d.ts.map +1 -0
  370. package/esm/providers/OpenAI/openai_util.js +14 -0
  371. package/esm/providers/OpenAI/openai_util.js.map +1 -0
  372. package/esm/providers/OpenAI/refine.d.ts +2 -0
  373. package/esm/providers/OpenAI/refine.d.ts.map +1 -0
  374. package/esm/providers/OpenAI/refine.js +166 -0
  375. package/esm/providers/OpenAI/refine.js.map +1 -0
  376. package/esm/util/ArrayOfLength.d.ts +2 -0
  377. package/esm/util/ArrayOfLength.d.ts.map +1 -0
  378. package/esm/util/ArrayOfLength.js +2 -0
  379. package/esm/util/ArrayOfLength.js.map +1 -0
  380. package/esm/util/PromiseOr.d.ts +2 -0
  381. package/esm/util/PromiseOr.d.ts.map +1 -0
  382. package/esm/util/PromiseOr.js +2 -0
  383. package/esm/util/PromiseOr.js.map +1 -0
  384. package/esm/util/WeakMemo.d.ts +7 -0
  385. package/esm/util/WeakMemo.d.ts.map +1 -0
  386. package/esm/util/WeakMemo.js +32 -0
  387. package/esm/util/WeakMemo.js.map +1 -0
  388. package/esm/util/collect.d.ts +2 -0
  389. package/esm/util/collect.d.ts.map +1 -0
  390. package/esm/util/collect.js +8 -0
  391. package/esm/util/collect.js.map +1 -0
  392. package/esm/util/isPromise.d.ts +2 -0
  393. package/esm/util/isPromise.d.ts.map +1 -0
  394. package/esm/util/isPromise.js +7 -0
  395. package/esm/util/isPromise.js.map +1 -0
  396. package/esm/util/isTemplateStringsArray.d.ts +2 -0
  397. package/esm/util/isTemplateStringsArray.d.ts.map +1 -0
  398. package/esm/util/isTemplateStringsArray.js +4 -0
  399. package/esm/util/isTemplateStringsArray.js.map +1 -0
  400. package/esm/util/mod.d.ts +10 -0
  401. package/esm/util/mod.d.ts.map +1 -0
  402. package/esm/util/mod.js +11 -0
  403. package/esm/util/mod.js.map +1 -0
  404. package/esm/util/recombine.d.ts +2 -0
  405. package/esm/util/recombine.d.ts.map +1 -0
  406. package/esm/util/recombine.js +11 -0
  407. package/esm/util/recombine.js.map +1 -0
  408. package/esm/util/splitLast.d.ts +2 -0
  409. package/esm/util/splitLast.d.ts.map +1 -0
  410. package/esm/util/splitLast.js +8 -0
  411. package/esm/util/splitLast.js.map +1 -0
  412. package/esm/util/type_util.d.ts +5 -0
  413. package/esm/util/type_util.d.ts.map +1 -0
  414. package/esm/util/type_util.js +2 -0
  415. package/esm/util/type_util.js.map +1 -0
  416. package/package.json +22 -0
  417. package/src/_dnt.shims.ts +60 -0
  418. package/src/client/Adapter.ts +50 -0
  419. package/src/client/Liminal.ts +113 -0
  420. package/src/client/Tool.ts +17 -0
  421. package/src/client/constants.ts +6 -0
  422. package/src/client/mod.ts +6 -0
  423. package/src/core/DescriptionContext.ts +89 -0
  424. package/src/core/L.ts +3 -0
  425. package/src/core/ReduceDependencies.ts +9 -0
  426. package/src/core/Type.ts +45 -0
  427. package/src/core/TypeVisitor.ts +44 -0
  428. package/src/core/annotations/Annotation.ts +14 -0
  429. package/src/core/annotations/Assertion.ts +18 -0
  430. package/src/core/annotations/Description.ts +16 -0
  431. package/src/core/annotations/Param.ts +30 -0
  432. package/src/core/annotations/Template.ts +11 -0
  433. package/src/core/annotations/mod.ts +7 -0
  434. package/src/core/assert.ts +145 -0
  435. package/src/core/declareIntrinsic.ts +45 -0
  436. package/src/core/deserialize.ts +36 -0
  437. package/src/core/display.ts +68 -0
  438. package/src/core/inspect.node.ts +13 -0
  439. package/src/core/intrinsics.ts +86 -0
  440. package/src/core/intrinsics_util.ts +50 -0
  441. package/src/core/isType.ts +20 -0
  442. package/src/core/mod.ts +15 -0
  443. package/src/core/signature.ts +90 -0
  444. package/src/core/utility/Flatten.ts +14 -0
  445. package/src/core/utility/Intersection.ts +24 -0
  446. package/src/core/utility/Option.ts +6 -0
  447. package/src/core/utility/Record.ts +7 -0
  448. package/src/core/utility/Set.ts +8 -0
  449. package/src/core/utility/TaggedUnion.ts +23 -0
  450. package/src/core/utility/Tuple.ts +24 -0
  451. package/src/core/utility/mod.ts +9 -0
  452. package/src/deps/jsr.io/@std/assert/1.0.10/almost_equals.ts +55 -0
  453. package/src/deps/jsr.io/@std/assert/1.0.10/array_includes.ts +57 -0
  454. package/src/deps/jsr.io/@std/assert/1.0.10/assert.ts +23 -0
  455. package/src/deps/jsr.io/@std/assert/1.0.10/assertion_error.ts +31 -0
  456. package/src/deps/jsr.io/@std/assert/1.0.10/equal.ts +210 -0
  457. package/src/deps/jsr.io/@std/assert/1.0.10/equals.ts +65 -0
  458. package/src/deps/jsr.io/@std/assert/1.0.10/exists.ts +31 -0
  459. package/src/deps/jsr.io/@std/assert/1.0.10/fail.ts +21 -0
  460. package/src/deps/jsr.io/@std/assert/1.0.10/false.ts +26 -0
  461. package/src/deps/jsr.io/@std/assert/1.0.10/greater.ts +30 -0
  462. package/src/deps/jsr.io/@std/assert/1.0.10/greater_or_equal.ts +36 -0
  463. package/src/deps/jsr.io/@std/assert/1.0.10/instance_of.ts +64 -0
  464. package/src/deps/jsr.io/@std/assert/1.0.10/is_error.ts +65 -0
  465. package/src/deps/jsr.io/@std/assert/1.0.10/less.ts +29 -0
  466. package/src/deps/jsr.io/@std/assert/1.0.10/less_or_equal.ts +36 -0
  467. package/src/deps/jsr.io/@std/assert/1.0.10/match.ts +30 -0
  468. package/src/deps/jsr.io/@std/assert/1.0.10/mod.ts +47 -0
  469. package/src/deps/jsr.io/@std/assert/1.0.10/not_equals.ts +37 -0
  470. package/src/deps/jsr.io/@std/assert/1.0.10/not_instance_of.ts +33 -0
  471. package/src/deps/jsr.io/@std/assert/1.0.10/not_match.ts +30 -0
  472. package/src/deps/jsr.io/@std/assert/1.0.10/not_strict_equals.ts +42 -0
  473. package/src/deps/jsr.io/@std/assert/1.0.10/object_match.ts +203 -0
  474. package/src/deps/jsr.io/@std/assert/1.0.10/rejects.ts +123 -0
  475. package/src/deps/jsr.io/@std/assert/1.0.10/strict_equals.ts +67 -0
  476. package/src/deps/jsr.io/@std/assert/1.0.10/string_includes.ts +30 -0
  477. package/src/deps/jsr.io/@std/assert/1.0.10/throws.ts +111 -0
  478. package/src/deps/jsr.io/@std/assert/1.0.10/unimplemented.ts +21 -0
  479. package/src/deps/jsr.io/@std/assert/1.0.10/unreachable.ts +21 -0
  480. package/src/deps/jsr.io/@std/encoding/1.0.6/_base32_common.ts +218 -0
  481. package/src/deps/jsr.io/@std/encoding/1.0.6/_validate_binary_like.ts +29 -0
  482. package/src/deps/jsr.io/@std/encoding/1.0.6/ascii85.ts +203 -0
  483. package/src/deps/jsr.io/@std/encoding/1.0.6/base32.ts +73 -0
  484. package/src/deps/jsr.io/@std/encoding/1.0.6/base58.ts +173 -0
  485. package/src/deps/jsr.io/@std/encoding/1.0.6/base64.ts +174 -0
  486. package/src/deps/jsr.io/@std/encoding/1.0.6/base64url.ts +88 -0
  487. package/src/deps/jsr.io/@std/encoding/1.0.6/hex.ts +120 -0
  488. package/src/deps/jsr.io/@std/encoding/1.0.6/mod.ts +24 -0
  489. package/src/deps/jsr.io/@std/encoding/1.0.6/varint.ts +242 -0
  490. package/src/deps/jsr.io/@std/internal/1.0.5/build_message.ts +134 -0
  491. package/src/deps/jsr.io/@std/internal/1.0.5/diff.ts +317 -0
  492. package/src/deps/jsr.io/@std/internal/1.0.5/diff_str.ts +204 -0
  493. package/src/deps/jsr.io/@std/internal/1.0.5/format.ts +39 -0
  494. package/src/deps/jsr.io/@std/internal/1.0.5/styles.ts +233 -0
  495. package/src/deps/jsr.io/@std/internal/1.0.5/types.ts +18 -0
  496. package/src/json_schema/Hydrated.ts +52 -0
  497. package/src/json_schema/JSONSchema.ts +95 -0
  498. package/src/json_schema/MetaType.ts +32 -0
  499. package/src/json_schema/MetaTypeMigration.ts +31 -0
  500. package/src/json_schema/PathLike.ts +9 -0
  501. package/src/json_schema/mod.ts +8 -0
  502. package/src/json_schema/toJSONSchema.ts +114 -0
  503. package/src/mod.ts +3 -0
  504. package/src/providers/OpenAI/OpenAIAdapter.ts +89 -0
  505. package/src/providers/OpenAI/OpenAIResponseFormat.ts +54 -0
  506. package/src/providers/OpenAI/TokenAllowance.ts +29 -0
  507. package/src/providers/OpenAI/mod.ts +7 -0
  508. package/src/providers/OpenAI/openai_util.ts +19 -0
  509. package/src/providers/OpenAI/refine.ts +171 -0
  510. package/src/util/ArrayOfLength.ts +5 -0
  511. package/src/util/PromiseOr.ts +1 -0
  512. package/src/util/WeakMemo.ts +13 -0
  513. package/src/util/collect.ts +7 -0
  514. package/src/util/isPromise.ts +8 -0
  515. package/src/util/isTemplateStringsArray.ts +3 -0
  516. package/src/util/mod.ts +11 -0
  517. package/src/util/recombine.ts +10 -0
  518. package/src/util/splitLast.ts +7 -0
  519. package/src/util/type_util.ts +3 -0
@@ -0,0 +1,90 @@
1
+ import { encodeBase32 } from "../deps/jsr.io/@std/encoding/1.0.6/mod.js"
2
+ import { WeakMemo } from "../util/WeakMemo.js"
3
+ import { IntrinsicName } from "./intrinsics_util.js"
4
+ import type { PartialType } from "./Type.js"
5
+ import { TypeVisitor } from "./TypeVisitor.js"
6
+
7
+ export function signature(type: PartialType): string {
8
+ return signatureMemo.getOrInit(type)
9
+ }
10
+ const signatureMemo = new WeakMemo<PartialType, string>((type) => {
11
+ const ctx = new SignatureVisitorContext()
12
+ visit(ctx, type)
13
+ return `{\n ${Object.entries(ctx.defs).map(([k, v]) => `${k}: ${v}`).join("\n ")}\n}`
14
+ })
15
+
16
+ export function signatureHash(type: PartialType): Promise<string> {
17
+ return signatureHashMemo.getOrInit(type)
18
+ }
19
+ const signatureHashMemo = new WeakMemo<PartialType, Promise<string>>((type) =>
20
+ crypto.subtle
21
+ .digest("SHA-256", new TextEncoder().encode(signatureMemo.getOrInit(type)))
22
+ .then(encodeBase32)
23
+ .then((v) => v.slice(0, -4))
24
+ )
25
+
26
+ class SignatureVisitorContext {
27
+ ids: Map<PartialType, string> = new Map()
28
+ defs: Record<string, undefined | string> = {}
29
+ }
30
+
31
+ const visit = TypeVisitor<SignatureVisitorContext, string>({
32
+ hook(next, ctx, type): string {
33
+ const { ids, defs } = ctx
34
+ switch (IntrinsicName(type)) {
35
+ case "array":
36
+ case "object":
37
+ case "union": {
38
+ let id = ids.get(type)
39
+ if (id === undefined) {
40
+ id = ids.size.toString()
41
+ ids.set(type, id)
42
+ }
43
+ if (id in defs) {
44
+ return `i(${id})`
45
+ }
46
+ defs[id] = undefined
47
+ const signature = next(ctx, type)
48
+ defs[id] = signature
49
+ return `i(${id})`
50
+ }
51
+ }
52
+ return next(ctx, type)
53
+ },
54
+ const(_0, _1, _2, value): string {
55
+ if (typeof value === "string") {
56
+ return `"${escapeDoubleQuotes(value)}"`
57
+ }
58
+ return JSON.stringify(value)
59
+ },
60
+ array(ctx, _1, element): string {
61
+ return `array(${visit(ctx, element)})`
62
+ },
63
+ object(ctx, _1, fields): string {
64
+ return `object({ ${
65
+ Object
66
+ .entries(fields)
67
+ .map(([k, v]) => `${escapeDoubleQuotes(k)}: ${visit(ctx, v)}`)
68
+ .join(", ")
69
+ } })`
70
+ },
71
+ enum(_0, _1, ...values) {
72
+ return `enum("${values.map(escapeDoubleQuotes).join(`", "`)}")`
73
+ },
74
+ union(ctx, _1, ...members): string {
75
+ return `union(${members.map((member) => visit(ctx, member)).join(", ")})`
76
+ },
77
+ ref(ctx, _1, get): string {
78
+ return visit(ctx, get())
79
+ },
80
+ transform(ctx, _1, from): string {
81
+ return visit(ctx, from)
82
+ },
83
+ fallback(_0, type) {
84
+ return IntrinsicName(type)
85
+ },
86
+ })
87
+
88
+ function escapeDoubleQuotes(value: string): string {
89
+ return value.indexOf(`"`) !== -1 ? JSON.stringify(value) : value
90
+ }
@@ -0,0 +1,14 @@
1
+ import * as I from "../intrinsics.js"
2
+ import type { PartialType, Type } from "../Type.js"
3
+ import { Tuple } from "./Tuple.js"
4
+
5
+ export function Flattened<A extends Array<PartialType<Array<unknown>>>>(
6
+ ...sources: A
7
+ ): Type<NativeFlattened<A>, A[number]["D"]> {
8
+ return I.transform(Tuple(...sources), (value) => value.flat()) as never
9
+ }
10
+
11
+ type NativeFlattened<A extends Array<PartialType<Array<unknown>>>> = A extends
12
+ [infer E0 extends PartialType, ...infer ERest extends PartialType[]]
13
+ ? [...E0["T"], ...NativeFlattened<ERest>]
14
+ : []
@@ -0,0 +1,24 @@
1
+ import type { Expand, U2I } from "../../util/mod.js"
2
+ import * as I from "../intrinsics.js"
3
+ import type { PartialType, Type } from "../Type.js"
4
+
5
+ export function Intersection<S extends Array<PartialType>>(
6
+ ...sources: Ensure<S>
7
+ ): Type<Expand<U2I<S[number]["T"]>>, S[number]["D"]> {
8
+ return I.object(
9
+ Object.fromEntries(
10
+ sources.flatMap((source) => Object.entries(source.declaration.args![0]!)),
11
+ ) as never,
12
+ )
13
+ }
14
+
15
+ type Ensure<S extends Array<PartialType>> = [ConflictingKey<S>] extends [never] ? S
16
+ : never
17
+
18
+ type ConflictingKey<S extends Array<PartialType>, V extends string = never> = S extends [
19
+ infer E0 extends PartialType,
20
+ ...infer ERest extends Array<PartialType>,
21
+ ] ?
22
+ | keyof { [K in keyof E0["T"] as K extends V ? K : never]: true }
23
+ | ConflictingKey<ERest, V | Extract<keyof E0["T"], string>>
24
+ : never
@@ -0,0 +1,6 @@
1
+ import * as I from "../intrinsics.js"
2
+ import type { Type } from "../Type.js"
3
+
4
+ export function Option<V, P extends symbol>(some: Type<V, P>): Type<V | null, P> {
5
+ return I.union(I.null, some)
6
+ }
@@ -0,0 +1,7 @@
1
+ import * as I from "../intrinsics.js"
2
+ import type { Type } from "../Type.js"
3
+ import { Tuple } from "./Tuple.js"
4
+
5
+ export function Record<V, P extends symbol>(value: Type<V, P>): Type<Record<string, V>, P> {
6
+ return I.transform(I.array(Tuple(I.string, value)), Object.fromEntries)
7
+ }
@@ -0,0 +1,8 @@
1
+ import * as I from "../intrinsics.js"
2
+ import type { Type } from "../Type.js"
3
+
4
+ export { Set_ as Set }
5
+ function Set_<T extends number | string, P extends symbol>(element: Type<T, P>): Type<Set<T>, P> {
6
+ return I.transform(I.array(element), (value) => new Set(value))
7
+ }
8
+ Object.defineProperty(Set_, "name", { value: "Set" })
@@ -0,0 +1,23 @@
1
+ import type { Falsy } from "../../deps/jsr.io/@std/assert/1.0.10/mod.js"
2
+ import type { Expand } from "../../util/mod.js"
3
+ import * as I from "../intrinsics.js"
4
+ import type { PartialType, Type } from "../Type.js"
5
+
6
+ export function TaggedUnion<M extends Record<string, Falsy | PartialType>>(members: M): Type<
7
+ {
8
+ [K in keyof M]: Expand<
9
+ & { type: K }
10
+ & (M[K] extends PartialType ? { value: M[K]["T"] } : { value?: never })
11
+ >
12
+ }[keyof M],
13
+ Extract<M[keyof M], PartialType>["D"]
14
+ > {
15
+ return I.union(
16
+ ...Object.keys(members).toSorted().map((tag) =>
17
+ I.object({
18
+ type: I.const(I.string, tag),
19
+ value: members[tag] ? members[tag] : I.null,
20
+ } as never)
21
+ ),
22
+ )
23
+ }
@@ -0,0 +1,24 @@
1
+ import type { ArrayOfLength } from "../../util/mod.js"
2
+ import * as I from "../intrinsics.js"
3
+ import type { PartialType, Type } from "../Type.js"
4
+
5
+ export function Tuple<M extends Array<PartialType>>(
6
+ ...members: M
7
+ ): Type<{ [I in keyof M]: M[I]["T"] }, M[number]["D"]> {
8
+ return I.transform(
9
+ I.object(Object.fromEntries(members.map((type, i) => [i, type]))),
10
+ (value) => Object.values(value) as never,
11
+ )
12
+ }
13
+
14
+ export namespace Tuple {
15
+ export function N<T, P extends symbol, N extends number>(
16
+ member: Type<T, P>,
17
+ length: N,
18
+ ): Type<ArrayOfLength<T, N>, P> {
19
+ return I.transform(
20
+ I.object(Object.fromEntries(Array.from({ length }, (_0, i) => [i, member]))),
21
+ (value) => Object.values(value) as never,
22
+ )
23
+ }
24
+ }
@@ -0,0 +1,9 @@
1
+ // moderate
2
+
3
+ export * from "./Flatten.js"
4
+ export * from "./Intersection.js"
5
+ export * from "./Option.js"
6
+ export * from "./Record.js"
7
+ export * from "./Set.js"
8
+ export * from "./TaggedUnion.js"
9
+ export * from "./Tuple.js"
@@ -0,0 +1,55 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { AssertionError } from "./assertion_error.js";
4
+
5
+ /**
6
+ * Make an assertion that `actual` and `expected` are almost equal numbers
7
+ * through a given tolerance. It can be used to take into account IEEE-754
8
+ * double-precision floating-point representation limitations. If the values
9
+ * are not almost equal then throw.
10
+ *
11
+ * The default tolerance is one hundred thousandth of a percent of the
12
+ * expected value.
13
+ *
14
+ * @example Usage
15
+ * ```ts ignore
16
+ * import { assertAlmostEquals } from "@std/assert";
17
+ *
18
+ * assertAlmostEquals(0.01, 0.02); // Throws
19
+ * assertAlmostEquals(1e-8, 1e-9); // Throws
20
+ * assertAlmostEquals(1.000000001e-8, 1.000000002e-8); // Doesn't throw
21
+ * assertAlmostEquals(0.01, 0.02, 0.1); // Doesn't throw
22
+ * assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16); // Doesn't throw
23
+ * assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17); // Throws
24
+ * ```
25
+ *
26
+ * @param actual The actual value to compare.
27
+ * @param expected The expected value to compare.
28
+ * @param tolerance The tolerance to consider the values almost equal. The
29
+ * default is one hundred thousandth of a percent of the expected value.
30
+ * @param msg The optional message to include in the error.
31
+ */
32
+ export function assertAlmostEquals(
33
+ actual: number,
34
+ expected: number,
35
+ tolerance?: number,
36
+ msg?: string,
37
+ ) {
38
+ if (Object.is(actual, expected)) {
39
+ return;
40
+ }
41
+ const delta = Math.abs(expected - actual);
42
+ if (tolerance === undefined) {
43
+ tolerance = isFinite(expected) ? Math.abs(expected * 1e-7) : 1e-7;
44
+ }
45
+ if (delta <= tolerance) {
46
+ return;
47
+ }
48
+
49
+ const msgSuffix = msg ? `: ${msg}` : ".";
50
+ const f = (n: number) => Number.isInteger(n) ? n : n.toExponential();
51
+ throw new AssertionError(
52
+ `Expected actual: "${f(actual)}" to be close to "${f(expected)}": \
53
+ delta "${f(delta)}" is greater than "${f(tolerance)}"${msgSuffix}`,
54
+ );
55
+ }
@@ -0,0 +1,57 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { equal } from "./equal.js";
4
+ import { format } from "../../internal/1.0.5/format.js";
5
+ import { AssertionError } from "./assertion_error.js";
6
+
7
+ /** An array-like object (`Array`, `Uint8Array`, `NodeList`, etc.) that is not a string */
8
+ export type ArrayLikeArg<T> = ArrayLike<T> & object;
9
+
10
+ /**
11
+ * Make an assertion that `actual` includes the `expected` values. If not then
12
+ * an error will be thrown.
13
+ *
14
+ * Type parameter can be specified to ensure values under comparison have the
15
+ * same type.
16
+ *
17
+ * @example Usage
18
+ * ```ts ignore
19
+ * import { assertArrayIncludes } from "@std/assert";
20
+ *
21
+ * assertArrayIncludes([1, 2], [2]); // Doesn't throw
22
+ * assertArrayIncludes([1, 2], [3]); // Throws
23
+ * ```
24
+ *
25
+ * @typeParam T The type of the elements in the array to compare.
26
+ * @param actual The array-like object to check for.
27
+ * @param expected The array-like object to check for.
28
+ * @param msg The optional message to display if the assertion fails.
29
+ */
30
+ export function assertArrayIncludes<T>(
31
+ actual: ArrayLikeArg<T>,
32
+ expected: ArrayLikeArg<T>,
33
+ msg?: string,
34
+ ) {
35
+ const missing: unknown[] = [];
36
+ for (let i = 0; i < expected.length; i++) {
37
+ let found = false;
38
+ for (let j = 0; j < actual.length; j++) {
39
+ if (equal(expected[i], actual[j])) {
40
+ found = true;
41
+ break;
42
+ }
43
+ }
44
+ if (!found) {
45
+ missing.push(expected[i]);
46
+ }
47
+ }
48
+ if (missing.length === 0) {
49
+ return;
50
+ }
51
+
52
+ const msgSuffix = msg ? `: ${msg}` : ".";
53
+ msg = `Expected actual: "${format(actual)}" to include: "${
54
+ format(expected)
55
+ }"${msgSuffix}\nmissing: ${format(missing)}`;
56
+ throw new AssertionError(msg);
57
+ }
@@ -0,0 +1,23 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { AssertionError } from "./assertion_error.js";
4
+
5
+ /**
6
+ * Make an assertion, error will be thrown if `expr` does not have truthy value.
7
+ *
8
+ * @example Usage
9
+ * ```ts ignore
10
+ * import { assert } from "@std/assert";
11
+ *
12
+ * assert("hello".includes("ello")); // Doesn't throw
13
+ * assert("hello".includes("world")); // Throws
14
+ * ```
15
+ *
16
+ * @param expr The expression to test.
17
+ * @param msg The optional message to display if the assertion fails.
18
+ */
19
+ export function assert(expr: unknown, msg = ""): asserts expr {
20
+ if (!expr) {
21
+ throw new AssertionError(msg);
22
+ }
23
+ }
@@ -0,0 +1,31 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Error thrown when an assertion fails.
6
+ *
7
+ * @example Usage
8
+ * ```ts ignore
9
+ * import { AssertionError } from "@std/assert";
10
+ *
11
+ * try {
12
+ * throw new AssertionError("foo", { cause: "bar" });
13
+ * } catch (error) {
14
+ * if (error instanceof AssertionError) {
15
+ * error.message === "foo"; // true
16
+ * error.cause === "bar"; // true
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export class AssertionError extends Error {
22
+ /** Constructs a new instance.
23
+ *
24
+ * @param message The error message.
25
+ * @param options Additional options. This argument is still unstable. It may change in the future release.
26
+ */
27
+ constructor(message: string, options?: ErrorOptions) {
28
+ super(message, options);
29
+ this.name = "AssertionError";
30
+ }
31
+ }
@@ -0,0 +1,210 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import * as dntShim from "../../../../../_dnt.shims.js";
4
+
5
+
6
+ type KeyedCollection = Set<unknown> | Map<unknown, unknown>;
7
+ function isKeyedCollection(x: unknown): x is KeyedCollection {
8
+ return x instanceof Set || x instanceof Map;
9
+ }
10
+
11
+ function prototypesEqual(a: object, b: object) {
12
+ const pa = Object.getPrototypeOf(a);
13
+ const pb = Object.getPrototypeOf(b);
14
+ return pa === pb ||
15
+ pa === Object.prototype && pb === null ||
16
+ pa === null && pb === Object.prototype;
17
+ }
18
+
19
+ function isBasicObjectOrArray(obj: object) {
20
+ const proto = Object.getPrototypeOf(obj);
21
+ return proto === null || proto === Object.prototype ||
22
+ proto === Array.prototype;
23
+ }
24
+
25
+ // Slightly faster than Reflect.ownKeys in V8 as of 12.9.202.13-rusty (2024-10-28)
26
+ function ownKeys(obj: object) {
27
+ return [
28
+ ...Object.getOwnPropertyNames(obj),
29
+ ...Object.getOwnPropertySymbols(obj),
30
+ ];
31
+ }
32
+
33
+ function getKeysDeep(obj: object) {
34
+ const keys = new Set<string | symbol>();
35
+
36
+ while (obj !== Object.prototype && obj !== Array.prototype && obj != null) {
37
+ for (const key of ownKeys(obj)) {
38
+ keys.add(key);
39
+ }
40
+ obj = Object.getPrototypeOf(obj);
41
+ }
42
+
43
+ return keys;
44
+ }
45
+
46
+ // deno-lint-ignore no-explicit-any
47
+ const Temporal: any = (dntShim.dntGlobalThis as any).Temporal ??
48
+ new Proxy({}, { get: () => {} });
49
+
50
+ /** A non-exhaustive list of prototypes that can be accurately fast-path compared with `String(instance)` */
51
+ const stringComparablePrototypes = new Set<unknown>(
52
+ [
53
+ Intl.Locale,
54
+ RegExp,
55
+ Temporal.Duration,
56
+ Temporal.Instant,
57
+ Temporal.PlainDate,
58
+ Temporal.PlainDateTime,
59
+ Temporal.PlainTime,
60
+ Temporal.PlainYearMonth,
61
+ Temporal.PlainMonthDay,
62
+ Temporal.ZonedDateTime,
63
+ URL,
64
+ URLSearchParams,
65
+ ].filter((x) => x != null).map((x) => x.prototype),
66
+ );
67
+
68
+ function isPrimitive(x: unknown) {
69
+ return typeof x === "string" ||
70
+ typeof x === "number" ||
71
+ typeof x === "boolean" ||
72
+ typeof x === "bigint" ||
73
+ typeof x === "symbol" ||
74
+ x == null;
75
+ }
76
+
77
+ type TypedArray = Pick<Uint8Array | BigUint64Array, "length" | number>;
78
+ const TypedArray = Object.getPrototypeOf(Uint8Array);
79
+ function compareTypedArrays(a: TypedArray, b: TypedArray) {
80
+ if (a.length !== b.length) return false;
81
+ for (let i = 0; i < b.length; i++) {
82
+ if (!sameValueZero(a[i], b[i])) return false;
83
+ }
84
+ return true;
85
+ }
86
+
87
+ /** Check both strict equality (`0 == -0`) and `Object.is` (`NaN == NaN`) */
88
+ function sameValueZero(a: unknown, b: unknown) {
89
+ return a === b || Object.is(a, b);
90
+ }
91
+
92
+ /**
93
+ * Deep equality comparison used in assertions.
94
+ *
95
+ * @param a The actual value
96
+ * @param b The expected value
97
+ * @returns `true` if the values are deeply equal, `false` otherwise
98
+ *
99
+ * @example Usage
100
+ * ```ts
101
+ * import { equal } from "@std/assert/equal";
102
+ *
103
+ * equal({ foo: "bar" }, { foo: "bar" }); // Returns `true`
104
+ * equal({ foo: "bar" }, { foo: "baz" }); // Returns `false`
105
+ * ```
106
+ */
107
+ export function equal(a: unknown, b: unknown): boolean {
108
+ const seen = new Map<unknown, unknown>();
109
+ return (function compare(a: unknown, b: unknown): boolean {
110
+ if (sameValueZero(a, b)) return true;
111
+ if (isPrimitive(a) || isPrimitive(b)) return false;
112
+
113
+ if (a instanceof Date && b instanceof Date) {
114
+ return Object.is(a.getTime(), b.getTime());
115
+ }
116
+ if (a && typeof a === "object" && b && typeof b === "object") {
117
+ if (!prototypesEqual(a, b)) {
118
+ return false;
119
+ }
120
+ if (a instanceof TypedArray) {
121
+ return compareTypedArrays(a as TypedArray, b as TypedArray);
122
+ }
123
+ if (a instanceof WeakMap) {
124
+ throw new TypeError("cannot compare WeakMap instances");
125
+ }
126
+ if (a instanceof WeakSet) {
127
+ throw new TypeError("cannot compare WeakSet instances");
128
+ }
129
+ if (a instanceof WeakRef) {
130
+ return compare(a.deref(), (b as WeakRef<WeakKey>).deref());
131
+ }
132
+ if (seen.get(a) === b) {
133
+ return true;
134
+ }
135
+ if (Object.keys(a).length !== Object.keys(b).length) {
136
+ return false;
137
+ }
138
+ seen.set(a, b);
139
+ if (isKeyedCollection(a) && isKeyedCollection(b)) {
140
+ if (a.size !== b.size) {
141
+ return false;
142
+ }
143
+
144
+ const aKeys = [...a.keys()];
145
+ const primitiveKeysFastPath = aKeys.every(isPrimitive);
146
+ if (primitiveKeysFastPath) {
147
+ if (a instanceof Set) {
148
+ return a.symmetricDifference(b).size === 0;
149
+ }
150
+
151
+ for (const key of aKeys) {
152
+ if (
153
+ !b.has(key) ||
154
+ !compare(a.get(key), (b as Map<unknown, unknown>).get(key))
155
+ ) {
156
+ return false;
157
+ }
158
+ }
159
+ return true;
160
+ }
161
+
162
+ let unmatchedEntries = a.size;
163
+
164
+ for (const [aKey, aValue] of a.entries()) {
165
+ for (const [bKey, bValue] of b.entries()) {
166
+ /* Given that Map keys can be references, we need
167
+ * to ensure that they are also deeply equal */
168
+
169
+ if (!compare(aKey, bKey)) continue;
170
+
171
+ if (
172
+ (aKey === aValue && bKey === bValue) ||
173
+ (compare(aValue, bValue))
174
+ ) {
175
+ unmatchedEntries--;
176
+ break;
177
+ }
178
+ }
179
+ }
180
+
181
+ return unmatchedEntries === 0;
182
+ }
183
+
184
+ let keys: Iterable<string | symbol>;
185
+
186
+ if (isBasicObjectOrArray(a)) {
187
+ // fast path
188
+ keys = ownKeys({ ...a, ...b });
189
+ } else if (stringComparablePrototypes.has(Object.getPrototypeOf(a))) {
190
+ // medium path
191
+ return String(a) === String(b);
192
+ } else {
193
+ // slow path
194
+ keys = getKeysDeep(a).union(getKeysDeep(b));
195
+ }
196
+
197
+ for (const key of keys) {
198
+ type Key = keyof typeof a;
199
+ if (!compare(a[key as Key], b[key as Key])) {
200
+ return false;
201
+ }
202
+ if (((key in a) && (!(key in b))) || ((key in b) && (!(key in a)))) {
203
+ return false;
204
+ }
205
+ }
206
+ return true;
207
+ }
208
+ return false;
209
+ })(a, b);
210
+ }
@@ -0,0 +1,65 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { equal } from "./equal.js";
4
+ import { buildMessage } from "../../internal/1.0.5/build_message.js";
5
+ import { diff } from "../../internal/1.0.5/diff.js";
6
+ import { diffStr } from "../../internal/1.0.5/diff_str.js";
7
+ import { format } from "../../internal/1.0.5/format.js";
8
+
9
+ import { AssertionError } from "./assertion_error.js";
10
+
11
+ /**
12
+ * Make an assertion that `actual` and `expected` are equal, deeply. If not
13
+ * deeply equal, then throw.
14
+ *
15
+ * Type parameter can be specified to ensure values under comparison have the
16
+ * same type.
17
+ *
18
+ * Note: When comparing `Blob` objects, you should first convert them to
19
+ * `Uint8Array` using the `Blob.bytes()` method and then compare their
20
+ * contents.
21
+ *
22
+ * @example Usage
23
+ * ```ts ignore
24
+ * import { assertEquals } from "@std/assert";
25
+ *
26
+ * assertEquals("world", "world"); // Doesn't throw
27
+ * assertEquals("hello", "world"); // Throws
28
+ * ```
29
+ * @example Compare `Blob` objects
30
+ * ```ts ignore
31
+ * import { assertEquals } from "@std/assert";
32
+ *
33
+ * const bytes1 = await new Blob(["foo"]).bytes();
34
+ * const bytes2 = await new Blob(["foo"]).bytes();
35
+ *
36
+ * assertEquals(bytes1, bytes2);
37
+ * ```
38
+ *
39
+ * @typeParam T The type of the values to compare. This is usually inferred.
40
+ * @param actual The actual value to compare.
41
+ * @param expected The expected value to compare.
42
+ * @param msg The optional message to display if the assertion fails.
43
+ */
44
+ export function assertEquals<T>(
45
+ actual: T,
46
+ expected: T,
47
+ msg?: string,
48
+ ) {
49
+ if (equal(actual, expected)) {
50
+ return;
51
+ }
52
+ const msgSuffix = msg ? `: ${msg}` : ".";
53
+ let message = `Values are not equal${msgSuffix}`;
54
+
55
+ const actualString = format(actual);
56
+ const expectedString = format(expected);
57
+ const stringDiff = (typeof actual === "string") &&
58
+ (typeof expected === "string");
59
+ const diffResult = stringDiff
60
+ ? diffStr(actual as string, expected as string)
61
+ : diff(actualString.split("\n"), expectedString.split("\n"));
62
+ const diffMsg = buildMessage(diffResult, { stringDiff }).join("\n");
63
+ message = `${message}\n${diffMsg}`;
64
+ throw new AssertionError(message);
65
+ }