arktype 3.0.0-beta.1 → 3.0.0-rc.0

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 (312) hide show
  1. package/README.md +48 -144
  2. package/out/_internal/regex/charset.d.ts +24 -0
  3. package/out/_internal/regex/escape.d.ts +29 -0
  4. package/out/_internal/regex/execArray.d.ts +24 -0
  5. package/out/_internal/regex/group.d.ts +34 -0
  6. package/out/_internal/regex/index.d.ts +2 -0
  7. package/out/_internal/regex/internal.d.ts +9 -0
  8. package/out/_internal/regex/parse.d.ts +10 -0
  9. package/out/_internal/regex/quantify.d.ts +59 -0
  10. package/out/_internal/regex/regex.d.ts +38 -0
  11. package/out/_internal/regex/state.d.ts +383 -0
  12. package/out/_internal/schema/codecs.d.ts +2 -0
  13. package/out/_internal/schema/config.d.ts +103 -0
  14. package/out/_internal/schema/constraint.d.ts +78 -0
  15. package/out/_internal/schema/errors.d.ts +1 -0
  16. package/out/_internal/schema/generic.d.ts +85 -0
  17. package/out/_internal/schema/i18n.d.ts +3 -0
  18. package/out/_internal/schema/index.d.ts +54 -0
  19. package/out/_internal/schema/internal.d.ts +15 -0
  20. package/out/_internal/schema/intrinsic.d.ts +28 -0
  21. package/out/_internal/schema/kinds.d.ts +76 -0
  22. package/out/_internal/schema/module.d.ts +23 -0
  23. package/out/_internal/schema/mutatesInput.d.ts +2 -0
  24. package/out/_internal/schema/node.d.ts +349 -0
  25. package/out/_internal/schema/parse.d.ts +77 -0
  26. package/out/_internal/schema/parseSchema.d.ts +116 -0
  27. package/out/_internal/schema/predicate.d.ts +46 -0
  28. package/out/_internal/schema/refinements/after.d.ts +32 -0
  29. package/out/_internal/schema/refinements/before.d.ts +32 -0
  30. package/out/_internal/schema/refinements/divisor.d.ts +41 -0
  31. package/out/_internal/schema/refinements/exactLength.d.ts +43 -0
  32. package/out/_internal/schema/refinements/kinds.d.ts +40 -0
  33. package/out/_internal/schema/refinements/max.d.ts +33 -0
  34. package/out/_internal/schema/refinements/maxLength.d.ts +32 -0
  35. package/out/_internal/schema/refinements/min.d.ts +33 -0
  36. package/out/_internal/schema/refinements/minLength.d.ts +32 -0
  37. package/out/_internal/schema/refinements/notEqual.d.ts +38 -0
  38. package/out/_internal/schema/refinements/notEqualLength.d.ts +38 -0
  39. package/out/_internal/schema/refinements/pattern.d.ts +43 -0
  40. package/out/_internal/schema/refinements/range.d.ts +101 -0
  41. package/out/_internal/schema/roots/alias.d.ts +49 -0
  42. package/out/_internal/schema/roots/basis.d.ts +12 -0
  43. package/out/_internal/schema/roots/domain.d.ts +45 -0
  44. package/out/_internal/schema/roots/intersection.d.ts +72 -0
  45. package/out/_internal/schema/roots/morph.d.ts +59 -0
  46. package/out/_internal/schema/roots/proto.d.ts +42 -0
  47. package/out/_internal/schema/roots/root.d.ts +163 -0
  48. package/out/_internal/schema/roots/union.d.ts +146 -0
  49. package/out/_internal/schema/roots/unit.d.ts +36 -0
  50. package/out/_internal/schema/runtime.d.ts +29 -0
  51. package/out/_internal/schema/runtimeLean.d.ts +2 -0
  52. package/out/_internal/schema/runtimeNone.d.ts +2 -0
  53. package/out/_internal/schema/runtimeNoneLean.d.ts +2 -0
  54. package/out/_internal/schema/scope.d.ts +203 -0
  55. package/out/_internal/schema/shared/codecs.d.ts +5 -0
  56. package/out/_internal/schema/shared/compile.d.ts +144 -0
  57. package/out/_internal/schema/shared/configured.d.ts +14 -0
  58. package/out/_internal/schema/shared/declare.d.ts +100 -0
  59. package/out/_internal/schema/shared/disjoint.d.ts +45 -0
  60. package/out/_internal/schema/shared/enWriters.d.ts +30 -0
  61. package/out/_internal/schema/shared/errorModes.d.ts +25 -0
  62. package/out/_internal/schema/shared/errorWriters.d.ts +34 -0
  63. package/out/_internal/schema/shared/errors.d.ts +264 -0
  64. package/out/_internal/schema/shared/implement.d.ts +154 -0
  65. package/out/_internal/schema/shared/inPlace.d.ts +8 -0
  66. package/out/_internal/schema/shared/issueFeatures.d.ts +38 -0
  67. package/out/_internal/schema/shared/issues.d.ts +261 -0
  68. package/out/_internal/schema/shared/issuesLean.d.ts +80 -0
  69. package/out/_internal/schema/shared/issuesNone.d.ts +22 -0
  70. package/out/_internal/schema/shared/issuesNoneLean.d.ts +20 -0
  71. package/out/_internal/schema/shared/issuesUndetailed.d.ts +25 -0
  72. package/out/_internal/schema/shared/jsonSchema.d.ts +153 -0
  73. package/out/_internal/schema/shared/listed.d.ts +15 -0
  74. package/out/_internal/schema/shared/locale.d.ts +149 -0
  75. package/out/_internal/schema/shared/registry.d.ts +16 -0
  76. package/out/_internal/schema/shared/render.d.ts +3 -0
  77. package/out/_internal/schema/shared/rootApply.d.ts +19 -0
  78. package/out/_internal/schema/shared/sets.d.ts +26 -0
  79. package/out/_internal/schema/shared/standardFailure.d.ts +22 -0
  80. package/out/_internal/schema/shared/standardSchema.d.ts +124 -0
  81. package/out/_internal/schema/shared/toJsonSchema.d.ts +229 -0
  82. package/out/_internal/schema/shared/transform.d.ts +35 -0
  83. package/out/_internal/schema/shared/traversal.d.ts +288 -0
  84. package/out/_internal/schema/shared/utils.d.ts +59 -0
  85. package/out/_internal/schema/structure/index.d.ts +43 -0
  86. package/out/_internal/schema/structure/optional.d.ts +61 -0
  87. package/out/_internal/schema/structure/prop.d.ts +45 -0
  88. package/out/_internal/schema/structure/required.d.ts +49 -0
  89. package/out/_internal/schema/structure/sequence.d.ts +127 -0
  90. package/out/_internal/schema/structure/shared.d.ts +3 -0
  91. package/out/_internal/schema/structure/structure.d.ts +178 -0
  92. package/out/_internal/schema/units.d.ts +123 -0
  93. package/out/_internal/sets/algebra.d.ts +26 -0
  94. package/out/_internal/sets/constraint.d.ts +19 -0
  95. package/out/_internal/sets/engine.d.ts +2 -0
  96. package/out/_internal/sets/formats.d.ts +23 -0
  97. package/out/_internal/sets/fromJsonSchema.d.ts +15 -0
  98. package/out/_internal/sets/implement.d.ts +16 -0
  99. package/out/_internal/sets/index.d.ts +2 -0
  100. package/out/_internal/sets/internal.d.ts +20 -0
  101. package/out/_internal/sets/intersections.d.ts +5 -0
  102. package/out/_internal/sets/kinds.d.ts +3 -0
  103. package/out/_internal/sets/refinements.d.ts +14 -0
  104. package/out/_internal/sets/roots/alias.d.ts +3 -0
  105. package/out/_internal/sets/roots/domain.d.ts +3 -0
  106. package/out/_internal/sets/roots/intersection.d.ts +4 -0
  107. package/out/_internal/sets/roots/morph.d.ts +4 -0
  108. package/out/_internal/sets/roots/proto.d.ts +3 -0
  109. package/out/_internal/sets/roots/union.d.ts +16 -0
  110. package/out/_internal/sets/roots/unit.d.ts +3 -0
  111. package/out/_internal/sets/structure/index.d.ts +3 -0
  112. package/out/_internal/sets/structure/prop.d.ts +8 -0
  113. package/out/_internal/sets/structure/sequence.d.ts +3 -0
  114. package/out/_internal/sets/structure/structure.d.ts +3 -0
  115. package/out/_internal/sets/toJsonSchema.d.ts +25 -0
  116. package/out/_internal/util/arrays.d.ts +130 -0
  117. package/out/_internal/util/clone.d.ts +4 -0
  118. package/out/_internal/util/describe.d.ts +25 -0
  119. package/out/_internal/util/domain.d.ts +49 -0
  120. package/out/_internal/util/errors.d.ts +29 -0
  121. package/out/_internal/util/facts.d.ts +22 -0
  122. package/out/_internal/util/flatMorph.d.ts +41 -0
  123. package/out/_internal/util/formats.d.ts +8 -0
  124. package/out/_internal/util/functions.d.ts +33 -0
  125. package/out/_internal/util/generics.d.ts +65 -0
  126. package/out/_internal/util/get.d.ts +9 -0
  127. package/out/_internal/util/hkt.d.ts +27 -0
  128. package/out/_internal/util/i18n.d.ts +12 -0
  129. package/out/_internal/util/index.d.ts +28 -0
  130. package/out/_internal/util/internal.d.ts +2 -0
  131. package/out/_internal/util/intersections.d.ts +50 -0
  132. package/out/_internal/util/isomorphic.d.ts +8 -0
  133. package/out/_internal/util/keys.d.ts +18 -0
  134. package/out/_internal/util/lazily.d.ts +7 -0
  135. package/out/_internal/util/numbers.d.ts +82 -0
  136. package/out/_internal/util/objectKinds.d.ts +157 -0
  137. package/out/_internal/util/path.d.ts +16 -0
  138. package/out/_internal/util/primitive.d.ts +16 -0
  139. package/out/_internal/util/records.d.ts +173 -0
  140. package/out/_internal/util/registry.d.ts +13 -0
  141. package/out/_internal/util/scanner.d.ts +110 -0
  142. package/out/_internal/util/serialize.d.ts +40 -0
  143. package/out/_internal/util/strings.d.ts +35 -0
  144. package/out/_internal/util/traits.d.ts +89 -0
  145. package/out/_internal/util/unionToTuple.d.ts +14 -0
  146. package/out/_internal/util/weak.d.ts +8 -0
  147. package/out/attributes.d.ts +15 -11
  148. package/out/checkers.d.ts +1 -1
  149. package/out/chunk-22RQSVV3.js +0 -0
  150. package/out/chunk-3HZC67MT.js +965 -0
  151. package/out/chunk-3KBOPH3J.js +1564 -0
  152. package/out/chunk-3SH2BQ4T.js +15 -0
  153. package/out/chunk-46PLKNON.js +126 -0
  154. package/out/{chunk-G45P2CLE.js → chunk-4FTHWK63.js} +6 -1
  155. package/out/{chunk-UK5UGFOX.js → chunk-4HREHNIV.js} +23 -11
  156. package/out/chunk-4NZCLVBD.js +14 -0
  157. package/out/chunk-6FMBO47M.js +7 -0
  158. package/out/chunk-7TALAWYX.js +10 -0
  159. package/out/{chunk-DLWCO4RV.js → chunk-BCYKO54Z.js} +11 -2
  160. package/out/chunk-BDJVONP7.js +168 -0
  161. package/out/{chunk-E3DZXEZK.js → chunk-C2JOL5M2.js} +4 -2
  162. package/out/{chunk-2U2AWCI3.js → chunk-C2V6QPE3.js} +126 -97
  163. package/out/chunk-C3B4IFQL.js +6408 -0
  164. package/out/chunk-CWSF57VM.js +10 -0
  165. package/out/chunk-F5BACUJS.js +7 -0
  166. package/out/{chunk-EVCML554.js → chunk-FWRSDUJ2.js} +14 -5
  167. package/out/chunk-GID3FSQA.js +161 -0
  168. package/out/chunk-I2KLQ2HA.js +22 -0
  169. package/out/chunk-K7SLP5D2.js +84 -0
  170. package/out/chunk-KQPSKGUI.js +9 -0
  171. package/out/chunk-KXOC3JEX.js +8234 -0
  172. package/out/chunk-KXOSUYRA.js +405 -0
  173. package/out/chunk-LHNEY6QW.js +0 -0
  174. package/out/chunk-MTWKGAGO.js +323 -0
  175. package/out/chunk-NU73GNCX.js +170 -0
  176. package/out/{chunk-RAZ3TXOE.js → chunk-P5W67FQH.js} +34 -19
  177. package/out/chunk-PDLTEX6Z.js +1118 -0
  178. package/out/{chunk-VV6YDN2D.js → chunk-QUS4IAXJ.js} +304 -263
  179. package/out/chunk-R7WXIH5P.js +94 -0
  180. package/out/chunk-TACLEIDM.js +95 -0
  181. package/out/chunk-UJJGG4VQ.js +71 -0
  182. package/out/chunk-US6BWOGJ.js +109 -0
  183. package/out/chunk-VMMMOO4R.js +945 -0
  184. package/out/chunk-VYMXHSFR.js +439 -0
  185. package/out/chunk-W2XOI5DY.js +141 -0
  186. package/out/chunk-WC5L5YRP.js +25 -0
  187. package/out/{chunk-NRIGTMPM.js → chunk-WKOSL2G6.js} +4 -1
  188. package/out/chunk-XLG66ZDF.js +0 -0
  189. package/out/{chunk-5U2ZMDNI.js → chunk-XNUAQSJ4.js} +52 -30
  190. package/out/chunk-ZRYEHGSG.js +79 -0
  191. package/out/cli.d.ts +28 -0
  192. package/out/cli.js +636 -0
  193. package/out/codecs.d.ts +6 -5
  194. package/out/codecs.js +23 -7
  195. package/out/config.d.ts +5 -17
  196. package/out/config.js +11 -2
  197. package/out/declare.d.ts +40 -12
  198. package/out/deferred.d.ts +2 -2
  199. package/out/errors.d.ts +1 -1
  200. package/out/errors.js +10 -2
  201. package/out/fn.d.ts +20 -13
  202. package/out/fromJsonSchema.d.ts +18 -0
  203. package/out/generic.d.ts +9 -6
  204. package/out/i18n.d.ts +2 -2
  205. package/out/i18n.js +9 -2
  206. package/out/index.d.ts +16 -7
  207. package/out/index.js +25 -8
  208. package/out/internal.d.ts +4 -0
  209. package/out/internal.js +41 -17
  210. package/out/island.js +22 -6
  211. package/out/islandDependency.js +42 -18
  212. package/out/jsonSchema/infer.d.ts +805 -0
  213. package/out/jsonSchema/validate.d.ts +416 -0
  214. package/out/keywords/Array.d.ts +2 -2
  215. package/out/keywords/builtins.d.ts +3 -3
  216. package/out/keywords/constructors.d.ts +1 -1
  217. package/out/keywords/functions.d.ts +5 -192
  218. package/out/keywords/keywords.d.ts +3 -3
  219. package/out/keywords/number.d.ts +2 -2
  220. package/out/keywords/phrases.d.ts +4 -191
  221. package/out/keywords/string.d.ts +3 -3
  222. package/out/keywords/ts.d.ts +18 -18
  223. package/out/keywords/ts.js +19 -4
  224. package/out/locale.d.ts +6 -2
  225. package/out/locales/de.js +9 -2
  226. package/out/locales/en.js +21 -5
  227. package/out/match.d.ts +13 -10
  228. package/out/module.d.ts +2 -2
  229. package/out/mutatesInput.js +18 -3
  230. package/out/nary.d.ts +220 -194
  231. package/out/parser/ast/bounds.d.ts +2 -2
  232. package/out/parser/ast/default.d.ts +2 -2
  233. package/out/parser/ast/divisor.d.ts +2 -2
  234. package/out/parser/ast/generic.d.ts +2 -2
  235. package/out/parser/ast/infer.d.ts +1 -1
  236. package/out/parser/ast/keyof.d.ts +2 -2
  237. package/out/parser/ast/utils.d.ts +1 -1
  238. package/out/parser/ast/validate.d.ts +2 -2
  239. package/out/parser/definition.d.ts +4 -4
  240. package/out/parser/objectLiteral.d.ts +2 -2
  241. package/out/parser/property.d.ts +2 -2
  242. package/out/parser/reduce/dynamic.d.ts +2 -2
  243. package/out/parser/reduce/shared.d.ts +1 -1
  244. package/out/parser/reduce/static.d.ts +1 -1
  245. package/out/parser/shift/operand/enclosed.d.ts +2 -2
  246. package/out/parser/shift/operand/genericArgs.d.ts +2 -2
  247. package/out/parser/shift/operand/operand.d.ts +1 -1
  248. package/out/parser/shift/operand/unenclosed.d.ts +2 -2
  249. package/out/parser/shift/operand/unresolvable.d.ts +2 -2
  250. package/out/parser/shift/operator/bounds.d.ts +2 -2
  251. package/out/parser/shift/operator/brand.d.ts +2 -2
  252. package/out/parser/shift/operator/default.d.ts +4 -4
  253. package/out/parser/shift/operator/divisor.d.ts +1 -1
  254. package/out/parser/shift/operator/operator.d.ts +1 -1
  255. package/out/parser/shift/tokens.d.ts +1 -1
  256. package/out/parser/string.d.ts +2 -2
  257. package/out/parser/tupleExpressions.d.ts +6 -8
  258. package/out/parser/tupleLiteral.d.ts +2 -2
  259. package/out/precompiled.d.ts +1 -1
  260. package/out/precompiled.js +16 -2
  261. package/out/regex.d.ts +1 -0
  262. package/out/regex.js +2 -0
  263. package/out/runtime.d.ts +10 -8
  264. package/out/runtime.js +6 -4
  265. package/out/runtimeDevelopment.js +70 -52
  266. package/out/schema.d.ts +1 -0
  267. package/out/schema.js +15 -0
  268. package/out/schemaInternal.d.ts +1 -0
  269. package/out/schemaInternal.js +1401 -0
  270. package/out/schemaIssueFeatures.d.ts +1 -0
  271. package/out/schemaRuntime.d.ts +1 -0
  272. package/out/schemaRuntime.js +7 -0
  273. package/out/schemaRuntimeLean.d.ts +1 -0
  274. package/out/schemaRuntimeLean.js +1870 -0
  275. package/out/schemaRuntimeNone.d.ts +1 -0
  276. package/out/schemaRuntimeNone.js +1774 -0
  277. package/out/schemaRuntimeNoneLean.d.ts +1 -0
  278. package/out/schemaRuntimeNoneLean.js +1767 -0
  279. package/out/scope.d.ts +3 -4
  280. package/out/shared/issueFeatures.d.ts +38 -0
  281. package/out/shared/issueFeatures.js +40 -0
  282. package/out/standalone/artifact.d.ts +6 -6
  283. package/out/standalone/baking.d.ts +2 -2
  284. package/out/standalone/combinators.d.ts +1 -1
  285. package/out/standalone/compilers.d.ts +1 -1
  286. package/out/standalone/fallbacks.d.ts +1 -1
  287. package/out/standalone/keys.d.ts +1 -1
  288. package/out/standalone/sites.d.ts +3 -3
  289. package/out/standalone/units.d.ts +1 -1
  290. package/out/standalone/values.d.ts +1 -1
  291. package/out/type.d.ts +6 -6
  292. package/out/util.d.ts +1 -0
  293. package/out/util.js +137 -0
  294. package/out/variants/array.d.ts +6 -6
  295. package/out/variants/base.d.ts +61 -10
  296. package/out/variants/date.d.ts +5 -5
  297. package/out/variants/instantiate.d.ts +1 -1
  298. package/out/variants/number.d.ts +6 -6
  299. package/out/variants/object.d.ts +25 -12
  300. package/out/variants/string.d.ts +8 -8
  301. package/package.json +183 -8
  302. package/skills/arktype/SKILL.md +93 -93
  303. package/skills/arktype/references/migrating.md +144 -158
  304. package/skills/arktype/references/precompile.md +7 -7
  305. package/out/chunk-4CUA5XIP.js +0 -7
  306. package/out/chunk-GPNK5353.js +0 -2529
  307. package/out/chunk-MLKGABMK.js +0 -9
  308. package/out/chunk-PRTMQCHS.js +0 -3
  309. package/out/chunk-R5G57XC7.js +0 -7
  310. package/out/chunk-SWOOCAHN.js +0 -4
  311. package/out/chunk-TAHPKDNM.js +0 -3
  312. package/out/chunk-UETB6YE2.js +0 -14
@@ -0,0 +1,18 @@
1
+ import type { array, join } from "./arrays.ts";
2
+ import type { NonNegativeIntegerLiteral } from "./numbers.ts";
3
+ export type Key = string | symbol;
4
+ export type toArkKey<o, k extends keyof o> = k extends number ? [
5
+ o,
6
+ number
7
+ ] extends [array, k] ? NonNegativeIntegerLiteral : `${k}` : k;
8
+ export type arkIndexableOf<o> = arkKeyOf<o> extends infer k ? k extends `${infer index extends number}` ? index | k : k : never;
9
+ export type arkKeyOf<o> = [
10
+ o
11
+ ] extends [object] ? [
12
+ o
13
+ ] extends [array] ? arkArrayKeyOf<o> : arkObjectLiteralKeyOf<o> : never;
14
+ type arkArrayKeyOf<a extends array> = number extends a["length"] ? NonNegativeIntegerLiteral : keyof a extends infer i ? i extends `${number}` ? i : never : never;
15
+ type arkObjectLiteralKeyOf<o extends object> = keyof o extends infer k ? k extends number ? `${k}` : k : never;
16
+ export type arkGet<o, k extends arkIndexableOf<o>> = o[k extends keyof o ? k : NonNegativeIntegerLiteral extends k ? number & keyof o : k extends number ? `${k}` & keyof o : never];
17
+ export type writeInvalidKeysMessage<o extends string, keys extends array<string>> = `Key${keys["length"] extends 1 ? "" : "s"} ${join<keys, ", ">} ${keys["length"] extends 1 ? "does" : "do"} not exist on ${o}`;
18
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare const lazily: <t extends object>(thunk: () => t) => t;
2
+ /**
3
+ * defines `k` as a getter computing `thunk` once and then holding its result.
4
+ * A result `isFinal` rejects is returned without being held, so the next read
5
+ * computes it again, e.g. a placeholder for an alias still resolving
6
+ */
7
+ export declare const defineLazily: <k extends PropertyKey>(o: object, k: k, thunk: (k: k) => unknown, isFinal?: (result: unknown) => boolean) => void;
@@ -0,0 +1,82 @@
1
+ export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
2
+ export type NumberLiteral<n extends number = number> = `${n}`;
3
+ /** a number written as its TypeScript name, which has no literal type */
4
+ export type NonFiniteNumberLiteral = keyof typeof nonFiniteNumbers;
5
+ export declare const nonFiniteNumbers: {
6
+ NaN: number;
7
+ Infinity: number;
8
+ "-Infinity": number;
9
+ };
10
+ export type BigintLiteral<n extends bigint = bigint> = `${n}n`;
11
+ export type IntegerLiteral<n extends bigint = bigint> = `${n}`;
12
+ export type NonNegativeIntegerLiteral<n extends bigint = bigint> = `${Digit}` | (`${Exclude<Digit, 0>}${string}` & `${n}`);
13
+ /**
14
+ * Matches a well-formatted numeric expression according to the following rules:
15
+ * 1. Must include an integer portion (i.e. '.321' must be written as '0.321')
16
+ * 2. The first digit of the value must not be 0, unless the entire integer portion is 0
17
+ * 3. If the value includes a decimal, its last digit may not be 0
18
+ * 4. The value may not be "-0"
19
+ */
20
+ export declare const wellFormedNumberMatcher: RegExp;
21
+ export declare const isWellFormedNumber: RegExp["test"];
22
+ /**
23
+ * Similar to wellFormedNumber but more permissive in the following ways:
24
+ *
25
+ * - Allows numbers without an integer portion like ".5" (well-formed equivalent is "0.5")
26
+ * - Allows decimals with trailing zeroes like "0.10" (well-formed equivalent is "0.1")
27
+ * - Allows an exponent like "5.7e-10", as Number() does
28
+ */
29
+ export declare const numericStringMatcher: RegExp;
30
+ export declare const isDigitCode: (code: number) => boolean;
31
+ export declare const isNumericString: (s: string) => boolean;
32
+ export declare const numberLikeMatcher: RegExp;
33
+ /**
34
+ * Matches a well-formatted integer according to the following rules:
35
+ * 1. must begin with an integer, the first digit of which cannot be 0 unless the entire value is 0
36
+ * 2. The value may not be "-0"
37
+ */
38
+ export declare const wellFormedIntegerMatcher: RegExp;
39
+ export declare const isWellFormedInteger: (s: string) => boolean;
40
+ export declare const integerLikeMatcher: RegExp;
41
+ type NumericLiteralKind = "number" | "bigint" | "integer";
42
+ declare const numericLiteralDescriptions: {
43
+ readonly number: "a number";
44
+ readonly bigint: "a bigint";
45
+ readonly integer: "an integer";
46
+ };
47
+ type numericLiteralDescriptions = typeof numericLiteralDescriptions;
48
+ export type writeMalformedNumericLiteralMessage<def extends string, kind extends NumericLiteralKind> = `'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`;
49
+ export declare const writeMalformedNumericLiteralMessage: <def extends string, kind extends NumericLiteralKind>(def: def, kind: kind) => writeMalformedNumericLiteralMessage<def, kind>;
50
+ export declare const tryParseNumber: <errorOnFail extends boolean | string>(token: string, options?: NumericParseOptions<errorOnFail>) => errorOnFail extends true | string ? number : number | undefined;
51
+ export declare const tryParseWellFormedNumber: typeof tryParseNumber;
52
+ export type tryParseNumber<token extends string, messageOnFail extends string> = token extends `${infer n extends number}` ? number extends n ? writeMalformedNumericLiteralMessage<token, "number"> : n : messageOnFail;
53
+ export type parseNumber<token extends string> = token extends `${infer n extends number}` ? n : never;
54
+ export declare const tryParseInteger: <errorOnFail extends boolean | string>(token: string, options?: NumericParseOptions<errorOnFail>) => errorOnFail extends true | string ? number : number | undefined;
55
+ export type tryParseInteger<token extends string, messageOnFail extends string> = token extends `${infer b extends bigint}` ? bigint extends b ? writeMalformedNumericLiteralMessage<token, "integer"> : token extends `${infer n extends number}` ? n : never : messageOnFail;
56
+ export type parseInteger<token extends string> = token extends `${bigint}` ? token extends `${infer n extends number}` ? n : never : never;
57
+ export type parseNonNegativeInteger<token extends string> = token extends `-${string}` ? never : parseInteger<token>;
58
+ export type NumericParseOptions<errorOnFail extends boolean | string> = {
59
+ errorOnFail?: errorOnFail;
60
+ strict?: boolean;
61
+ };
62
+ export declare const tryParseWellFormedBigint: (def: string) => bigint | undefined;
63
+ /**
64
+ * Returns the next or previous representable floating-point number after the given input.
65
+ *
66
+ * @param {"+" | "-"} [direction="+"] - The direction to find the nearest float. "+" for the next float, "-" for the previous float.
67
+ * @throws {Error} If the input is not a finite number.
68
+ *
69
+ * @example
70
+ * console.log(nearestFloat(0)); // Smallest positive number
71
+ * console.log(nearestFloat(2)); // 2.0000000000000004
72
+ * console.log(nearestFloat(2.1)); // 2.1000000000000005
73
+ * console.log(nearestFloat(2, "-")); // 1.9999999999999998
74
+ * console.log(nearestFloat(2.1, "-")); // 2.0999999999999996
75
+ * // as size of input increases, the increments become larger to stay within what
76
+ * // JS can represent in a numeric value
77
+ * console.log(nearestFloat(5555555555555555)); // 5555555555555556
78
+ * console.log(nearestFloat(5555555555555555, "-")); // 5555555555555554
79
+ */
80
+ export declare const nearestFloat: (n: number, direction?: "+" | "-") => number;
81
+ export declare const printDecimal: (n: number) => string;
82
+ export {};
@@ -0,0 +1,157 @@
1
+ import type { DescribeOptions } from "./describe.ts";
2
+ import { type domainDescriptions, domainOf } from "./domain.ts";
3
+ import type { Fn } from "./functions.ts";
4
+ import type { anyOrNever, satisfy, show } from "./generics.ts";
5
+ declare const ecmascriptConstructorsOf: () => {
6
+ Array: ArrayConstructor;
7
+ Boolean: BooleanConstructor;
8
+ Date: DateConstructor;
9
+ Error: ErrorConstructor;
10
+ Function: FunctionConstructor;
11
+ Map: MapConstructor;
12
+ Number: NumberConstructor;
13
+ Promise: PromiseConstructor;
14
+ RegExp: RegExpConstructor;
15
+ Set: SetConstructor;
16
+ String: StringConstructor;
17
+ WeakMap: WeakMapConstructor;
18
+ WeakSet: WeakSetConstructor;
19
+ };
20
+ export declare const ecmascriptConstructors: ecmascriptConstructors;
21
+ export type ecmascriptConstructors = ReturnType<typeof ecmascriptConstructorsOf>;
22
+ export type EcmascriptObjects = satisfy<instantiateConstructors<keyof ecmascriptConstructors>, {
23
+ Array: Array<unknown>;
24
+ Boolean: Boolean;
25
+ Date: Date;
26
+ Error: Error;
27
+ Function: Function;
28
+ Map: Map<unknown, unknown>;
29
+ Number: Number;
30
+ RegExp: RegExp;
31
+ Set: Set<unknown>;
32
+ String: String;
33
+ WeakMap: WeakMap<object, unknown>;
34
+ WeakSet: WeakSet<object>;
35
+ Promise: Promise<unknown>;
36
+ }>;
37
+ /** Node18 */
38
+ export declare const FileConstructor: typeof File;
39
+ export type platformConstructors = {
40
+ ArrayBuffer: ArrayBufferConstructor;
41
+ Blob: typeof Blob;
42
+ File: typeof File;
43
+ FormData: typeof FormData;
44
+ Headers: typeof Headers;
45
+ Request: typeof Request;
46
+ Response: typeof Response;
47
+ URL: typeof URL;
48
+ };
49
+ export declare const platformConstructors: platformConstructors;
50
+ export type PlatformObjects = {
51
+ [k in keyof platformConstructors]: [platformConstructors[k]] extends ([
52
+ anyOrNever
53
+ ]) ? never : platformConstructors[k] extends {
54
+ prototype: infer instance;
55
+ } ? instance : never;
56
+ };
57
+ declare const typedArrayConstructorsOf: () => {
58
+ Int8Array: Int8ArrayConstructor;
59
+ Uint8Array: Uint8ArrayConstructor;
60
+ Uint8ClampedArray: Uint8ClampedArrayConstructor;
61
+ Int16Array: Int16ArrayConstructor;
62
+ Uint16Array: Uint16ArrayConstructor;
63
+ Int32Array: Int32ArrayConstructor;
64
+ Uint32Array: Uint32ArrayConstructor;
65
+ Float32Array: Float32ArrayConstructor;
66
+ Float64Array: Float64ArrayConstructor;
67
+ BigInt64Array: BigInt64ArrayConstructor;
68
+ BigUint64Array: BigUint64ArrayConstructor;
69
+ };
70
+ export declare const typedArrayConstructors: typedArrayConstructors;
71
+ export type typedArrayConstructors = ReturnType<typeof typedArrayConstructorsOf>;
72
+ export type TypedArrayObjects = instantiateConstructors<keyof typedArrayConstructors>;
73
+ export type builtinConstructors = ecmascriptConstructors & platformConstructors & typedArrayConstructors;
74
+ export declare const builtinConstructors: builtinConstructors;
75
+ export type BuiltinObjectKind = keyof builtinConstructors;
76
+ export type GlobalName = keyof typeof globalThis;
77
+ type instantiateConstructors<kind extends BuiltinObjectKind> = {
78
+ [k in kind]: [builtinConstructors[k]] extends [anyOrNever] ? never : InstanceType<builtinConstructors[k]>;
79
+ };
80
+ export type BuiltinObjects = instantiateConstructors<BuiltinObjectKind>;
81
+ export type objectKindOf<data extends object> = object extends data ? keyof builtinConstructors | undefined : data extends Fn ? "Function" : instantiableObjectKind<data> extends never ? undefined : instantiableObjectKind<data>;
82
+ export type describeObject<o extends object, opts extends DescribeOptions = {}> = objectKindOf<o> extends string ? [
83
+ opts["includeArticles"]
84
+ ] extends [true] ? objectKindDescriptions[objectKindOf<o>] : objectKindOf<o> : [opts["includeArticles"]] extends [true] ? domainDescriptions["object"] : "object";
85
+ type instantiableObjectKind<data extends object> = {
86
+ [kind in keyof builtinConstructors]: data extends (InstanceType<builtinConstructors[kind]>) ? kind : never;
87
+ }[keyof builtinConstructors];
88
+ export declare const objectKindOf: <data extends object>(data: data) => objectKindOf<data> | undefined;
89
+ export declare const objectKindOrDomainOf: <data>(data: data) => (objectKindOf<data & object> & {}) | domainOf<data>;
90
+ export type objectKindOrDomainOf<data> = data extends object ? objectKindOf<data> extends undefined ? "object" : objectKindOf<data> : domainOf<data>;
91
+ export declare const hasObjectKind: <kind extends keyof builtinConstructors>(data: object, kind: kind) => data is InstanceType<builtinConstructors[kind]>;
92
+ export declare const isArray: (data: unknown) => data is readonly unknown[];
93
+ export declare const dateGetTime: () => number;
94
+ export declare const timeOf: (date: Date) => number | undefined;
95
+ export declare const isValidDate: (date: Date) => boolean;
96
+ export declare const isDateObject: (value: object) => value is Date;
97
+ export declare const isRegExpObject: (value: object) => value is RegExp;
98
+ export declare const writeInvalidDateMessage: <source extends string>(source: source) => writeInvalidDateMessage<source>;
99
+ export type writeInvalidDateMessage<source extends string> = `Date literal '${source}' must be an ISO date like 2025-01-01, an ISO date-time with Z or an offset like 2025-01-01T12:00Z, or epoch milliseconds`;
100
+ export type DateParseResult<errorOnFail extends boolean | string = boolean | string> = Date | (errorOnFail extends true | string ? never : undefined);
101
+ export declare const tryParseDate: <errorOnFail extends boolean | string>(source: string, errorOnFail?: errorOnFail) => DateParseResult<errorOnFail>;
102
+ export declare const ecmascriptDescriptions: {
103
+ readonly Array: "an array";
104
+ readonly Function: "a function";
105
+ readonly Date: "a Date";
106
+ readonly RegExp: "a RegExp";
107
+ readonly Error: "an Error";
108
+ readonly Map: "a Map";
109
+ readonly Set: "a Set";
110
+ readonly String: "a String object";
111
+ readonly Number: "a Number object";
112
+ readonly Boolean: "a Boolean object";
113
+ readonly Promise: "a Promise";
114
+ readonly WeakMap: "a WeakMap";
115
+ readonly WeakSet: "a WeakSet";
116
+ };
117
+ export declare const platformDescriptions: {
118
+ ArrayBuffer: string;
119
+ Blob: string;
120
+ File: string;
121
+ FormData: string;
122
+ Headers: string;
123
+ Request: string;
124
+ Response: string;
125
+ URL: string;
126
+ };
127
+ export declare const typedArrayDescriptions: {
128
+ readonly Int8Array: "an Int8Array";
129
+ readonly Uint8Array: "a Uint8Array";
130
+ readonly Uint8ClampedArray: "a Uint8ClampedArray";
131
+ readonly Int16Array: "an Int16Array";
132
+ readonly Uint16Array: "a Uint16Array";
133
+ readonly Int32Array: "an Int32Array";
134
+ readonly Uint32Array: "a Uint32Array";
135
+ readonly Float32Array: "a Float32Array";
136
+ readonly Float64Array: "a Float64Array";
137
+ readonly BigInt64Array: "a BigInt64Array";
138
+ readonly BigUint64Array: "a BigUint64Array";
139
+ };
140
+ /** Each defaultObjectKind's completion for the phrase "must be _____" */
141
+ export declare const objectKindDescriptions: objectKindDescriptions;
142
+ export type objectKindDescriptions = Readonly<show<typeof ecmascriptDescriptions & typeof platformDescriptions & typeof typedArrayDescriptions>>;
143
+ /**
144
+ * this will only return an object kind if it's the root constructor
145
+ * example TypeError would return null not 'Error'
146
+ **/
147
+ export declare const getBuiltinNameOfConstructor: (ctor: Function) => BuiltinObjectKind | null;
148
+ export type Constructor<instance = {}> = abstract new (...args: never[]) => instance;
149
+ export type instanceOf<constructor> = constructor extends Constructor<infer instance> ? instance : never;
150
+ /**
151
+ * Returns an array of constructors for all ancestors (i.e., prototypes) of a given object.
152
+ */
153
+ export declare const ancestorsOf: (o: object) => Function[];
154
+ /** whether an object is an array, or has the prototype of a literal or none */
155
+ export declare const isPlainObjectOrArray: (o: object) => boolean;
156
+ export type normalizedKeyOf<t> = keyof t extends infer k ? k extends number ? `${k}` : k : never;
157
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { array } from "./arrays.ts";
2
+ import type { noInfer } from "./generics.ts";
3
+ import type { requireKeys } from "./records.ts";
4
+ export type StringifyPathOptions<stringifiable = PropertyKey> = requireKeys<{
5
+ stringifySymbol?: (s: symbol) => string;
6
+ stringifyNonKey?: (o: Exclude<stringifiable, PropertyKey>) => string;
7
+ }, stringifiable extends PropertyKey ? never : "stringifyNonKey">;
8
+ export type StringifyPathFn = <stringifiable>(path: array<stringifiable>, ...[opts]: [stringifiable] extends [PropertyKey] ? [
9
+ opts?: StringifyPathOptions
10
+ ] : noInfer<[opts: StringifyPathOptions<stringifiable>], stringifiable>) => string;
11
+ export type AppendStringifiedKeyFn = <stringifiable>(path: string, prop: stringifiable, ...[opts]: [stringifiable] extends [PropertyKey] ? [
12
+ opts?: StringifyPathOptions
13
+ ] : noInfer<[opts: StringifyPathOptions<stringifiable>], stringifiable>) => string;
14
+ export declare const appendStringifiedKey: AppendStringifiedKeyFn;
15
+ export declare const stringifyPath: StringifyPathFn;
16
+ export declare const pathAt: (path: PropertyKey[], key?: PropertyKey) => PropertyKey[];
@@ -0,0 +1,16 @@
1
+ import type { inferDomain } from "./domain.ts";
2
+ import type { BigintLiteral } from "./numbers.ts";
3
+ type SerializedString<value extends string = string> = `"${value}"`;
4
+ export type SerializedPrimitives = {
5
+ string: SerializedString;
6
+ number: `${number}`;
7
+ bigint: BigintLiteral;
8
+ boolean: "true" | "false";
9
+ null: "null";
10
+ undefined: "undefined";
11
+ };
12
+ export type SerializedPrimitive = SerializedPrimitives[keyof SerializedPrimitives];
13
+ export type SerializablePrimitive = inferDomain<keyof SerializedPrimitives>;
14
+ export declare const serializePrimitive: <value extends SerializablePrimitive>(value: value) => serializePrimitive<value>;
15
+ export type serializePrimitive<value extends SerializablePrimitive> = value extends string ? `"${value}"` : value extends bigint ? `${value}n` : `${value}`;
16
+ export {};
@@ -0,0 +1,173 @@
1
+ import type { array } from "./arrays.ts";
2
+ import type { Primitive } from "./domain.ts";
3
+ import type { Fn } from "./functions.ts";
4
+ import type { defined, show } from "./generics.ts";
5
+ import type { Key } from "./keys.ts";
6
+ import type { intersectUnion } from "./unionToTuple.ts";
7
+ export type Dict<k extends string = string, v = unknown> = {
8
+ readonly [_ in k]: v;
9
+ };
10
+ export type dict<v = unknown, k extends string = string> = {
11
+ [_ in k]: v;
12
+ };
13
+ /** Either:
14
+ * A, with all properties of B undefined
15
+ * OR
16
+ * B, with all properties of A undefined
17
+ **/
18
+ export type propwiseXor<a, b> = show<a & {
19
+ [k in keyof b]?: undefined;
20
+ }> | show<b & {
21
+ [k in keyof a]?: undefined;
22
+ }>;
23
+ export type unionToPropwiseXor<props extends object, branchKey extends PropertyKey = keyof intersectUnion<props>> = props extends infer distributed ? show<distributed & {
24
+ [k in branchKey]?: k extends keyof distributed ? unknown : undefined;
25
+ }> : never;
26
+ export type requireKeys<o, key extends keyof o> = o & {
27
+ [requiredKey in key]-?: defined<o[requiredKey]>;
28
+ };
29
+ export type require<o, maxDepth extends number = 1> = _require<o, [], maxDepth>;
30
+ type _require<o, depth extends 1[], maxDepth extends number> = depth["length"] extends maxDepth ? o : o extends object ? o extends Fn ? o : {
31
+ [k in keyof o]-?: _require<o[k], [...depth, 1], maxDepth>;
32
+ } : o;
33
+ export type PartialRecord<k extends PropertyKey = PropertyKey, v = unknown> = {
34
+ [_ in k]?: v;
35
+ };
36
+ /** Returns true if a type can be homomorphically mapped without losing information.
37
+ * Useful for avoiding e.g. classes with private properties while mapping.
38
+ */
39
+ export type isSafelyMappable<t> = {
40
+ [k in keyof t]: t[k];
41
+ } extends t ? true : false;
42
+ export type KeySet<key extends string = string> = {
43
+ readonly [_ in key]?: 1;
44
+ };
45
+ export type keySetOf<o extends object> = KeySet<Extract<keyof o, string>>;
46
+ export type mutable<o, maxDepth extends number = 1> = _mutable<o, [], maxDepth>;
47
+ type _mutable<o, depth extends 1[], maxDepth extends number> = depth["length"] extends maxDepth ? o : o extends Primitive ? o : o extends Fn ? o : {
48
+ -readonly [k in keyof o]: _mutable<o[k], [...depth, 1], maxDepth>;
49
+ };
50
+ /**
51
+ * extracts entries mimicking Object.entries, accounting for whether the
52
+ * object is an array
53
+ **/
54
+ export type entryOf<o> = {
55
+ [k in keyof o]-?: [k, o[k] & ({} | null)];
56
+ }[o extends readonly unknown[] ? keyof o & number : keyof o] & unknown;
57
+ export type entriesOf<o extends object> = entryOf<o>[];
58
+ /**
59
+ * Object.entries wrapper providing narrowed types for objects with known sets
60
+ * of keys, e.g. those defined internally as configs
61
+ */
62
+ export declare const entriesOf: <o extends object>(o: o) => entryOf<o>[];
63
+ export type Entry<key extends PropertyKey = PropertyKey, value = unknown> = readonly [key: key, value: value];
64
+ export type fromEntries<entries extends readonly Entry[]> = show<{
65
+ [entry in entries[number] as entry[0]]: entry[1];
66
+ }>;
67
+ export declare const fromEntries: <const entries extends readonly Entry[]>(entries: entries) => fromEntries<entries>;
68
+ /** Mimics the result of Object.keys(...) */
69
+ export type keyOf<o> = o extends array ? number extends o["length"] ? `${number}` : keyof o & `${number}` : keyof o extends infer k ? k extends string ? k : k extends number ? `${k}` : never : never;
70
+ export declare const keysOf: <o extends object>(o: o) => keyOf<o>[];
71
+ export declare const isKeyOf: <k extends string | number | symbol, o extends object>(k: k, o: o) => k is Extract<keyof o, k>;
72
+ /** Coalesce keys that exist on one or more branches of a union */
73
+ export type unionKeyOf<t> = t extends unknown ? keyof t : never;
74
+ export type extractKeyed<o extends object, k extends unionKeyOf<o>> = Extract<o, {
75
+ [_ in k]?: unknown;
76
+ }>;
77
+ export declare const hasOwn: (o: object, k: PropertyKey) => boolean;
78
+ export declare const hasKey: <o extends object, k extends unionKeyOf<o>>(o: o, k: k) => o is extractKeyed<o, k>;
79
+ export type extractDefinedKey<o extends object, k extends unionKeyOf<o>> = show<extractKeyed<o, k> & {
80
+ [_ in k]: {} | null;
81
+ }>;
82
+ export declare const hasDefinedKey: <o extends object, k extends unionKeyOf<o>>(o: o, k: k) => o is extractDefinedKey<o, k>;
83
+ export type requiredKeyOf<o> = keyof o extends infer k ? k extends keyof o ? o extends {
84
+ [_ in k]-?: o[k];
85
+ } ? k : never : never : never;
86
+ export type optionalKeyOf<o> = Exclude<keyof o, requiredKeyOf<o>>;
87
+ export type merge<base, props> = base extends unknown ? props extends unknown ? keyof base & keyof props extends never ? show<base & props> : show<omit<base, keyof props & keyof base> & props> : never : never;
88
+ export type override<base, merged extends {
89
+ [k in keyof base]?: unknown;
90
+ }> = merge<base, merged>;
91
+ export type propValueOf<o> = o[keyof o];
92
+ export declare const InnerDynamicBase: new <t extends object>(base: t) => t;
93
+ /** @ts-ignore (needed to extend `t`) **/
94
+ export interface DynamicBase<out t extends object> extends t {
95
+ }
96
+ export declare class DynamicBase<t extends object> {
97
+ constructor(properties: t);
98
+ }
99
+ export declare const NoopBase: new <t extends object>() => t;
100
+ /** @ts-ignore (needed to extend `t`) **/
101
+ export declare class CastableBase<t extends object> extends NoopBase<t> {
102
+ private " covariant"?;
103
+ }
104
+ export declare const splitByKeys: <o extends object, leftKeys extends keySetOf<o>>(o: o, leftKeys: leftKeys) => [show<Pick<o, keyof leftKeys & keyof o>>, show<Omit<o, keyof leftKeys & keyof o>>];
105
+ /** Homomorphic implementation of the builtin Pick.
106
+ *
107
+ * Gives different results for certain union expressions like the following:
108
+ *
109
+ * @example
110
+ * // flattens result to { a?: 1 | 2; b?: 1 | 2 }
111
+ * type PickResult = Pick<{ a: 1; b?: 1 } | { a?: 2; b: 2 }, "a" | "b">
112
+ *
113
+ * @example
114
+ * // preserves original type w/ modifier groupings
115
+ * type pickResult = pick<{ a: 1; b?: 1 } | { a?: 2; b: 2 }, "a" | "b">
116
+ */
117
+ export type pick<o, key extends keyof o> = o extends unknown ? {
118
+ [k in keyof o as k extends key ? k : never]: o[k];
119
+ } : never;
120
+ export declare const pick: <o extends object, keys extends keySetOf<o>>(o: o, keys: keys) => pick<o, keyof keys & keyof o>;
121
+ /** Homomorphic implementation of the builtin Omit.
122
+ *
123
+ * Gives different results for many union expressions like the following:
124
+ *
125
+ * @example
126
+ * // {}
127
+ * type OmitResult = Omit<{ a: 1 } | { b: 2 }, never>
128
+ *
129
+ * @example
130
+ * // preserves original type w/ modifier groupings
131
+ * type omitResult = omit<{ a: 1 } | { b: 2 }, never>
132
+ */
133
+ export type omit<o, key extends keyof o> = {
134
+ [k in keyof o as k extends key ? never : k]: o[k];
135
+ };
136
+ export declare const omit: <o extends object, keys extends keySetOf<o>>(o: o, keys: keys) => omit<o, keyof keys & keyof o>;
137
+ /** Returns onTrue if the type is exactly `{}` and onFalse otherwise*/
138
+ export type ifEmptyObjectLiteral<t, onTrue = true, onFalse = false> = [
139
+ unknown,
140
+ t & (null | undefined)
141
+ ] extends [t | null | undefined, never] ? onTrue : onFalse;
142
+ export type EmptyObject = Record<PropertyKey, never>;
143
+ export declare const isEmptyObject: (o: object) => o is EmptyObject;
144
+ export declare const stringAndSymbolicEntriesOf: (o: object) => Entry<Key>[];
145
+ /** Like Object.assign, but it will preserve getters instead of evaluating them. */
146
+ export declare const defineProperties: <base extends object, merged extends object>(base: base, merged: merged) => merge<base, merged>;
147
+ export declare const defineValue: (o: object, k: PropertyKey, value: unknown) => object;
148
+ /** Copies enumerable keys of o to a new object in alphabetical order */
149
+ export declare const withAlphabetizedKeys: <o extends object>(o: o) => o;
150
+ export type invert<t extends Record<PropertyKey, PropertyKey>> = {
151
+ [k in t[keyof t]]: {
152
+ [k2 in keyof t]: t[k2] extends k ? k2 : never;
153
+ }[keyof t];
154
+ } & unknown;
155
+ export declare const invert: <t extends Record<PropertyKey, PropertyKey>>(t: t) => invert<t>;
156
+ export declare const unset: " unset​";
157
+ export type unset = typeof unset;
158
+ /**
159
+ * For each keyof o that also exists on jsDocSource, add associated JsDoc annotations to o.
160
+ * Does not preserve modifiers on o like optionality.
161
+ */
162
+ export type withJsDoc<o, jsDocSource> = show<keyof o extends keyof jsDocSource ? keyof jsDocSource extends keyof o ? _withJsDoc<o, jsDocSource> : Pick<_withJsDoc<o, jsDocSource>, keyof o & keyof jsDocSource> : Pick<_withJsDoc<o, jsDocSource>, keyof o & keyof jsDocSource> & {
163
+ [k in Exclude<keyof o, keyof jsDocSource>]: o[k];
164
+ }>;
165
+ type _withJsDoc<o, jsDocSource> = {
166
+ [k in keyof jsDocSource]-?: o[k & keyof o];
167
+ };
168
+ export type propertyDescriptorsOf<o extends object> = {
169
+ [k in keyof o]: TypedPropertyDescriptor<o[k]>;
170
+ };
171
+ export type keyWithValue<t, constraint> = keyof t extends infer k ? k extends keyof t ? t[k] extends constraint ? k : never : never : never;
172
+ export declare const enumValues: <tsEnum extends object>(tsEnum: tsEnum) => tsEnum[keyof tsEnum][];
173
+ export {};
@@ -0,0 +1,13 @@
1
+ export declare const arkUtilVersion = "3.0.0-rc.0";
2
+ export declare const initialRegistryContents: {
3
+ version: string;
4
+ FileConstructor: typeof File;
5
+ };
6
+ export type InitialRegistryContents = typeof initialRegistryContents;
7
+ export interface ArkRegistry extends InitialRegistryContents {
8
+ [k: string]: unknown;
9
+ }
10
+ export declare const registry: ArkRegistry;
11
+ export declare const register: (value: object | symbol) => string;
12
+ export declare const registeredNameOf: (value: object | symbol) => string | undefined;
13
+ export declare const nameOf: (value: object | symbol) => string;
@@ -0,0 +1,110 @@
1
+ import type { KeySet } from "./records.ts";
2
+ import { Backslash, type WhitespaceChar } from "./strings.ts";
3
+ declare const namedControlEscapes: {
4
+ readonly b: "\b";
5
+ readonly f: "\f";
6
+ readonly n: "\n";
7
+ readonly r: "\r";
8
+ readonly t: "\t";
9
+ };
10
+ type NamedControlEscapes = typeof namedControlEscapes;
11
+ declare const controlEscapes: {
12
+ readonly "0000": "\0";
13
+ readonly "0001": "\u0001";
14
+ readonly "0002": "\u0002";
15
+ readonly "0003": "\u0003";
16
+ readonly "0004": "\u0004";
17
+ readonly "0005": "\u0005";
18
+ readonly "0006": "\u0006";
19
+ readonly "0007": "\u0007";
20
+ readonly "0008": "\b";
21
+ readonly "0009": "\t";
22
+ readonly "000a": "\n";
23
+ readonly "000b": "\v";
24
+ readonly "000c": "\f";
25
+ readonly "000d": "\r";
26
+ readonly "000e": "\u000E";
27
+ readonly "000f": "\u000F";
28
+ readonly "0010": "\u0010";
29
+ readonly "0011": "\u0011";
30
+ readonly "0012": "\u0012";
31
+ readonly "0013": "\u0013";
32
+ readonly "0014": "\u0014";
33
+ readonly "0015": "\u0015";
34
+ readonly "0016": "\u0016";
35
+ readonly "0017": "\u0017";
36
+ readonly "0018": "\u0018";
37
+ readonly "0019": "\u0019";
38
+ readonly "001a": "\u001A";
39
+ readonly "001b": "\u001B";
40
+ readonly "001c": "\u001C";
41
+ readonly "001d": "\u001D";
42
+ readonly "001e": "\u001E";
43
+ readonly "001f": "\u001F";
44
+ };
45
+ type ControlEscapes = typeof controlEscapes;
46
+ export declare class Scanner<peek extends string = string> {
47
+ chars: string[];
48
+ i: number;
49
+ def: string;
50
+ constructor(def: string);
51
+ /** the next character, advancing past it */
52
+ shift(): this["peek"];
53
+ /** the next character, or "" at the end */
54
+ get peek(): peek;
55
+ /** the character after the next, or "" past the end */
56
+ get peekNext(): string;
57
+ get length(): number;
58
+ shiftUntil(condition: Scanner.UntilCondition): string;
59
+ /**
60
+ * shifts until condition holds, reading `\` before the terminator as the
61
+ * terminator and `\\` as escapeEscape followed by a backslash. Where
62
+ * escapeEscape is "", as in a literal, the escapes JSON writes for a
63
+ * control character are read as that character, so a literal's expression
64
+ * parses back to it
65
+ */
66
+ shiftUntilEscapable(condition: Scanner.UntilCondition, escapeEscape?: typeof Backslash | ""): string;
67
+ /** the control character escaped after a backslash, or the backslash as written */
68
+ private shiftControlEscape;
69
+ shiftUntilNext(charOrSet: string | KeySet): string;
70
+ /** shifts past whitespace, returning what it shifted */
71
+ skipSpace(): string;
72
+ jumpForward(count: number): void;
73
+ get location(): number;
74
+ get unscanned(): string;
75
+ get scanned(): string;
76
+ sliceChars(start: number, end?: number): string;
77
+ peekIs<char extends peek>(char: char): this is Scanner<char>;
78
+ peekIsIn<keySet extends KeySet>(tokens: keySet): this is Scanner<Extract<keyof keySet, string>>;
79
+ }
80
+ export declare namespace Scanner {
81
+ type UntilCondition = (sc: Scanner, shifted: string) => boolean;
82
+ type shift<peek extends string, unscanned extends string> = `${peek}${unscanned}`;
83
+ type shiftUntil<unscanned extends string, terminator extends string, appendTo extends string = ""> = unscanned extends `${infer first}${infer second}${infer rest}` ? first extends terminator ? [appendTo, unscanned] : second extends terminator ? [`${appendTo}${first}`, `${second}${rest}`] : shiftUntil<rest, terminator, `${appendTo}${first}${second}`> : unscanned extends terminator ? [appendTo, unscanned] : [`${appendTo}${unscanned}`, ""];
84
+ type shiftUntilEscapable<unscanned extends string, terminator extends string, escapeEscape extends Backslash | "", appendTo extends string = ""> = unscanned extends `${infer head}${Backslash}${infer escaped}` ? head extends `${infer scanned}${terminator}${infer rest}` ? [
85
+ `${appendTo}${scanned}`,
86
+ `${terminator}${rest}${Backslash}${escaped}`
87
+ ] : escaped extends shift<infer peek, infer nextUnscanned> ? peek extends terminator ? shiftUntilEscapable<nextUnscanned, terminator, escapeEscape, `${appendTo}${head}${peek}`> : peek extends Backslash ? shiftUntilEscapable<nextUnscanned, terminator, escapeEscape, `${appendTo}${head}${escapeEscape}${peek}`> : escapeEscape extends "" ? shiftControlEscape<escaped> extends ([
88
+ infer char extends string,
89
+ infer rest extends string
90
+ ]) ? shiftUntilEscapable<rest, terminator, escapeEscape, `${appendTo}${head}${char}`> : never : shiftUntilEscapable<nextUnscanned, terminator, escapeEscape, `${appendTo}${head}${Backslash}${peek}`> : [`${appendTo}${head}${Backslash}`, ""] : unscanned extends `${infer scanned}${terminator}${infer rest}` ? [
91
+ `${appendTo}${scanned}`,
92
+ `${terminator}${rest}`
93
+ ] : [`${appendTo}${unscanned}`, ""];
94
+ /** the control character escaped after a backslash, or the backslash as written */
95
+ type shiftControlEscape<escaped extends string> = escaped extends shift<infer peek, infer rest> ? peek extends keyof NamedControlEscapes ? [NamedControlEscapes[peek], rest] : escaped extends (`u${infer h1}${infer h2}${infer h3}${infer h4}${infer afterCode}`) ? Lowercase<`${h1}${h2}${h3}${h4}`> extends (infer code extends keyof ControlEscapes) ? [
96
+ ControlEscapes[code],
97
+ afterCode
98
+ ] : [`${Backslash}${peek}`, rest] : [`${Backslash}${peek}`, rest] : never;
99
+ type shiftUntilNot<unscanned extends string, nonTerminator extends string, appendTo extends string = ""> = unscanned extends shift<infer peek, infer nextUnscanned> ? peek extends nonTerminator ? shiftUntilNot<nextUnscanned, nonTerminator, `${appendTo}${peek}`> : [appendTo, unscanned] : [appendTo, ""];
100
+ type skipWhitespace<unscanned extends string> = shiftUntilNot<unscanned, WhitespaceChar>[1];
101
+ type shiftResult<scanned extends string, unscanned extends string> = [
102
+ scanned,
103
+ unscanned
104
+ ];
105
+ }
106
+ export declare const writeUnmatchedGroupCloseMessage: <char extends string, unscanned extends string>(char: char, unscanned: unscanned) => writeUnmatchedGroupCloseMessage<char, unscanned>;
107
+ export type writeUnmatchedGroupCloseMessage<char extends string, unscanned extends string> = `Unmatched ${char}${unscanned extends "" ? "" : ` before ${unscanned}`}`;
108
+ export declare const writeUnclosedGroupMessage: <missingChar extends string>(missingChar: missingChar) => writeUnclosedGroupMessage<missingChar>;
109
+ export type writeUnclosedGroupMessage<missingChar extends string> = `Missing ${missingChar}`;
110
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { array } from "./arrays.ts";
2
+ import { type Primitive } from "./domain.ts";
3
+ export type SerializationOptions = {
4
+ onCycle?: (value: object) => string;
5
+ onSymbol?: (value: symbol) => string;
6
+ onFunction?: (value: Function) => string;
7
+ onUndefined?: string;
8
+ onBigInt?: (value: bigint) => string;
9
+ onAccessor?: (descriptor: PropertyDescriptor) => string;
10
+ };
11
+ export type JsonStructure = JsonObject | JsonArray;
12
+ export interface JsonObject {
13
+ [k: string]: Json;
14
+ }
15
+ export type JsonArray = Json[];
16
+ export type JsonPrimitive = string | boolean | number | null;
17
+ export type Json = JsonStructure | JsonPrimitive;
18
+ export declare const snapshot: <t>(data: t, opts?: SerializationOptions) => snapshot<t>;
19
+ export type snapshot<t, depth extends 1[] = []> = unknown extends t ? unknown : t extends Primitive ? snapshotPrimitive<t> : t extends {
20
+ toJSON: () => infer serialized;
21
+ } ? serialized : t extends Function ? `Function(${string})` : t extends Date ? string : depth["length"] extends 10 ? unknown : t extends array<infer item> ? array<snapshot<item, [...depth, 1]>> : {
22
+ [k in keyof t as snapshotPrimitive<k>]: snapshot<t[k], [...depth, 1]>;
23
+ };
24
+ type snapshotPrimitive<t> = t extends symbol ? `Symbol(${string})` : t;
25
+ export type PrintableOptions = {
26
+ indent?: number;
27
+ quoteKeys?: boolean;
28
+ ownDataOnly?: boolean;
29
+ };
30
+ export declare const print: (data: unknown, opts?: PrintableOptions) => void;
31
+ export declare const printable: (data: unknown, opts?: PrintableOptions) => string;
32
+ export declare const printKind: (data: unknown) => string;
33
+ export declare const printSymbol: (symbol: symbol) => string;
34
+ /**
35
+ * Converts a Date instance to a human-readable description relative to its precision
36
+ */
37
+ export declare const describeCollapsibleDate: (date: Date) => string;
38
+ export declare const isDotAccessible: (keyName: string) => boolean;
39
+ export declare const baseNameOf: (value: object | symbol) => string;
40
+ export {};