structured-outputs 0.1.0-beta.2 → 0.1.0-beta.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (391) hide show
  1. package/README.md +77 -6
  2. package/esm/ResponseFormat.d.ts +18 -11
  3. package/esm/ResponseFormat.d.ts.map +1 -1
  4. package/esm/ResponseFormat.js +57 -5
  5. package/esm/ResponseFormat.js.map +1 -1
  6. package/esm/Tool.d.ts +13 -0
  7. package/esm/Tool.d.ts.map +1 -0
  8. package/esm/Tool.js +17 -0
  9. package/esm/Tool.js.map +1 -0
  10. package/esm/_dnt.polyfills.d.ts +12 -0
  11. package/esm/_dnt.polyfills.d.ts.map +1 -0
  12. package/esm/_dnt.polyfills.js +16 -0
  13. package/esm/_dnt.polyfills.js.map +1 -0
  14. package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts +6 -0
  15. package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.js +19 -0
  17. package/esm/deps/jsr.io/@std/collections/1.0.9/_utils.js.map +1 -0
  18. package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts +41 -0
  19. package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts.map +1 -0
  20. package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.js +51 -0
  21. package/esm/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.js.map +1 -0
  22. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts +37 -0
  23. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.js +45 -0
  25. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_by.js.map +1 -0
  26. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts +33 -0
  27. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts.map +1 -0
  28. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.js +41 -0
  29. package/esm/deps/jsr.io/@std/collections/1.0.9/associate_with.js.map +1 -0
  30. package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts +38 -0
  31. package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts.map +1 -0
  32. package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.js +51 -0
  33. package/esm/deps/jsr.io/@std/collections/1.0.9/chunk.js.map +1 -0
  34. package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts +322 -0
  35. package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.js +96 -0
  37. package/esm/deps/jsr.io/@std/collections/1.0.9/deep_merge.js.map +1 -0
  38. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts +23 -0
  39. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts.map +1 -0
  40. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.js +28 -0
  41. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct.js.map +1 -0
  42. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts +26 -0
  43. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts.map +1 -0
  44. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.js +39 -0
  45. package/esm/deps/jsr.io/@std/collections/1.0.9/distinct_by.js.map +1 -0
  46. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts +26 -0
  47. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.js +33 -0
  49. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_last_while.js.map +1 -0
  50. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts +25 -0
  51. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts.map +1 -0
  52. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.js +34 -0
  53. package/esm/deps/jsr.io/@std/collections/1.0.9/drop_while.js.map +1 -0
  54. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts +32 -0
  55. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts.map +1 -0
  56. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.js +43 -0
  57. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_entries.js.map +1 -0
  58. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts +36 -0
  59. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts.map +1 -0
  60. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.js +46 -0
  61. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_keys.js.map +1 -0
  62. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts +35 -0
  63. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts.map +1 -0
  64. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.js +46 -0
  65. package/esm/deps/jsr.io/@std/collections/1.0.9/filter_values.js.map +1 -0
  66. package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts +31 -0
  67. package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts.map +1 -0
  68. package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.js +45 -0
  69. package/esm/deps/jsr.io/@std/collections/1.0.9/find_single.js.map +1 -0
  70. package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts +32 -0
  71. package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.js +42 -0
  73. package/esm/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.js.map +1 -0
  74. package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts +29 -0
  75. package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts.map +1 -0
  76. package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.js +39 -0
  77. package/esm/deps/jsr.io/@std/collections/1.0.9/includes_value.js.map +1 -0
  78. package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts +25 -0
  79. package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts.map +1 -0
  80. package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.js +36 -0
  81. package/esm/deps/jsr.io/@std/collections/1.0.9/intersect.js.map +1 -0
  82. package/esm/deps/jsr.io/@std/collections/1.0.9/invert.d.ts +29 -0
  83. package/esm/deps/jsr.io/@std/collections/1.0.9/invert.d.ts.map +1 -0
  84. package/esm/deps/jsr.io/@std/collections/1.0.9/invert.js +29 -0
  85. package/esm/deps/jsr.io/@std/collections/1.0.9/invert.js.map +1 -0
  86. package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts +34 -0
  87. package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts.map +1 -0
  88. package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.js +46 -0
  89. package/esm/deps/jsr.io/@std/collections/1.0.9/invert_by.js.map +1 -0
  90. package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts +75 -0
  91. package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts.map +1 -0
  92. package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.js +59 -0
  93. package/esm/deps/jsr.io/@std/collections/1.0.9/join_to_string.js.map +1 -0
  94. package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts +37 -0
  95. package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts.map +1 -0
  96. package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.js +47 -0
  97. package/esm/deps/jsr.io/@std/collections/1.0.9/map_entries.js.map +1 -0
  98. package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts +33 -0
  99. package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts.map +1 -0
  100. package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.js +42 -0
  101. package/esm/deps/jsr.io/@std/collections/1.0.9/map_keys.js.map +1 -0
  102. package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts +32 -0
  103. package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts.map +1 -0
  104. package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.js +43 -0
  105. package/esm/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.js.map +1 -0
  106. package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts +71 -0
  107. package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts.map +1 -0
  108. package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.js +13 -0
  109. package/esm/deps/jsr.io/@std/collections/1.0.9/map_values.js.map +1 -0
  110. package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts +117 -0
  111. package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts.map +1 -0
  112. package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.js +15 -0
  113. package/esm/deps/jsr.io/@std/collections/1.0.9/max_by.js.map +1 -0
  114. package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts +61 -0
  115. package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts.map +1 -0
  116. package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.js +17 -0
  117. package/esm/deps/jsr.io/@std/collections/1.0.9/max_of.js.map +1 -0
  118. package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts +29 -0
  119. package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts.map +1 -0
  120. package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.js +41 -0
  121. package/esm/deps/jsr.io/@std/collections/1.0.9/max_with.js.map +1 -0
  122. package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts +115 -0
  123. package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts.map +1 -0
  124. package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.js +15 -0
  125. package/esm/deps/jsr.io/@std/collections/1.0.9/min_by.js.map +1 -0
  126. package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts +61 -0
  127. package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts.map +1 -0
  128. package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.js +17 -0
  129. package/esm/deps/jsr.io/@std/collections/1.0.9/min_of.js.map +1 -0
  130. package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts +25 -0
  131. package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts.map +1 -0
  132. package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.js +37 -0
  133. package/esm/deps/jsr.io/@std/collections/1.0.9/min_with.js.map +1 -0
  134. package/esm/deps/jsr.io/@std/collections/1.0.9/mod.d.ts +73 -0
  135. package/esm/deps/jsr.io/@std/collections/1.0.9/mod.d.ts.map +1 -0
  136. package/esm/deps/jsr.io/@std/collections/1.0.9/mod.js +75 -0
  137. package/esm/deps/jsr.io/@std/collections/1.0.9/mod.js.map +1 -0
  138. package/esm/deps/jsr.io/@std/collections/1.0.9/omit.d.ts +24 -0
  139. package/esm/deps/jsr.io/@std/collections/1.0.9/omit.d.ts.map +1 -0
  140. package/esm/deps/jsr.io/@std/collections/1.0.9/omit.js +29 -0
  141. package/esm/deps/jsr.io/@std/collections/1.0.9/omit.js.map +1 -0
  142. package/esm/deps/jsr.io/@std/collections/1.0.9/partition.d.ts +60 -0
  143. package/esm/deps/jsr.io/@std/collections/1.0.9/partition.d.ts.map +1 -0
  144. package/esm/deps/jsr.io/@std/collections/1.0.9/partition.js +16 -0
  145. package/esm/deps/jsr.io/@std/collections/1.0.9/partition.js.map +1 -0
  146. package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts +39 -0
  147. package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts.map +1 -0
  148. package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.js +54 -0
  149. package/esm/deps/jsr.io/@std/collections/1.0.9/partition_entries.js.map +1 -0
  150. package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts +27 -0
  151. package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts.map +1 -0
  152. package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.js +58 -0
  153. package/esm/deps/jsr.io/@std/collections/1.0.9/permutations.js.map +1 -0
  154. package/esm/deps/jsr.io/@std/collections/1.0.9/pick.d.ts +25 -0
  155. package/esm/deps/jsr.io/@std/collections/1.0.9/pick.d.ts.map +1 -0
  156. package/esm/deps/jsr.io/@std/collections/1.0.9/pick.js +33 -0
  157. package/esm/deps/jsr.io/@std/collections/1.0.9/pick.js.map +1 -0
  158. package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts +35 -0
  159. package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts.map +1 -0
  160. package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.js +40 -0
  161. package/esm/deps/jsr.io/@std/collections/1.0.9/reduce_groups.js.map +1 -0
  162. package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts +27 -0
  163. package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts.map +1 -0
  164. package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.js +32 -0
  165. package/esm/deps/jsr.io/@std/collections/1.0.9/running_reduce.js.map +1 -0
  166. package/esm/deps/jsr.io/@std/collections/1.0.9/sample.d.ts +24 -0
  167. package/esm/deps/jsr.io/@std/collections/1.0.9/sample.d.ts.map +1 -0
  168. package/esm/deps/jsr.io/@std/collections/1.0.9/sample.js +35 -0
  169. package/esm/deps/jsr.io/@std/collections/1.0.9/sample.js.map +1 -0
  170. package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts +66 -0
  171. package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts.map +1 -0
  172. package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.js +57 -0
  173. package/esm/deps/jsr.io/@std/collections/1.0.9/sliding_windows.js.map +1 -0
  174. package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts +161 -0
  175. package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts.map +1 -0
  176. package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.js +30 -0
  177. package/esm/deps/jsr.io/@std/collections/1.0.9/sort_by.js.map +1 -0
  178. package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts +29 -0
  179. package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts.map +1 -0
  180. package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.js +37 -0
  181. package/esm/deps/jsr.io/@std/collections/1.0.9/sum_of.js.map +1 -0
  182. package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts +27 -0
  183. package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts.map +1 -0
  184. package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.js +34 -0
  185. package/esm/deps/jsr.io/@std/collections/1.0.9/take_last_while.js.map +1 -0
  186. package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts +30 -0
  187. package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts.map +1 -0
  188. package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.js +39 -0
  189. package/esm/deps/jsr.io/@std/collections/1.0.9/take_while.js.map +1 -0
  190. package/esm/deps/jsr.io/@std/collections/1.0.9/union.d.ts +24 -0
  191. package/esm/deps/jsr.io/@std/collections/1.0.9/union.d.ts.map +1 -0
  192. package/esm/deps/jsr.io/@std/collections/1.0.9/union.js +34 -0
  193. package/esm/deps/jsr.io/@std/collections/1.0.9/union.js.map +1 -0
  194. package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts +32 -0
  195. package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts.map +1 -0
  196. package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.js +46 -0
  197. package/esm/deps/jsr.io/@std/collections/1.0.9/unzip.js.map +1 -0
  198. package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts +23 -0
  199. package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts.map +1 -0
  200. package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.js +28 -0
  201. package/esm/deps/jsr.io/@std/collections/1.0.9/without_all.js.map +1 -0
  202. package/esm/deps/jsr.io/@std/collections/1.0.9/zip.d.ts +34 -0
  203. package/esm/deps/jsr.io/@std/collections/1.0.9/zip.d.ts.map +1 -0
  204. package/esm/deps/jsr.io/@std/collections/1.0.9/zip.js +43 -0
  205. package/esm/deps/jsr.io/@std/collections/1.0.9/zip.js.map +1 -0
  206. package/esm/mod.d.ts +3 -14
  207. package/esm/mod.d.ts.map +1 -1
  208. package/esm/mod.js +3 -10
  209. package/esm/mod.js.map +1 -1
  210. package/esm/oai.d.ts +5 -0
  211. package/esm/oai.d.ts.map +1 -0
  212. package/esm/oai.js +2 -0
  213. package/esm/oai.js.map +1 -0
  214. package/esm/types/Ref.d.ts +4 -0
  215. package/esm/types/Ref.d.ts.map +1 -0
  216. package/esm/types/Ref.js +11 -0
  217. package/esm/types/Ref.js.map +1 -0
  218. package/esm/types/RootTy.d.ts +8 -0
  219. package/esm/types/RootTy.d.ts.map +1 -0
  220. package/esm/types/RootTy.js +19 -0
  221. package/esm/types/RootTy.js.map +1 -0
  222. package/esm/types/Ty.d.ts +27 -0
  223. package/esm/types/Ty.d.ts.map +1 -0
  224. package/esm/types/Ty.js +17 -0
  225. package/esm/types/Ty.js.map +1 -0
  226. package/esm/types/array.d.ts +3 -0
  227. package/esm/types/array.d.ts.map +1 -0
  228. package/esm/types/array.js +9 -0
  229. package/esm/types/array.js.map +1 -0
  230. package/esm/types/constant.d.ts +3 -0
  231. package/esm/types/constant.d.ts.map +1 -0
  232. package/esm/types/constant.js +8 -0
  233. package/esm/types/constant.js.map +1 -0
  234. package/esm/types/constantUnion.d.ts +3 -0
  235. package/esm/types/constantUnion.d.ts.map +1 -0
  236. package/esm/types/constantUnion.js +25 -0
  237. package/esm/types/constantUnion.js.map +1 -0
  238. package/esm/types/leaves.d.ts +6 -0
  239. package/esm/types/leaves.d.ts.map +1 -0
  240. package/esm/types/leaves.js +18 -0
  241. package/esm/types/leaves.js.map +1 -0
  242. package/esm/types/mod.d.ts +11 -0
  243. package/esm/types/mod.d.ts.map +1 -0
  244. package/esm/types/mod.js +11 -0
  245. package/esm/types/mod.js.map +1 -0
  246. package/esm/types/object.d.ts +6 -0
  247. package/esm/types/object.d.ts.map +1 -0
  248. package/esm/{object.js → types/object.js} +4 -4
  249. package/esm/types/object.js.map +1 -0
  250. package/esm/types/std/Option.d.ts +7 -0
  251. package/esm/types/std/Option.d.ts.map +1 -0
  252. package/esm/types/std/Option.js +9 -0
  253. package/esm/types/std/Option.js.map +1 -0
  254. package/esm/types/std/Wrapper.d.ts +7 -0
  255. package/esm/types/std/Wrapper.d.ts.map +1 -0
  256. package/esm/types/std/Wrapper.js +5 -0
  257. package/esm/types/std/Wrapper.js.map +1 -0
  258. package/esm/types/std/mod.d.ts +3 -0
  259. package/esm/types/std/mod.d.ts.map +1 -0
  260. package/esm/types/std/mod.js +3 -0
  261. package/esm/types/std/mod.js.map +1 -0
  262. package/esm/types/taggedUnion.d.ts +8 -0
  263. package/esm/types/taggedUnion.d.ts.map +1 -0
  264. package/esm/types/taggedUnion.js +20 -0
  265. package/esm/types/taggedUnion.js.map +1 -0
  266. package/esm/util/phantoms.d.ts +2 -0
  267. package/esm/util/phantoms.d.ts.map +1 -0
  268. package/esm/util/phantoms.js +4 -0
  269. package/esm/util/phantoms.js.map +1 -0
  270. package/esm/util/recombineTaggedTemplateArgs.d.ts +2 -0
  271. package/esm/util/recombineTaggedTemplateArgs.d.ts.map +1 -0
  272. package/esm/util/recombineTaggedTemplateArgs.js +4 -0
  273. package/esm/util/recombineTaggedTemplateArgs.js.map +1 -0
  274. package/package.json +7 -9
  275. package/src/ResponseFormat.ts +80 -22
  276. package/src/Tool.ts +38 -0
  277. package/src/_dnt.polyfills.ts +27 -0
  278. package/src/deps/jsr.io/@std/collections/1.0.9/_utils.ts +26 -0
  279. package/src/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.ts +62 -0
  280. package/src/deps/jsr.io/@std/collections/1.0.9/associate_by.ts +50 -0
  281. package/src/deps/jsr.io/@std/collections/1.0.9/associate_with.ts +46 -0
  282. package/src/deps/jsr.io/@std/collections/1.0.9/chunk.ts +56 -0
  283. package/src/deps/jsr.io/@std/collections/1.0.9/deep_merge.ts +578 -0
  284. package/src/deps/jsr.io/@std/collections/1.0.9/distinct.ts +29 -0
  285. package/src/deps/jsr.io/@std/collections/1.0.9/distinct_by.ts +42 -0
  286. package/src/deps/jsr.io/@std/collections/1.0.9/drop_last_while.ts +36 -0
  287. package/src/deps/jsr.io/@std/collections/1.0.9/drop_while.ts +39 -0
  288. package/src/deps/jsr.io/@std/collections/1.0.9/filter_entries.ts +48 -0
  289. package/src/deps/jsr.io/@std/collections/1.0.9/filter_keys.ts +51 -0
  290. package/src/deps/jsr.io/@std/collections/1.0.9/filter_values.ts +51 -0
  291. package/src/deps/jsr.io/@std/collections/1.0.9/find_single.ts +48 -0
  292. package/src/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.ts +47 -0
  293. package/src/deps/jsr.io/@std/collections/1.0.9/includes_value.ts +45 -0
  294. package/src/deps/jsr.io/@std/collections/1.0.9/intersect.ts +35 -0
  295. package/src/deps/jsr.io/@std/collections/1.0.9/invert.ts +38 -0
  296. package/src/deps/jsr.io/@std/collections/1.0.9/invert_by.ts +56 -0
  297. package/src/deps/jsr.io/@std/collections/1.0.9/join_to_string.ts +109 -0
  298. package/src/deps/jsr.io/@std/collections/1.0.9/map_entries.ts +53 -0
  299. package/src/deps/jsr.io/@std/collections/1.0.9/map_keys.ts +47 -0
  300. package/src/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.ts +49 -0
  301. package/src/deps/jsr.io/@std/collections/1.0.9/map_values.ts +96 -0
  302. package/src/deps/jsr.io/@std/collections/1.0.9/max_by.ts +153 -0
  303. package/src/deps/jsr.io/@std/collections/1.0.9/max_of.ts +90 -0
  304. package/src/deps/jsr.io/@std/collections/1.0.9/max_with.ts +46 -0
  305. package/src/deps/jsr.io/@std/collections/1.0.9/min_by.ts +151 -0
  306. package/src/deps/jsr.io/@std/collections/1.0.9/min_of.ts +90 -0
  307. package/src/deps/jsr.io/@std/collections/1.0.9/min_with.ts +42 -0
  308. package/src/deps/jsr.io/@std/collections/1.0.9/mod.ts +76 -0
  309. package/src/deps/jsr.io/@std/collections/1.0.9/omit.ts +34 -0
  310. package/src/deps/jsr.io/@std/collections/1.0.9/partition.ts +85 -0
  311. package/src/deps/jsr.io/@std/collections/1.0.9/partition_entries.ts +58 -0
  312. package/src/deps/jsr.io/@std/collections/1.0.9/permutations.ts +66 -0
  313. package/src/deps/jsr.io/@std/collections/1.0.9/pick.ts +34 -0
  314. package/src/deps/jsr.io/@std/collections/1.0.9/reduce_groups.ts +45 -0
  315. package/src/deps/jsr.io/@std/collections/1.0.9/running_reduce.ts +38 -0
  316. package/src/deps/jsr.io/@std/collections/1.0.9/sample.ts +36 -0
  317. package/src/deps/jsr.io/@std/collections/1.0.9/sliding_windows.ts +86 -0
  318. package/src/deps/jsr.io/@std/collections/1.0.9/sort_by.ts +219 -0
  319. package/src/deps/jsr.io/@std/collections/1.0.9/sum_of.ts +42 -0
  320. package/src/deps/jsr.io/@std/collections/1.0.9/take_last_while.ts +37 -0
  321. package/src/deps/jsr.io/@std/collections/1.0.9/take_while.ts +44 -0
  322. package/src/deps/jsr.io/@std/collections/1.0.9/union.ts +36 -0
  323. package/src/deps/jsr.io/@std/collections/1.0.9/unzip.ts +50 -0
  324. package/src/deps/jsr.io/@std/collections/1.0.9/without_all.ts +28 -0
  325. package/src/deps/jsr.io/@std/collections/1.0.9/zip.ts +49 -0
  326. package/src/mod.ts +3 -18
  327. package/src/oai.ts +5 -0
  328. package/src/types/Ref.ts +16 -0
  329. package/src/types/RootTy.ts +40 -0
  330. package/src/types/Ty.ts +57 -0
  331. package/src/types/array.ts +9 -0
  332. package/src/types/constant.ts +8 -0
  333. package/src/types/constantUnion.ts +27 -0
  334. package/src/types/leaves.ts +21 -0
  335. package/src/types/mod.ts +10 -0
  336. package/src/types/object.ts +15 -0
  337. package/src/types/std/Option.ts +15 -0
  338. package/src/types/std/Wrapper.ts +8 -0
  339. package/src/types/std/mod.ts +2 -0
  340. package/src/types/taggedUnion.ts +28 -0
  341. package/src/util/phantoms.ts +3 -0
  342. package/src/util/recombineTaggedTemplateArgs.ts +6 -0
  343. package/esm/F.d.ts +0 -13
  344. package/esm/F.d.ts.map +0 -1
  345. package/esm/F.js +0 -10
  346. package/esm/F.js.map +0 -1
  347. package/esm/_base.d.ts +0 -13
  348. package/esm/_base.d.ts.map +0 -1
  349. package/esm/_base.js +0 -40
  350. package/esm/_base.js.map +0 -1
  351. package/esm/array.d.ts +0 -4
  352. package/esm/array.d.ts.map +0 -1
  353. package/esm/array.js +0 -9
  354. package/esm/array.js.map +0 -1
  355. package/esm/common.d.ts +0 -6
  356. package/esm/common.d.ts.map +0 -1
  357. package/esm/common.js +0 -2
  358. package/esm/common.js.map +0 -1
  359. package/esm/literal.d.ts +0 -4
  360. package/esm/literal.d.ts.map +0 -1
  361. package/esm/literal.js +0 -8
  362. package/esm/literal.js.map +0 -1
  363. package/esm/number.d.ts +0 -4
  364. package/esm/number.d.ts.map +0 -1
  365. package/esm/number.js +0 -8
  366. package/esm/number.js.map +0 -1
  367. package/esm/object.d.ts +0 -7
  368. package/esm/object.d.ts.map +0 -1
  369. package/esm/object.js.map +0 -1
  370. package/esm/schema.d.ts +0 -4
  371. package/esm/schema.d.ts.map +0 -1
  372. package/esm/schema.js +0 -9
  373. package/esm/schema.js.map +0 -1
  374. package/esm/string.d.ts +0 -4
  375. package/esm/string.d.ts.map +0 -1
  376. package/esm/string.js +0 -8
  377. package/esm/string.js.map +0 -1
  378. package/esm/union.d.ts +0 -6
  379. package/esm/union.d.ts.map +0 -1
  380. package/esm/union.js +0 -8
  381. package/esm/union.js.map +0 -1
  382. package/src/F.ts +0 -27
  383. package/src/_base.ts +0 -25
  384. package/src/array.ts +0 -11
  385. package/src/common.ts +0 -6
  386. package/src/literal.ts +0 -10
  387. package/src/number.ts +0 -10
  388. package/src/object.ts +0 -17
  389. package/src/schema.ts +0 -10
  390. package/src/string.ts +0 -10
  391. package/src/union.ts +0 -12
@@ -0,0 +1,219 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /** Order option for {@linkcode SortByOptions}. */
5
+ export type Order = "asc" | "desc";
6
+
7
+ /** Options for {@linkcode sortBy}. */
8
+ export type SortByOptions = {
9
+ /**
10
+ * The order to sort the elements in.
11
+ *
12
+ * @default {"asc"}
13
+ */
14
+ order: Order;
15
+ };
16
+
17
+ /**
18
+ * Returns all elements in the given collection, sorted by their result using
19
+ * the given selector. The selector function is called only once for each
20
+ * element. Ascending or descending order can be specified through the `order`
21
+ * option. By default, the elements are sorted in ascending order.
22
+ *
23
+ * Note: If you want to process any iterable, use the new version of
24
+ * `sortBy` from `@std/collections/unstable-sort-by`.
25
+ *
26
+ * @typeParam T The type of the array elements.
27
+ *
28
+ * @param array The array to sort.
29
+ * @param selector The selector function to get the value to sort by.
30
+ * @param options The options for sorting.
31
+ *
32
+ * @returns A new array containing all elements sorted by the selector.
33
+ *
34
+ * @example Usage
35
+ * ```ts
36
+ * import { sortBy } from "@std/collections/sort-by";
37
+ * import { assertEquals } from "@std/assert";
38
+ *
39
+ * const people = [
40
+ * { name: "Anna", age: 34 },
41
+ * { name: "Kim", age: 42 },
42
+ * { name: "John", age: 23 },
43
+ * ];
44
+ * const sortedByAge = sortBy(people, (person) => person.age);
45
+ *
46
+ * assertEquals(sortedByAge, [
47
+ * { name: "John", age: 23 },
48
+ * { name: "Anna", age: 34 },
49
+ * { name: "Kim", age: 42 },
50
+ * ]);
51
+ *
52
+ * const sortedByAgeDesc = sortBy(people, (person) => person.age, { order: "desc" });
53
+ *
54
+ * assertEquals(sortedByAgeDesc, [
55
+ * { name: "Kim", age: 42 },
56
+ * { name: "Anna", age: 34 },
57
+ * { name: "John", age: 23 },
58
+ * ]);
59
+ * ```
60
+ */
61
+ export function sortBy<T>(
62
+ array: readonly T[],
63
+ selector: (el: T) => number,
64
+ options?: SortByOptions,
65
+ ): T[];
66
+ /**
67
+ * Returns all elements in the given collection, sorted by their result using
68
+ * the given selector. The selector function is called only once for each
69
+ * element. Ascending or descending order can be specified through the `order`
70
+ * option. By default, the elements are sorted in ascending order.
71
+ *
72
+ * @typeParam T The type of the array elements.
73
+ *
74
+ * @param array The array to sort.
75
+ * @param selector The selector function to get the value to sort by.
76
+ * @param options The options for sorting.
77
+ *
78
+ * @returns A new array containing all elements sorted by the selector.
79
+ *
80
+ * @example Usage
81
+ * ```ts
82
+ * import { sortBy } from "@std/collections/sort-by";
83
+ * import { assertEquals } from "@std/assert";
84
+ *
85
+ * const people = [
86
+ * { name: "Anna" },
87
+ * { name: "Kim" },
88
+ * { name: "John" },
89
+ * ];
90
+ * const sortedByName = sortBy(people, (it) => it.name);
91
+ *
92
+ * assertEquals(sortedByName, [
93
+ * { name: "Anna" },
94
+ * { name: "John" },
95
+ * { name: "Kim" },
96
+ * ]);
97
+ * ```
98
+ */
99
+ export function sortBy<T>(
100
+ array: readonly T[],
101
+ selector: (el: T) => string,
102
+ options?: SortByOptions,
103
+ ): T[];
104
+ /**
105
+ * Returns all elements in the given collection, sorted by their result using
106
+ * the given selector. The selector function is called only once for each
107
+ * element. Ascending or descending order can be specified through the `order`
108
+ * option. By default, the elements are sorted in ascending order.
109
+ *
110
+ * @typeParam T The type of the array elements.
111
+ *
112
+ * @param array The array to sort.
113
+ * @param selector The selector function to get the value to sort by.
114
+ * @param options The options for sorting.
115
+ *
116
+ * @returns A new array containing all elements sorted by the selector.
117
+ *
118
+ * @example Usage
119
+ * ```ts
120
+ * import { sortBy } from "@std/collections/sort-by";
121
+ * import { assertEquals } from "@std/assert";
122
+ *
123
+ * const people = [
124
+ * { name: "Anna", age: 34n },
125
+ * { name: "Kim", age: 42n },
126
+ * { name: "John", age: 23n },
127
+ * ];
128
+ *
129
+ * const sortedByAge = sortBy(people, (person) => person.age);
130
+ *
131
+ * assertEquals(sortedByAge, [
132
+ * { name: "John", age: 23n },
133
+ * { name: "Anna", age: 34n },
134
+ * { name: "Kim", age: 42n },
135
+ * ]);
136
+ * ```
137
+ */
138
+
139
+ export function sortBy<T>(
140
+ array: readonly T[],
141
+ selector: (el: T) => bigint,
142
+ options?: SortByOptions,
143
+ ): T[];
144
+ /**
145
+ * Returns all elements in the given collection, sorted by their result using
146
+ * the given selector. The selector function is called only once for each
147
+ * element. Ascending or descending order can be specified through the `order`
148
+ * option. By default, the elements are sorted in ascending order.
149
+ *
150
+ * @typeParam T The type of the array elements.
151
+ *
152
+ * @param array The array to sort.
153
+ * @param selector The selector function to get the value to sort by.
154
+ * @param options The options for sorting.
155
+ *
156
+ * @returns A new array containing all elements sorted by the selector.
157
+ *
158
+ * @example Usage
159
+ * ```ts
160
+ * import { sortBy } from "@std/collections/sort-by";
161
+ * import { assertEquals } from "@std/assert";
162
+ *
163
+ * const people = [
164
+ * { name: "Anna", startedAt: new Date("2020-01-01") },
165
+ * { name: "Kim", startedAt: new Date("2020-03-01") },
166
+ * { name: "John", startedAt: new Date("2020-06-01") },
167
+ * ];
168
+ *
169
+ * const sortedByStartedAt = sortBy(people, (people) => people.startedAt);
170
+ *
171
+ * assertEquals(sortedByStartedAt, [
172
+ * { name: "Anna", startedAt: new Date("2020-01-01") },
173
+ * { name: "Kim", startedAt: new Date("2020-03-01") },
174
+ * { name: "John", startedAt: new Date("2020-06-01") },
175
+ * ]);
176
+ * ```
177
+ */
178
+ export function sortBy<T>(
179
+ array: readonly T[],
180
+ selector: (el: T) => Date,
181
+ options?: SortByOptions,
182
+ ): T[];
183
+ export function sortBy<T>(
184
+ array: readonly T[],
185
+ selector:
186
+ | ((el: T) => number)
187
+ | ((el: T) => string)
188
+ | ((el: T) => bigint)
189
+ | ((el: T) => Date),
190
+ options?: SortByOptions,
191
+ ): T[] {
192
+ const len = array.length;
193
+ const indexes = new Array<number>(len);
194
+ const selectors = new Array<ReturnType<typeof selector> | null>(len);
195
+ const order = options?.order ?? "asc";
196
+
197
+ array.forEach((element, index) => {
198
+ indexes[index] = index;
199
+ const selected = selector(element);
200
+ selectors[index] = Number.isNaN(selected) ? null : selected;
201
+ });
202
+
203
+ indexes.sort((ai, bi) => {
204
+ let a = selectors[ai]!;
205
+ let b = selectors[bi]!;
206
+ if (order === "desc") {
207
+ [a, b] = [b, a];
208
+ }
209
+ if (a === null) return 1;
210
+ if (b === null) return -1;
211
+ return a > b ? 1 : a < b ? -1 : 0;
212
+ });
213
+
214
+ for (let i = 0; i < len; i++) {
215
+ (indexes as unknown as T[])[i] = array[indexes[i]!] as T;
216
+ }
217
+
218
+ return indexes as unknown as T[];
219
+ }
@@ -0,0 +1,42 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Applies the given selector to all elements in the given collection and
6
+ * calculates the sum of the results.
7
+ *
8
+ * @typeParam T The type of the array elements.
9
+ *
10
+ * @param array The array to calculate the sum of.
11
+ * @param selector The selector function to get the value to sum.
12
+ *
13
+ * @returns The sum of all elements in the collection.
14
+ *
15
+ * @example Basic usage
16
+ * ```ts
17
+ * import { sumOf } from "@std/collections/sum-of";
18
+ * import { assertEquals } from "@std/assert";
19
+ *
20
+ * const people = [
21
+ * { name: "Anna", age: 34 },
22
+ * { name: "Kim", age: 42 },
23
+ * { name: "John", age: 23 },
24
+ * ];
25
+ *
26
+ * const totalAge = sumOf(people, (person) => person.age);
27
+ *
28
+ * assertEquals(totalAge, 99);
29
+ * ```
30
+ */
31
+ export function sumOf<T>(
32
+ array: Iterable<T>,
33
+ selector: (el: T) => number,
34
+ ): number {
35
+ let sum = 0;
36
+
37
+ for (const i of array) {
38
+ sum += selector(i);
39
+ }
40
+
41
+ return sum;
42
+ }
@@ -0,0 +1,37 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Returns all elements in the given array after the last element that does not
6
+ * match the given predicate.
7
+ *
8
+ * @typeParam T The type of the array elements.
9
+ *
10
+ * @param array The array to take elements from.
11
+ * @param predicate The predicate function to determine if an element should be
12
+ * included.
13
+ *
14
+ * @returns A new array containing all elements after the last element that does
15
+ * not match the predicate.
16
+ *
17
+ * @example Basic usage
18
+ * ```ts
19
+ * import { takeLastWhile } from "@std/collections/take-last-while";
20
+ * import { assertEquals } from "@std/assert";
21
+ *
22
+ * const numbers = [1, 2, 3, 4, 5, 6];
23
+ *
24
+ * const result = takeLastWhile(numbers, (number) => number > 4);
25
+ *
26
+ * assertEquals(result, [5, 6]);
27
+ * ```
28
+ */
29
+ export function takeLastWhile<T>(
30
+ array: readonly T[],
31
+ predicate: (el: T) => boolean,
32
+ ): T[] {
33
+ let offset = array.length;
34
+ while (0 < offset && predicate(array[offset - 1] as T)) offset--;
35
+
36
+ return array.slice(offset, array.length);
37
+ }
@@ -0,0 +1,44 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Returns all elements in the given collection until the first element that
6
+ * does not match the given predicate.
7
+ *
8
+ * Note: If you want to process any iterable, use the new version of
9
+ * `takeWhile` from `@std/collections/unstable-take-while`.
10
+ *
11
+ * @typeParam T The type of the array elements.
12
+ *
13
+ * @param array The array to take elements from.
14
+ * @param predicate The predicate function to determine if an element should be
15
+ * included.
16
+ *
17
+ * @returns A new array containing all elements until the first element that
18
+ * does not match the predicate.
19
+ *
20
+ * @example Basic usage
21
+ * ```ts
22
+ * import { takeWhile } from "@std/collections/take-while";
23
+ * import { assertEquals } from "@std/assert";
24
+ *
25
+ * const numbers = [1, 2, 3, 4, 5, 6];
26
+ *
27
+ * const result = takeWhile(numbers, (number) => number < 4);
28
+ *
29
+ * assertEquals(result, [1, 2, 3]);
30
+ * ```
31
+ */
32
+ export function takeWhile<T>(
33
+ array: readonly T[],
34
+ predicate: (el: T) => boolean,
35
+ ): T[] {
36
+ let offset = 0;
37
+ const length = array.length;
38
+
39
+ while (length > offset && predicate(array[offset] as T)) {
40
+ offset++;
41
+ }
42
+
43
+ return array.slice(0, offset);
44
+ }
@@ -0,0 +1,36 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Returns all distinct elements that appear in any of the given arrays.
6
+ *
7
+ * @typeParam T The type of the array elements.
8
+ *
9
+ * @param arrays The arrays to get the union of.
10
+ *
11
+ * @returns A new array containing all distinct elements from the given arrays.
12
+ *
13
+ * @example Basic usage
14
+ * ```ts
15
+ * import { union } from "@std/collections/union";
16
+ * import { assertEquals } from "@std/assert";
17
+ *
18
+ * const soupIngredients = ["Pepper", "Carrots", "Leek"];
19
+ * const saladIngredients = ["Carrots", "Radicchio", "Pepper"];
20
+ *
21
+ * const shoppingList = union(soupIngredients, saladIngredients);
22
+ *
23
+ * assertEquals(shoppingList, ["Pepper", "Carrots", "Leek", "Radicchio"]);
24
+ * ```
25
+ */
26
+ export function union<T>(...arrays: Iterable<T>[]): T[] {
27
+ const set = new Set<T>();
28
+
29
+ for (const array of arrays) {
30
+ for (const element of array) {
31
+ set.add(element);
32
+ }
33
+ }
34
+
35
+ return Array.from(set);
36
+ }
@@ -0,0 +1,50 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Builds two separate arrays from the given array of 2-tuples, with the first
6
+ * returned array holding all first tuple elements and the second one holding
7
+ * all the second elements.
8
+ *
9
+ * @typeParam T The type of the first tuple elements.
10
+ * @typeParam U The type of the second tuple elements.
11
+ *
12
+ * @param pairs The array of 2-tuples to unzip.
13
+ *
14
+ * @returns A tuple containing two arrays, the first one holding all first tuple
15
+ * elements and the second one holding all second elements.
16
+ *
17
+ * @example Basic usage
18
+ * ```ts
19
+ * import { unzip } from "@std/collections/unzip";
20
+ * import { assertEquals } from "@std/assert";
21
+ *
22
+ * const parents = [
23
+ * ["Maria", "Jeff"],
24
+ * ["Anna", "Kim"],
25
+ * ["John", "Leroy"],
26
+ * ] as [string, string][];
27
+ *
28
+ * const [moms, dads] = unzip(parents);
29
+ *
30
+ * assertEquals(moms, ["Maria", "Anna", "John"]);
31
+ * assertEquals(dads, ["Jeff", "Kim", "Leroy"]);
32
+ * ```
33
+ */
34
+ export function unzip<T, U>(pairs: readonly [T, U][]): [T[], U[]] {
35
+ const { length } = pairs;
36
+
37
+ const result: [T[], U[]] = [
38
+ new Array<T>(length),
39
+ new Array<U>(length),
40
+ ];
41
+
42
+ for (let i = 0; i < length; ++i) {
43
+ const pair = pairs[i] as [T, U];
44
+
45
+ result[0][i] = pair[0];
46
+ result[1][i] = pair[1];
47
+ }
48
+
49
+ return result;
50
+ }
@@ -0,0 +1,28 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * Returns an array excluding all given values.
6
+ *
7
+ * @typeParam T The type of the array elements.
8
+ *
9
+ * @param array The array to exclude values from.
10
+ * @param values The values to exclude from the array.
11
+ *
12
+ * @returns A new array containing all elements from the given array except the
13
+ * ones that are in the values array.
14
+ *
15
+ * @example Basic usage
16
+ * ```ts
17
+ * import { withoutAll } from "@std/collections/without-all";
18
+ * import { assertEquals } from "@std/assert";
19
+ *
20
+ * const withoutList = withoutAll([2, 1, 2, 3], [1, 2]);
21
+ *
22
+ * assertEquals(withoutList, [3]);
23
+ * ```
24
+ */
25
+ export function withoutAll<T>(array: readonly T[], values: readonly T[]): T[] {
26
+ const toExclude = new Set(values);
27
+ return array.filter((it) => !toExclude.has(it));
28
+ }
@@ -0,0 +1,49 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { minOf } from "./min_of.js";
5
+
6
+ /**
7
+ * Builds N-tuples of elements from the given N arrays with matching indices,
8
+ * stopping when the smallest array's end is reached.
9
+ *
10
+ * @typeParam T the type of the tuples produced by this function.
11
+ *
12
+ * @param arrays The arrays to zip.
13
+ *
14
+ * @returns A new array containing N-tuples of elements from the given arrays.
15
+ *
16
+ * @example Basic usage
17
+ * ```ts
18
+ * import { zip } from "@std/collections/zip";
19
+ * import { assertEquals } from "@std/assert";
20
+ *
21
+ * const numbers = [1, 2, 3, 4];
22
+ * const letters = ["a", "b", "c", "d"];
23
+ * const pairs = zip(numbers, letters);
24
+ *
25
+ * assertEquals(
26
+ * pairs,
27
+ * [
28
+ * [1, "a"],
29
+ * [2, "b"],
30
+ * [3, "c"],
31
+ * [4, "d"],
32
+ * ],
33
+ * );
34
+ * ```
35
+ */
36
+ export function zip<T extends unknown[]>(
37
+ ...arrays: { [K in keyof T]: ReadonlyArray<T[K]> }
38
+ ): T[] {
39
+ const minLength = minOf(arrays, (element) => element.length) ?? 0;
40
+
41
+ const result: T[] = new Array(minLength);
42
+
43
+ for (let i = 0; i < minLength; i += 1) {
44
+ const arr = arrays.map((it) => it[i]);
45
+ result[i] = arr as T;
46
+ }
47
+
48
+ return result;
49
+ }
package/src/mod.ts CHANGED
@@ -1,19 +1,4 @@
1
- import type { ArrayTy } from "./array.js"
2
- import type { NumberTy } from "./number.js"
3
- import type { ObjectTy } from "./object.js"
4
- import type { StringTy } from "./string.js"
5
-
6
- export type RootTy = NumberTy | StringTy | ObjectTy | ArrayTy
7
-
8
- // moderate --exclude _base.ts code_critique.ts
9
-
10
- export * from "./array.js"
11
- export * from "./common.js"
12
- export * from "./F.js"
13
- export * from "./literal.js"
14
- export * from "./number.js"
15
- export * from "./object.js"
1
+ import "./_dnt.polyfills.js";
2
+ export * as T from "./types/mod.js"
16
3
  export * from "./ResponseFormat.js"
17
- export * from "./schema.js"
18
- export * from "./string.js"
19
- export * from "./union.js"
4
+ export * from "./Tool.js"
package/src/oai.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type Openai from "openai"
2
+
3
+ export type JsonSchema = Openai.ResponseFormatJSONSchema["json_schema"]
4
+ export type ChatCompletion = Openai.Chat.ChatCompletion
5
+ export type ChatCompletionChoice = Openai.Chat.Completions.ChatCompletion.Choice
@@ -0,0 +1,16 @@
1
+ import type { Applied, Schema, Ty } from "./Ty.js"
2
+ import { recombineTaggedTemplateArgs } from "../util/recombineTaggedTemplateArgs.js"
3
+
4
+ export type Ref = (ty: Ty) => Schema
5
+
6
+ export function Ref(applied: Applied): Ref {
7
+ return (ty) => {
8
+ applied = { ...applied, ...ty.applied }
9
+ const description = ty.descriptions
10
+ .map(({ template, placeheld }) =>
11
+ recombineTaggedTemplateArgs(template, placeheld.map((k) => applied[k]!))
12
+ )
13
+ .join(" ")
14
+ return ty.toSchema(description, Ref(applied))
15
+ }
16
+ }
@@ -0,0 +1,40 @@
1
+ import { phantoms } from "../util/phantoms.js"
2
+ import { Ref } from "./Ref.js"
3
+ import type { Applied, Description, Schema, ToSchema, Ty } from "./Ty.js"
4
+
5
+ export function RootTy<T, P extends string = never>(
6
+ toSchema: ToSchema,
7
+ descriptions: Array<Description> = [],
8
+ applied: Applied = {},
9
+ ): RootTy<T, P> {
10
+ return Object.assign(
11
+ <P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2) =>
12
+ RootTy<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...descriptions], applied),
13
+ phantoms<{ [Ty.T]: T; [Ty.P]: P }>(),
14
+ {
15
+ toSchema,
16
+ descriptions,
17
+ applied,
18
+ apply: <A extends Partial<Record<P, string | number>>>(values: A) => {
19
+ return RootTy<T, Exclude<P, keyof A>>(toSchema, descriptions, { ...applied, ...values })
20
+ },
21
+ schema(this: RootTy<T, never>) {
22
+ return Ref({})(this)
23
+ },
24
+ isRoot(): this is RootTy {
25
+ return true
26
+ },
27
+ },
28
+ )
29
+ }
30
+
31
+ export interface RootTy<T = any, P extends string = string> extends Ty<T, P> {
32
+ <P2 extends Array<string>>(
33
+ template: TemplateStringsArray,
34
+ ...placeheld: P2
35
+ ): RootTy<T, P | P2[number]>
36
+ apply: <A extends Partial<Record<P, number | string>>>(
37
+ values: A,
38
+ ) => RootTy<T, Exclude<P, keyof A>>
39
+ schema(this: RootTy<T, never>): Schema
40
+ }
@@ -0,0 +1,57 @@
1
+ import type { Ref } from "./Ref.js"
2
+ import { phantoms } from "../util/phantoms.js"
3
+ import type { RootTy } from "./RootTy.js"
4
+
5
+ export function Ty<T, P extends string = never>(
6
+ toSchema: ToSchema,
7
+ descriptions: Array<Description> = [],
8
+ applied: Applied = {},
9
+ ): Ty<T, P> {
10
+ return Object.assign(
11
+ <P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2) =>
12
+ Ty<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...descriptions], applied),
13
+ phantoms<{ [Ty.T]: T; [Ty.P]: P }>(),
14
+ {
15
+ toSchema,
16
+ descriptions,
17
+ applied,
18
+ apply: <A extends Partial<Record<P, string | number>>>(values: A) => {
19
+ return Ty<T, Exclude<P, keyof A>>(toSchema, descriptions, { ...applied, ...values })
20
+ },
21
+ isRoot(): this is RootTy {
22
+ return false
23
+ },
24
+ },
25
+ )
26
+ }
27
+
28
+ export interface Ty<T = any, P extends string = string> {
29
+ <P2 extends Array<string>>(
30
+ template: TemplateStringsArray,
31
+ ...placeheld: P2
32
+ ): Ty<T, P | P2[number]>
33
+ [Ty.T]: T
34
+ [Ty.P]: P
35
+ toSchema: ToSchema
36
+ descriptions: Array<Description>
37
+ applied: Applied
38
+ apply: <A extends Partial<Record<P, number | string>>>(values: A) => Ty<T, Exclude<P, keyof A>>
39
+ isRoot(): this is RootTy
40
+ }
41
+
42
+ export namespace Ty {
43
+ export type T = typeof T
44
+ export declare const T: unique symbol
45
+ export type P = typeof P
46
+ export declare const P: unique symbol
47
+ }
48
+
49
+ export type ToSchema = (description: string | undefined, ref: Ref) => Schema
50
+ export type Schema = Record<string, unknown>
51
+
52
+ export interface Description {
53
+ template: TemplateStringsArray
54
+ placeheld: Array<string>
55
+ }
56
+
57
+ export type Applied = Record<string, number | string>
@@ -0,0 +1,9 @@
1
+ import { Ty } from "./Ty.js"
2
+
3
+ export function array<E extends Ty>(element: E): Ty<Array<E[Ty.T]>, E[Ty.P]> {
4
+ return Ty((description, ref) => ({
5
+ type: "array",
6
+ description,
7
+ items: ref(element),
8
+ }))
9
+ }
@@ -0,0 +1,8 @@
1
+ import { Ty } from "./Ty.js"
2
+
3
+ export function constant<V extends number | string>(value: V): Ty<V, never> {
4
+ return Ty((description) => ({
5
+ const: value,
6
+ description,
7
+ }))
8
+ }