arktype 2.0.0-dev.5 → 2.0.0-dev.6

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 (376) hide show
  1. package/__tests__/array.test.ts +70 -38
  2. package/__tests__/badDefinitionType.test.ts +9 -2
  3. package/__tests__/basis.test.ts +6 -2
  4. package/__tests__/bounds.test.ts +49 -218
  5. package/__tests__/cast.test.ts +7 -2
  6. package/__tests__/completions.test.ts +8 -3
  7. package/__tests__/config.test.ts +8 -2
  8. package/__tests__/cyclic.test.ts +141 -137
  9. package/__tests__/dateLiteral.test.ts +6 -2
  10. package/__tests__/declared.test.ts +2 -2
  11. package/__tests__/divisor.test.ts +28 -12
  12. package/__tests__/enclosed.test.ts +32 -23
  13. package/__tests__/examples.test.ts +56 -56
  14. package/__tests__/expressions.test.ts +184 -106
  15. package/__tests__/generic.test.ts +307 -287
  16. package/__tests__/group.test.ts +59 -51
  17. package/__tests__/imports.test.ts +44 -37
  18. package/__tests__/instanceof.test.ts +14 -12
  19. package/__tests__/intersection.test.ts +16 -36
  20. package/__tests__/keyTraversal.test.ts +6 -1
  21. package/__tests__/keyof.test.ts +57 -43
  22. package/__tests__/keywords.test.ts +144 -135
  23. package/__tests__/literal.test.ts +12 -7
  24. package/__tests__/match.test.ts +234 -236
  25. package/__tests__/morph.test.ts +169 -153
  26. package/__tests__/narrow.test.ts +14 -9
  27. package/__tests__/objectLiteral.test.ts +172 -184
  28. package/__tests__/realWorld.test.ts +60 -59
  29. package/__tests__/regex.test.ts +17 -7
  30. package/__tests__/scope.test.ts +59 -14
  31. package/__tests__/serialization.test.ts +19 -0
  32. package/__tests__/string.test.ts +11 -7
  33. package/__tests__/submodule.test.ts +24 -37
  34. package/__tests__/this.test.ts +83 -57
  35. package/__tests__/thunk.test.ts +13 -7
  36. package/__tests__/traverse.test.ts +22 -12
  37. package/__tests__/tsGenerics.test.ts +12 -12
  38. package/__tests__/type.test.ts +38 -0
  39. package/__tests__/typeReference.test.ts +5 -5
  40. package/__tests__/unenclosed.test.ts +106 -96
  41. package/__tests__/union.test.ts +207 -212
  42. package/ark.ts +44 -0
  43. package/generic.ts +67 -0
  44. package/main.ts +6 -17
  45. package/match.ts +41 -51
  46. package/module.ts +15 -0
  47. package/out/ark.d.ts +12 -40
  48. package/out/ark.d.ts.map +1 -1
  49. package/out/ark.js +9 -20
  50. package/out/ark.js.map +1 -1
  51. package/out/base.d.ts +198 -122
  52. package/out/base.d.ts.map +1 -1
  53. package/out/base.js +317 -271
  54. package/out/base.js.map +1 -1
  55. package/out/builtins/builtins.d.ts +21 -17
  56. package/out/builtins/builtins.js +15 -12
  57. package/out/builtins/jsObjects.d.ts +17 -17
  58. package/out/builtins/jsObjects.js +18 -15
  59. package/out/builtins/parsing.d.ts +13 -13
  60. package/out/builtins/parsing.js +57 -54
  61. package/out/builtins/tsGenerics.d.ts +2 -2
  62. package/out/builtins/tsGenerics.js +2 -2
  63. package/out/builtins/tsKeywords.d.ts +21 -21
  64. package/out/builtins/tsKeywords.js +23 -20
  65. package/out/builtins/utils/creditCard.d.ts +3 -3
  66. package/out/builtins/utils/creditCard.js +31 -32
  67. package/out/builtins/utils/date.d.ts +39 -20
  68. package/out/builtins/utils/date.js +51 -48
  69. package/out/builtins/validation.d.ts +17 -17
  70. package/out/builtins/validation.js +66 -62
  71. package/out/config.d.ts +9 -6
  72. package/out/config.js +17 -16
  73. package/out/constraints/ast.d.ts +263 -152
  74. package/out/constraints/ast.js +2 -2
  75. package/out/constraints/constraint.d.ts +196 -66
  76. package/out/constraints/constraint.js +21 -17
  77. package/out/constraints/predicate.d.ts +60 -42
  78. package/out/constraints/predicate.js +48 -43
  79. package/out/constraints/props/index.d.ts +35 -29
  80. package/out/constraints/props/index.js +54 -46
  81. package/out/constraints/props/optional.d.ts +31 -28
  82. package/out/constraints/props/optional.js +54 -53
  83. package/out/constraints/props/prop.d.ts +42 -39
  84. package/out/constraints/props/prop.js +104 -102
  85. package/out/constraints/props/props.d.ts +35 -32
  86. package/out/constraints/props/props.js +117 -102
  87. package/out/constraints/props/props.js.map +1 -1
  88. package/out/constraints/props/required.d.ts +40 -37
  89. package/out/constraints/props/required.js +78 -73
  90. package/out/constraints/props/sequence.d.ts +74 -56
  91. package/out/constraints/props/sequence.js +371 -322
  92. package/out/constraints/props/shared.d.ts +3 -3
  93. package/out/constraints/props/shared.js +4 -4
  94. package/out/constraints/refinements/after.d.ts +26 -18
  95. package/out/constraints/refinements/after.js +34 -33
  96. package/out/constraints/refinements/before.d.ts +26 -18
  97. package/out/constraints/refinements/before.js +41 -39
  98. package/out/constraints/refinements/divisor.d.ts +47 -37
  99. package/out/constraints/refinements/divisor.js +48 -37
  100. package/out/constraints/refinements/exactLength.d.ts +40 -36
  101. package/out/constraints/refinements/exactLength.js +50 -42
  102. package/out/constraints/refinements/kinds.d.ts +25 -25
  103. package/out/constraints/refinements/kinds.js +16 -16
  104. package/out/constraints/refinements/length.d.ts +45 -39
  105. package/out/constraints/refinements/length.js +51 -43
  106. package/out/constraints/refinements/max.d.ts +24 -17
  107. package/out/constraints/refinements/max.js +33 -29
  108. package/out/constraints/refinements/maxLength.d.ts +25 -17
  109. package/out/constraints/refinements/maxLength.js +34 -32
  110. package/out/constraints/refinements/min.d.ts +24 -17
  111. package/out/constraints/refinements/min.js +26 -23
  112. package/out/constraints/refinements/minLength.d.ts +25 -17
  113. package/out/constraints/refinements/minLength.js +31 -30
  114. package/out/constraints/refinements/range.d.ts +107 -78
  115. package/out/constraints/refinements/range.js +83 -66
  116. package/out/constraints/refinements/regex.d.ts +42 -38
  117. package/out/constraints/refinements/regex.js +35 -34
  118. package/out/constraints/refinements/shared.d.ts +20 -5
  119. package/out/constraints/refinements/shared.js +9 -9
  120. package/out/generic.d.ts +22 -0
  121. package/out/generic.d.ts.map +1 -0
  122. package/out/generic.js +23 -0
  123. package/out/generic.js.map +1 -0
  124. package/out/inference.d.ts +132 -35
  125. package/out/inference.js +2 -2
  126. package/out/keywords/ark.d.ts +60 -50
  127. package/out/keywords/ark.js +25 -25
  128. package/out/keywords/internal.d.ts +11 -11
  129. package/out/keywords/internal.js +13 -10
  130. package/out/keywords/jsObject.d.ts +18 -18
  131. package/out/keywords/jsObject.js +18 -15
  132. package/out/keywords/parsing.d.ts +14 -14
  133. package/out/keywords/parsing.js +53 -50
  134. package/out/keywords/root.d.ts +6 -6
  135. package/out/keywords/root.js +4 -4
  136. package/out/keywords/tsGenerics.d.ts +2 -2
  137. package/out/keywords/tsGenerics.js +2 -2
  138. package/out/keywords/tsPrimitive.d.ts +22 -22
  139. package/out/keywords/tsPrimitive.js +25 -22
  140. package/out/keywords/utils/creditCard.d.ts +11 -8
  141. package/out/keywords/utils/creditCard.js +31 -32
  142. package/out/keywords/utils/date.d.ts +43 -23
  143. package/out/keywords/utils/date.js +51 -48
  144. package/out/keywords/validation.d.ts +18 -18
  145. package/out/keywords/validation.js +67 -63
  146. package/out/kinds.d.ts +97 -67
  147. package/out/kinds.js +28 -28
  148. package/out/main.d.ts +6 -7
  149. package/out/main.d.ts.map +1 -1
  150. package/out/main.js +4 -2
  151. package/out/main.js.map +1 -1
  152. package/out/match.d.ts +6 -10
  153. package/out/match.d.ts.map +1 -1
  154. package/out/match.js +1 -1
  155. package/out/match.js.map +1 -1
  156. package/out/module.d.ts +11 -0
  157. package/out/module.d.ts.map +1 -0
  158. package/out/module.js +4 -0
  159. package/out/module.js.map +1 -0
  160. package/out/parse.d.ts +28 -22
  161. package/out/parse.js +157 -144
  162. package/out/parser/definition.d.ts +8 -10
  163. package/out/parser/definition.d.ts.map +1 -1
  164. package/out/parser/definition.js +5 -6
  165. package/out/parser/definition.js.map +1 -1
  166. package/out/parser/generic.d.ts +3 -4
  167. package/out/parser/generic.d.ts.map +1 -1
  168. package/out/parser/generic.js +6 -8
  169. package/out/parser/generic.js.map +1 -1
  170. package/out/parser/objectLiteral.d.ts +5 -6
  171. package/out/parser/objectLiteral.d.ts.map +1 -1
  172. package/out/parser/objectLiteral.js +10 -15
  173. package/out/parser/objectLiteral.js.map +1 -1
  174. package/out/parser/semantic/bounds.d.ts +4 -3
  175. package/out/parser/semantic/bounds.d.ts.map +1 -1
  176. package/out/parser/semantic/bounds.js.map +1 -1
  177. package/out/parser/semantic/divisor.d.ts +4 -3
  178. package/out/parser/semantic/divisor.d.ts.map +1 -1
  179. package/out/parser/semantic/infer.d.ts +7 -10
  180. package/out/parser/semantic/infer.d.ts.map +1 -1
  181. package/out/parser/semantic/utils.d.ts.map +1 -1
  182. package/out/parser/semantic/validate.d.ts +13 -11
  183. package/out/parser/semantic/validate.d.ts.map +1 -1
  184. package/out/parser/semantic/validate.js +1 -0
  185. package/out/parser/semantic/validate.js.map +1 -1
  186. package/out/parser/string/reduce/dynamic.d.ts +7 -8
  187. package/out/parser/string/reduce/dynamic.d.ts.map +1 -1
  188. package/out/parser/string/reduce/dynamic.js +26 -22
  189. package/out/parser/string/reduce/dynamic.js.map +1 -1
  190. package/out/parser/string/reduce/shared.d.ts +2 -2
  191. package/out/parser/string/reduce/shared.d.ts.map +1 -1
  192. package/out/parser/string/reduce/static.d.ts +8 -5
  193. package/out/parser/string/reduce/static.d.ts.map +1 -1
  194. package/out/parser/string/shift/operand/date.d.ts +1 -1
  195. package/out/parser/string/shift/operand/date.d.ts.map +1 -1
  196. package/out/parser/string/shift/operand/date.js +2 -2
  197. package/out/parser/string/shift/operand/date.js.map +1 -1
  198. package/out/parser/string/shift/operand/enclosed.d.ts +1 -1
  199. package/out/parser/string/shift/operand/enclosed.d.ts.map +1 -1
  200. package/out/parser/string/shift/operand/enclosed.js +1 -1
  201. package/out/parser/string/shift/operand/enclosed.js.map +1 -1
  202. package/out/parser/string/shift/operand/genericArgs.d.ts +8 -8
  203. package/out/parser/string/shift/operand/genericArgs.d.ts.map +1 -1
  204. package/out/parser/string/shift/operand/genericArgs.js +6 -8
  205. package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
  206. package/out/parser/string/shift/operand/operand.d.ts +3 -3
  207. package/out/parser/string/shift/operand/operand.d.ts.map +1 -1
  208. package/out/parser/string/shift/operand/operand.js +8 -11
  209. package/out/parser/string/shift/operand/operand.js.map +1 -1
  210. package/out/parser/string/shift/operand/unenclosed.d.ts +10 -16
  211. package/out/parser/string/shift/operand/unenclosed.d.ts.map +1 -1
  212. package/out/parser/string/shift/operand/unenclosed.js +19 -24
  213. package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
  214. package/out/parser/string/shift/operator/bounds.d.ts +6 -8
  215. package/out/parser/string/shift/operator/bounds.d.ts.map +1 -1
  216. package/out/parser/string/shift/operator/bounds.js +20 -29
  217. package/out/parser/string/shift/operator/bounds.js.map +1 -1
  218. package/out/parser/string/shift/operator/divisor.d.ts +1 -2
  219. package/out/parser/string/shift/operator/divisor.d.ts.map +1 -1
  220. package/out/parser/string/shift/operator/divisor.js.map +1 -1
  221. package/out/parser/string/shift/operator/operator.d.ts +1 -1
  222. package/out/parser/string/shift/operator/operator.d.ts.map +1 -1
  223. package/out/parser/string/shift/operator/operator.js +12 -18
  224. package/out/parser/string/shift/operator/operator.js.map +1 -1
  225. package/out/parser/string/shift/scanner.d.ts +2 -1
  226. package/out/parser/string/shift/scanner.d.ts.map +1 -1
  227. package/out/parser/string/shift/scanner.js +12 -11
  228. package/out/parser/string/shift/scanner.js.map +1 -1
  229. package/out/parser/string/string.d.ts +7 -4
  230. package/out/parser/string/string.d.ts.map +1 -1
  231. package/out/parser/string/string.js.map +1 -1
  232. package/out/parser/tuple.d.ts +27 -30
  233. package/out/parser/tuple.d.ts.map +1 -1
  234. package/out/parser/tuple.js +33 -35
  235. package/out/parser/tuple.js.map +1 -1
  236. package/out/schema.d.ts +171 -40
  237. package/out/schema.js +2 -2
  238. package/out/schemaScope.d.ts +170 -100
  239. package/out/schemaScope.js +231 -208
  240. package/out/scope.d.ts +43 -187
  241. package/out/scope.d.ts.map +1 -1
  242. package/out/scope.js +56 -326
  243. package/out/scope.js.map +1 -1
  244. package/out/shared/compile.d.ts +19 -19
  245. package/out/shared/compile.js +77 -65
  246. package/out/shared/context.d.ts +51 -26
  247. package/out/shared/context.js +50 -45
  248. package/out/shared/declare.d.ts +61 -45
  249. package/out/shared/declare.js +2 -2
  250. package/out/shared/disjoint.d.ts +85 -73
  251. package/out/shared/disjoint.js +108 -80
  252. package/out/shared/disjoint.js.map +1 -1
  253. package/out/shared/errors.d.ts +85 -45
  254. package/out/shared/errors.js +101 -101
  255. package/out/shared/implement.d.ts +351 -158
  256. package/out/shared/implement.js +61 -62
  257. package/out/shared/implement.js.map +1 -1
  258. package/out/shared/inference.d.ts +5 -5
  259. package/out/shared/inference.js +2 -2
  260. package/out/shared/intersections.d.ts +57 -12
  261. package/out/shared/intersections.js +2 -2
  262. package/out/shared/traversal.d.ts +57 -39
  263. package/out/shared/traversal.js +95 -95
  264. package/out/shared/utils.d.ts +23 -7
  265. package/out/shared/utils.d.ts.map +1 -1
  266. package/out/shared/utils.js +14 -9
  267. package/out/shared/utils.js.map +1 -1
  268. package/out/type.d.ts +24 -32
  269. package/out/type.d.ts.map +1 -1
  270. package/out/type.js +2 -51
  271. package/out/type.js.map +1 -1
  272. package/out/types/basis.d.ts +44 -21
  273. package/out/types/basis.js +13 -13
  274. package/out/types/discriminate.d.ts +33 -19
  275. package/out/types/discriminate.js +116 -110
  276. package/out/types/domain.d.ts +54 -37
  277. package/out/types/domain.js +39 -36
  278. package/out/types/intersection.d.ts +121 -61
  279. package/out/types/intersection.js +355 -326
  280. package/out/types/morph.d.ts +148 -70
  281. package/out/types/morph.js +97 -93
  282. package/out/types/proto.d.ts +48 -39
  283. package/out/types/proto.js +58 -46
  284. package/out/types/type.d.ts +137 -55
  285. package/out/types/type.d.ts.map +1 -1
  286. package/out/types/type.js +121 -109
  287. package/out/types/type.js.map +1 -1
  288. package/out/types/union.d.ts +66 -43
  289. package/out/types/union.js +299 -257
  290. package/out/types/unit.d.ts +41 -36
  291. package/out/types/unit.js +53 -45
  292. package/out/util.d.ts +30 -21
  293. package/out/util.js +8 -7
  294. package/package.json +3 -2
  295. package/parser/definition.ts +64 -81
  296. package/parser/generic.ts +35 -36
  297. package/parser/objectLiteral.ts +78 -92
  298. package/parser/semantic/bounds.ts +25 -33
  299. package/parser/semantic/divisor.ts +7 -11
  300. package/parser/semantic/infer.ts +69 -80
  301. package/parser/semantic/utils.ts +10 -13
  302. package/parser/semantic/validate.ts +81 -71
  303. package/parser/string/reduce/dynamic.ts +42 -39
  304. package/parser/string/reduce/shared.ts +1 -1
  305. package/parser/string/reduce/static.ts +50 -52
  306. package/parser/string/shift/operand/date.ts +5 -5
  307. package/parser/string/shift/operand/enclosed.ts +12 -13
  308. package/parser/string/shift/operand/genericArgs.ts +45 -44
  309. package/parser/string/shift/operand/operand.ts +32 -37
  310. package/parser/string/shift/operand/unenclosed.ts +99 -134
  311. package/parser/string/shift/operator/bounds.ts +78 -75
  312. package/parser/string/shift/operator/divisor.ts +11 -13
  313. package/parser/string/shift/operator/operator.ts +35 -46
  314. package/parser/string/shift/scanner.ts +39 -36
  315. package/parser/string/string.ts +26 -30
  316. package/parser/tuple.ts +206 -248
  317. package/scope.ts +185 -704
  318. package/type.ts +101 -140
  319. package/__tests__/errors.test.ts +0 -115
  320. package/__tests__/schema.bench.ts +0 -14
  321. package/__tests__/schema.test.ts +0 -60
  322. package/__tests__/typeMethods.test.ts +0 -68
  323. package/__tests__/unit.test.ts +0 -61
  324. package/base.ts +0 -520
  325. package/config.ts +0 -25
  326. package/constraints/ast.ts +0 -288
  327. package/constraints/constraint.ts +0 -91
  328. package/constraints/predicate.ts +0 -102
  329. package/constraints/props/index.ts +0 -93
  330. package/constraints/props/prop.ts +0 -146
  331. package/constraints/props/props.ts +0 -148
  332. package/constraints/props/sequence.ts +0 -473
  333. package/constraints/props/shared.ts +0 -5
  334. package/constraints/refinements/after.ts +0 -68
  335. package/constraints/refinements/before.ts +0 -75
  336. package/constraints/refinements/divisor.ts +0 -76
  337. package/constraints/refinements/exactLength.ts +0 -75
  338. package/constraints/refinements/kinds.ts +0 -31
  339. package/constraints/refinements/max.ts +0 -61
  340. package/constraints/refinements/maxLength.ts +0 -66
  341. package/constraints/refinements/min.ts +0 -54
  342. package/constraints/refinements/minLength.ts +0 -63
  343. package/constraints/refinements/range.ts +0 -181
  344. package/constraints/refinements/regex.ts +0 -59
  345. package/keywords/ark.ts +0 -101
  346. package/keywords/internal.ts +0 -29
  347. package/keywords/jsObject.ts +0 -39
  348. package/keywords/parsing.ts +0 -87
  349. package/keywords/root.ts +0 -9
  350. package/keywords/tsGenerics.ts +0 -28
  351. package/keywords/tsPrimitive.ts +0 -52
  352. package/keywords/utils/creditCard.ts +0 -37
  353. package/keywords/utils/date.ts +0 -112
  354. package/keywords/validation.ts +0 -115
  355. package/kinds.ts +0 -115
  356. package/parse.ts +0 -221
  357. package/schema.ts +0 -263
  358. package/shared/compile.ts +0 -92
  359. package/shared/declare.ts +0 -75
  360. package/shared/disjoint.ts +0 -203
  361. package/shared/errors.ts +0 -204
  362. package/shared/implement.ts +0 -327
  363. package/shared/inference.ts +0 -9
  364. package/shared/intersections.ts +0 -53
  365. package/shared/traversal.ts +0 -146
  366. package/shared/utils.ts +0 -30
  367. package/types/basis.ts +0 -62
  368. package/types/discriminate.ts +0 -168
  369. package/types/domain.ts +0 -79
  370. package/types/intersection.ts +0 -539
  371. package/types/morph.ts +0 -263
  372. package/types/proto.ts +0 -89
  373. package/types/type.ts +0 -319
  374. package/types/union.ts +0 -451
  375. package/types/unit.ts +0 -78
  376. package/util.ts +0 -39
@@ -1,327 +1,376 @@
1
- import { append, throwInternalError, throwParseError } from "@arktype/util";
2
- import { Disjoint } from "../../shared/disjoint.js";
3
- import { BaseConstraint } from "../constraint.js";
1
+ import { append, throwInternalError, throwParseError } from "@arktype/util"
2
+ import { Disjoint } from "../../shared/disjoint.js"
3
+ import { BaseConstraint } from "../constraint.js"
4
4
  const fixedSequenceKeyDefinition = {
5
- child: true,
6
- parse: (schema, ctx) => schema.length === 0
7
- ? // empty affixes are omitted. an empty array should therefore
8
- // be specified as `{ proto: Array, length: 0 }`
9
- undefined
10
- : schema.map((element) => ctx.$.node(element))
11
- };
5
+ child: true,
6
+ parse: (schema, ctx) =>
7
+ schema.length === 0
8
+ ? // empty affixes are omitted. an empty array should therefore
9
+ // be specified as `{ proto: Array, length: 0 }`
10
+ undefined
11
+ : schema.map((element) => ctx.$.node(element))
12
+ }
12
13
  export class SequenceNode extends BaseConstraint {
13
- static implementation = this.implement({
14
- hasAssociatedError: false,
15
- collapsibleKey: "variadic",
16
- keys: {
17
- prefix: fixedSequenceKeyDefinition,
18
- optionals: fixedSequenceKeyDefinition,
19
- variadic: {
20
- child: true,
21
- parse: (schema, ctx) => ctx.$.node(schema)
22
- },
23
- minVariadicLength: {
24
- // minVariadicLength is reflected in the id of this node,
25
- // but not its IntersectionNode parent since it is superceded by the minLength
26
- // node it implies
27
- implied: true,
28
- parse: (min) => (min === 0 ? undefined : min)
29
- },
30
- postfix: fixedSequenceKeyDefinition
31
- },
32
- normalize: (schema) => {
33
- if (typeof schema === "string") {
34
- return { variadic: schema };
35
- }
36
- if ("variadic" in schema ||
37
- "prefix" in schema ||
38
- "optionals" in schema ||
39
- "postfix" in schema ||
40
- "minVariadicLength" in schema) {
41
- if (schema.postfix?.length) {
42
- if (!schema.variadic) {
43
- return throwParseError(postfixWithoutVariadicMessage);
44
- }
45
- if (schema.optionals?.length) {
46
- return throwParseError(postfixFollowingOptionalMessage);
47
- }
48
- }
49
- if (schema.minVariadicLength && !schema.variadic) {
50
- return throwParseError("minVariadicLength may not be specified without a variadic element");
51
- }
52
- return schema;
53
- }
54
- return { variadic: schema };
55
- },
56
- reduce: (raw, $) => {
57
- let minVariadicLength = raw.minVariadicLength ?? 0;
58
- const prefix = raw.prefix?.slice() ?? [];
59
- const optionals = raw.optionals?.slice() ?? [];
60
- const postfix = raw.postfix?.slice() ?? [];
61
- if (raw.variadic) {
62
- // optional elements equivalent to the variadic parameter are redundant
63
- while (optionals.at(-1)?.equals(raw.variadic)) {
64
- optionals.pop();
65
- }
66
- if (optionals.length === 0) {
67
- // If there are no optional, normalize prefix
68
- // elements adjacent and equivalent to variadic:
69
- // { variadic: number, prefix: [string, number] }
70
- // reduces to:
71
- // { variadic: number, prefix: [string], minVariadicLength: 1 }
72
- while (prefix.at(-1)?.equals(raw.variadic)) {
73
- prefix.pop();
74
- minVariadicLength++;
75
- }
76
- }
77
- // Normalize postfix elements adjacent and equivalent to variadic:
78
- // { variadic: number, postfix: [number, number, 5] }
79
- // reduces to:
80
- // { variadic: number, postfix: [5], minVariadicLength: 2 }
81
- while (postfix[0]?.equals(raw.variadic)) {
82
- postfix.shift();
83
- minVariadicLength++;
84
- }
85
- }
86
- else if (optionals.length === 0) {
87
- // if there's no variadic or optional parameters,
88
- // postfix can just be appended to prefix
89
- prefix.push(...postfix.splice(0));
90
- }
91
- if (
92
- // if any variadic adjacent elements were moved to minVariadicLength
93
- minVariadicLength !== raw.minVariadicLength ||
94
- // or any postfix elements were moved to prefix
95
- (raw.prefix && raw.prefix.length !== prefix.length)) {
96
- // reparse the reduced schema
97
- return $.node("sequence", {
98
- ...raw,
99
- // empty lists will be omitted during parsing
100
- prefix,
101
- postfix,
102
- optionals,
103
- minVariadicLength
104
- }, { prereduced: true });
105
- }
106
- },
107
- defaults: {
108
- description(node) {
109
- if (node.isVariadicOnly)
110
- return `${node.variadic.nestableExpression}[]`;
111
- return ("[" +
112
- node.tuple
113
- .map((element) => element.kind === "optionals"
114
- ? `${element.node.nestableExpression}?`
115
- : element.kind === "variadic"
116
- ? `...${element.node.nestableExpression}[]`
117
- : element.node.expression)
118
- .join(", ") +
119
- "]");
120
- }
121
- },
122
- intersections: {
123
- sequence: (l, r, $) => {
124
- const rootState = intersectSequences({
125
- l: l.tuple,
126
- r: r.tuple,
127
- disjoint: new Disjoint({}),
128
- result: [],
129
- fixedVariants: []
130
- });
131
- const viableBranches = rootState.disjoint.isEmpty()
132
- ? [rootState, ...rootState.fixedVariants]
133
- : rootState.fixedVariants;
134
- return viableBranches.length === 0
135
- ? rootState.disjoint
136
- : viableBranches.length === 1
137
- ? $.node("sequence", sequenceTupleToInner(viableBranches[0].result))
138
- : $.node("union", viableBranches.map((state) => ({
139
- proto: Array,
140
- sequence: sequenceTupleToInner(state.result)
141
- })));
142
- }
143
- // exactLength, minLength, and maxLength don't need to be defined
144
- // here since impliedSiblings guarantees they will be added
145
- // directly to the IntersectionNode parent of the SequenceNode
146
- // they exist on
147
- }
148
- });
149
- impliedBasis = this.$.keywords.Array;
150
- prefix = this.inner.prefix ?? [];
151
- optionals = this.inner.optionals ?? [];
152
- prevariadic = [...this.prefix, ...this.optionals];
153
- postfix = this.inner.postfix ?? [];
154
- isVariadicOnly = this.prevariadic.length + this.postfix.length === 0;
155
- minVariadicLength = this.inner.minVariadicLength ?? 0;
156
- minLength = this.prefix.length + this.minVariadicLength + this.postfix.length;
157
- minLengthNode = this.minLength === 0 ? undefined : this.$.node("minLength", this.minLength);
158
- maxLength = this.variadic
159
- ? undefined
160
- : this.minLength + this.optionals.length;
161
- maxLengthNode = this.maxLength === undefined
162
- ? undefined
163
- : this.$.node("maxLength", this.maxLength);
164
- impliedSiblings = this.minLengthNode
165
- ? this.maxLengthNode
166
- ? [this.minLengthNode, this.maxLengthNode]
167
- : [this.minLengthNode]
168
- : this.maxLengthNode
169
- ? [this.maxLengthNode]
170
- : undefined;
171
- childAtIndex(data, index) {
172
- if (index < this.prevariadic.length)
173
- return this.prevariadic[index];
174
- const postfixStartIndex = data.length - this.postfix.length;
175
- if (index >= postfixStartIndex)
176
- return this.postfix[index - postfixStartIndex];
177
- return (this.variadic ??
178
- throwInternalError(`Unexpected attempt to access index ${index} on ${this}`));
179
- }
180
- // minLength/maxLength should be checked by Intersection before either traversal
181
- traverseAllows = (data, ctx) => {
182
- for (let i = 0; i < data.length; i++) {
183
- if (!this.childAtIndex(data, i).traverseAllows(data[i], ctx)) {
184
- return false;
185
- }
186
- }
187
- return true;
188
- };
189
- traverseApply = (data, ctx) => {
190
- for (let i = 0; i < data.length; i++) {
191
- ctx.path.push(i);
192
- this.childAtIndex(data, i).traverseApply(data[i], ctx);
193
- ctx.path.pop();
194
- }
195
- };
196
- // minLength/maxLength compilation should be handled by Intersection
197
- compile(js) {
198
- this.prefix.forEach((node, i) => js.checkReferenceKey(`${i}`, node));
199
- this.optionals.forEach((node, i) => {
200
- const dataIndex = `${i + this.prefix.length}`;
201
- js.if(`${dataIndex} >= ${js.data}.length`, () => js.traversalKind === "Allows" ? js.return(true) : js.return());
202
- js.checkReferenceKey(dataIndex, node);
203
- });
204
- if (this.variadic) {
205
- js.const("lastVariadicIndex", `${js.data}.length${this.postfix ? `- ${this.postfix.length}` : ""}`);
206
- js.for("i < lastVariadicIndex", () => js.checkReferenceKey("i", this.variadic), this.prevariadic.length);
207
- this.postfix.forEach((node, i) => js.checkReferenceKey(`lastVariadicIndex + ${i + 1}`, node));
208
- }
209
- if (js.traversalKind === "Allows") {
210
- js.return(true);
211
- }
212
- }
213
- tuple = sequenceInnerToTuple(this.inner);
214
- // this depends on tuple so needs to come after it
215
- expression = this.description;
14
+ static implementation = this.implement({
15
+ hasAssociatedError: false,
16
+ collapsibleKey: "variadic",
17
+ keys: {
18
+ prefix: fixedSequenceKeyDefinition,
19
+ optionals: fixedSequenceKeyDefinition,
20
+ variadic: {
21
+ child: true,
22
+ parse: (schema, ctx) => ctx.$.node(schema)
23
+ },
24
+ minVariadicLength: {
25
+ // minVariadicLength is reflected in the id of this node,
26
+ // but not its IntersectionNode parent since it is superceded by the minLength
27
+ // node it implies
28
+ implied: true,
29
+ parse: (min) => (min === 0 ? undefined : min)
30
+ },
31
+ postfix: fixedSequenceKeyDefinition
32
+ },
33
+ normalize: (schema) => {
34
+ if (typeof schema === "string") {
35
+ return { variadic: schema }
36
+ }
37
+ if (
38
+ "variadic" in schema ||
39
+ "prefix" in schema ||
40
+ "optionals" in schema ||
41
+ "postfix" in schema ||
42
+ "minVariadicLength" in schema
43
+ ) {
44
+ if (schema.postfix?.length) {
45
+ if (!schema.variadic) {
46
+ return throwParseError(postfixWithoutVariadicMessage)
47
+ }
48
+ if (schema.optionals?.length) {
49
+ return throwParseError(postfixFollowingOptionalMessage)
50
+ }
51
+ }
52
+ if (schema.minVariadicLength && !schema.variadic) {
53
+ return throwParseError(
54
+ "minVariadicLength may not be specified without a variadic element"
55
+ )
56
+ }
57
+ return schema
58
+ }
59
+ return { variadic: schema }
60
+ },
61
+ reduce: (raw, $) => {
62
+ let minVariadicLength = raw.minVariadicLength ?? 0
63
+ const prefix = raw.prefix?.slice() ?? []
64
+ const optionals = raw.optionals?.slice() ?? []
65
+ const postfix = raw.postfix?.slice() ?? []
66
+ if (raw.variadic) {
67
+ // optional elements equivalent to the variadic parameter are redundant
68
+ while (optionals.at(-1)?.equals(raw.variadic)) {
69
+ optionals.pop()
70
+ }
71
+ if (optionals.length === 0) {
72
+ // If there are no optional, normalize prefix
73
+ // elements adjacent and equivalent to variadic:
74
+ // { variadic: number, prefix: [string, number] }
75
+ // reduces to:
76
+ // { variadic: number, prefix: [string], minVariadicLength: 1 }
77
+ while (prefix.at(-1)?.equals(raw.variadic)) {
78
+ prefix.pop()
79
+ minVariadicLength++
80
+ }
81
+ }
82
+ // Normalize postfix elements adjacent and equivalent to variadic:
83
+ // { variadic: number, postfix: [number, number, 5] }
84
+ // reduces to:
85
+ // { variadic: number, postfix: [5], minVariadicLength: 2 }
86
+ while (postfix[0]?.equals(raw.variadic)) {
87
+ postfix.shift()
88
+ minVariadicLength++
89
+ }
90
+ } else if (optionals.length === 0) {
91
+ // if there's no variadic or optional parameters,
92
+ // postfix can just be appended to prefix
93
+ prefix.push(...postfix.splice(0))
94
+ }
95
+ if (
96
+ // if any variadic adjacent elements were moved to minVariadicLength
97
+ minVariadicLength !== raw.minVariadicLength ||
98
+ // or any postfix elements were moved to prefix
99
+ (raw.prefix && raw.prefix.length !== prefix.length)
100
+ ) {
101
+ // reparse the reduced schema
102
+ return $.node(
103
+ "sequence",
104
+ {
105
+ ...raw,
106
+ // empty lists will be omitted during parsing
107
+ prefix,
108
+ postfix,
109
+ optionals,
110
+ minVariadicLength
111
+ },
112
+ { prereduced: true }
113
+ )
114
+ }
115
+ },
116
+ defaults: {
117
+ description(node) {
118
+ if (node.isVariadicOnly)
119
+ return `${node.variadic.nestableExpression}[]`
120
+ return (
121
+ "[" +
122
+ node.tuple
123
+ .map((element) =>
124
+ element.kind === "optionals"
125
+ ? `${element.node.nestableExpression}?`
126
+ : element.kind === "variadic"
127
+ ? `...${element.node.nestableExpression}[]`
128
+ : element.node.expression
129
+ )
130
+ .join(", ") +
131
+ "]"
132
+ )
133
+ }
134
+ },
135
+ intersections: {
136
+ sequence: (l, r, $) => {
137
+ const rootState = intersectSequences({
138
+ l: l.tuple,
139
+ r: r.tuple,
140
+ disjoint: new Disjoint({}),
141
+ result: [],
142
+ fixedVariants: []
143
+ })
144
+ const viableBranches = rootState.disjoint.isEmpty()
145
+ ? [rootState, ...rootState.fixedVariants]
146
+ : rootState.fixedVariants
147
+ return viableBranches.length === 0
148
+ ? rootState.disjoint
149
+ : viableBranches.length === 1
150
+ ? $.node(
151
+ "sequence",
152
+ sequenceTupleToInner(viableBranches[0].result)
153
+ )
154
+ : $.node(
155
+ "union",
156
+ viableBranches.map((state) => ({
157
+ proto: Array,
158
+ sequence: sequenceTupleToInner(state.result)
159
+ }))
160
+ )
161
+ }
162
+ // exactLength, minLength, and maxLength don't need to be defined
163
+ // here since impliedSiblings guarantees they will be added
164
+ // directly to the IntersectionNode parent of the SequenceNode
165
+ // they exist on
166
+ }
167
+ })
168
+ impliedBasis = this.$.keywords.Array
169
+ prefix = this.inner.prefix ?? []
170
+ optionals = this.inner.optionals ?? []
171
+ prevariadic = [...this.prefix, ...this.optionals]
172
+ postfix = this.inner.postfix ?? []
173
+ isVariadicOnly = this.prevariadic.length + this.postfix.length === 0
174
+ minVariadicLength = this.inner.minVariadicLength ?? 0
175
+ minLength =
176
+ this.prefix.length + this.minVariadicLength + this.postfix.length
177
+ minLengthNode =
178
+ this.minLength === 0
179
+ ? undefined
180
+ : this.$.node("minLength", this.minLength)
181
+ maxLength = this.variadic
182
+ ? undefined
183
+ : this.minLength + this.optionals.length
184
+ maxLengthNode =
185
+ this.maxLength === undefined
186
+ ? undefined
187
+ : this.$.node("maxLength", this.maxLength)
188
+ impliedSiblings = this.minLengthNode
189
+ ? this.maxLengthNode
190
+ ? [this.minLengthNode, this.maxLengthNode]
191
+ : [this.minLengthNode]
192
+ : this.maxLengthNode
193
+ ? [this.maxLengthNode]
194
+ : undefined
195
+ childAtIndex(data, index) {
196
+ if (index < this.prevariadic.length) return this.prevariadic[index]
197
+ const postfixStartIndex = data.length - this.postfix.length
198
+ if (index >= postfixStartIndex)
199
+ return this.postfix[index - postfixStartIndex]
200
+ return (
201
+ this.variadic ??
202
+ throwInternalError(
203
+ `Unexpected attempt to access index ${index} on ${this}`
204
+ )
205
+ )
206
+ }
207
+ // minLength/maxLength should be checked by Intersection before either traversal
208
+ traverseAllows = (data, ctx) => {
209
+ for (let i = 0; i < data.length; i++) {
210
+ if (!this.childAtIndex(data, i).traverseAllows(data[i], ctx)) {
211
+ return false
212
+ }
213
+ }
214
+ return true
215
+ }
216
+ traverseApply = (data, ctx) => {
217
+ for (let i = 0; i < data.length; i++) {
218
+ ctx.path.push(i)
219
+ this.childAtIndex(data, i).traverseApply(data[i], ctx)
220
+ ctx.path.pop()
221
+ }
222
+ }
223
+ // minLength/maxLength compilation should be handled by Intersection
224
+ compile(js) {
225
+ this.prefix.forEach((node, i) => js.checkReferenceKey(`${i}`, node))
226
+ this.optionals.forEach((node, i) => {
227
+ const dataIndex = `${i + this.prefix.length}`
228
+ js.if(`${dataIndex} >= ${js.data}.length`, () =>
229
+ js.traversalKind === "Allows" ? js.return(true) : js.return()
230
+ )
231
+ js.checkReferenceKey(dataIndex, node)
232
+ })
233
+ if (this.variadic) {
234
+ js.const(
235
+ "lastVariadicIndex",
236
+ `${js.data}.length${
237
+ this.postfix ? `- ${this.postfix.length}` : ""
238
+ }`
239
+ )
240
+ js.for(
241
+ "i < lastVariadicIndex",
242
+ () => js.checkReferenceKey("i", this.variadic),
243
+ this.prevariadic.length
244
+ )
245
+ this.postfix.forEach((node, i) =>
246
+ js.checkReferenceKey(`lastVariadicIndex + ${i + 1}`, node)
247
+ )
248
+ }
249
+ if (js.traversalKind === "Allows") {
250
+ js.return(true)
251
+ }
252
+ }
253
+ tuple = sequenceInnerToTuple(this.inner)
254
+ // this depends on tuple so needs to come after it
255
+ expression = this.description
216
256
  }
217
257
  const sequenceInnerToTuple = (inner) => {
218
- const tuple = [];
219
- inner.prefix?.forEach((node) => tuple.push({ kind: "prefix", node }));
220
- inner.optionals?.forEach((node) => tuple.push({ kind: "optionals", node }));
221
- if (inner.variadic)
222
- tuple.push({ kind: "variadic", node: inner.variadic });
223
- inner.postfix?.forEach((node) => tuple.push({ kind: "postfix", node }));
224
- return tuple;
225
- };
226
- const sequenceTupleToInner = (tuple) => tuple.reduce((result, node) => {
227
- if (node.kind === "variadic") {
228
- result.variadic = node.node;
229
- }
230
- else {
231
- result[node.kind] = append(result[node.kind], node.node);
232
- }
233
- return result;
234
- }, {});
235
- export const postfixFollowingOptionalMessage = "A postfix required element cannot follow an optional element";
236
- export const postfixWithoutVariadicMessage = "A postfix element requires a variadic element";
258
+ const tuple = []
259
+ inner.prefix?.forEach((node) => tuple.push({ kind: "prefix", node }))
260
+ inner.optionals?.forEach((node) => tuple.push({ kind: "optionals", node }))
261
+ if (inner.variadic) tuple.push({ kind: "variadic", node: inner.variadic })
262
+ inner.postfix?.forEach((node) => tuple.push({ kind: "postfix", node }))
263
+ return tuple
264
+ }
265
+ const sequenceTupleToInner = (tuple) =>
266
+ tuple.reduce((result, node) => {
267
+ if (node.kind === "variadic") {
268
+ result.variadic = node.node
269
+ } else {
270
+ result[node.kind] = append(result[node.kind], node.node)
271
+ }
272
+ return result
273
+ }, {})
274
+ export const postfixFollowingOptionalMessage =
275
+ "A postfix required element cannot follow an optional element"
276
+ export const postfixWithoutVariadicMessage =
277
+ "A postfix element requires a variadic element"
237
278
  const intersectSequences = (state) => {
238
- const [lHead, ...lTail] = state.l;
239
- const [rHead, ...rTail] = state.r;
240
- if (!lHead || !rHead) {
241
- return state;
242
- }
243
- const lHasPostfix = lTail.at(-1)?.kind === "postfix";
244
- const rHasPostfix = rTail.at(-1)?.kind === "postfix";
245
- const kind = lHead.kind === "prefix" || rHead.kind === "prefix"
246
- ? "prefix"
247
- : lHead.kind === "optionals" || rHead.kind === "optionals"
248
- ? // if either operand has postfix elements, the full-length
249
- // intersection can't include optional elements (though they may
250
- // exist in some of the fixed length variants)
251
- lHasPostfix || rHasPostfix
252
- ? "prefix"
253
- : "optionals"
254
- : lHead.kind === "postfix" || rHead.kind === "postfix"
255
- ? "postfix"
256
- : "variadic";
257
- if (lHead.kind === "prefix" && rHead.kind === "variadic" && rHasPostfix) {
258
- const postfixBranchResult = intersectSequences({
259
- ...state,
260
- fixedVariants: [],
261
- r: rTail.map((element) => ({ ...element, kind: "prefix" }))
262
- });
263
- if (postfixBranchResult.disjoint.isEmpty()) {
264
- state.fixedVariants.push(postfixBranchResult);
265
- }
266
- }
267
- else if (rHead.kind === "prefix" &&
268
- lHead.kind === "variadic" &&
269
- lHasPostfix) {
270
- const postfixBranchResult = intersectSequences({
271
- ...state,
272
- fixedVariants: [],
273
- l: lTail.map((element) => ({ ...element, kind: "prefix" }))
274
- });
275
- if (postfixBranchResult.disjoint.isEmpty()) {
276
- state.fixedVariants.push(postfixBranchResult);
277
- }
278
- }
279
- const result = lHead.node.intersect(rHead.node);
280
- if (result instanceof Disjoint) {
281
- if (kind === "prefix" || kind === "postfix") {
282
- state.disjoint.add(result.withPrefixKey(
283
- // TODO: more precise path handling for Disjoints
284
- kind === "prefix" ? `${state.result.length}` : `-${lTail.length + 1}`));
285
- state.result = [
286
- ...state.result,
287
- { kind, node: lHead.node.$.keywords.never }
288
- ];
289
- }
290
- else if (kind === "optionals") {
291
- // if the element result is optional and unsatisfiable, the
292
- // intersection can still be satisfied as long as the tuple
293
- // ends before the disjoint element would occur
294
- return state;
295
- }
296
- else {
297
- // if the element is variadic and unsatisfiable, the intersection
298
- // can be satisfied with a fixed length variant including zero
299
- // variadic elements
300
- return intersectSequences({
301
- ...state,
302
- fixedVariants: [],
303
- // if there were any optional elements, there will be no postfix elements
304
- // so this mapping will never occur (which would be illegal otherwise)
305
- l: lTail.map((element) => ({ ...element, kind: "prefix" })),
306
- r: lTail.map((element) => ({ ...element, kind: "prefix" }))
307
- });
308
- }
309
- }
310
- else {
311
- state.result = [...state.result, { kind, node: result }];
312
- }
313
- const lRemaining = state.l.length;
314
- const rRemaining = state.r.length;
315
- if (lHead.kind !== "variadic" ||
316
- (lRemaining >= rRemaining &&
317
- (rHead.kind === "variadic" || rRemaining === 1))) {
318
- state.l = lTail;
319
- }
320
- if (rHead.kind !== "variadic" ||
321
- (rRemaining >= lRemaining &&
322
- (lHead.kind === "variadic" || lRemaining === 1))) {
323
- state.r = rTail;
324
- }
325
- return intersectSequences(state);
326
- };
327
- //# sourceMappingURL=sequence.js.map
279
+ const [lHead, ...lTail] = state.l
280
+ const [rHead, ...rTail] = state.r
281
+ if (!lHead || !rHead) {
282
+ return state
283
+ }
284
+ const lHasPostfix = lTail.at(-1)?.kind === "postfix"
285
+ const rHasPostfix = rTail.at(-1)?.kind === "postfix"
286
+ const kind =
287
+ lHead.kind === "prefix" || rHead.kind === "prefix"
288
+ ? "prefix"
289
+ : lHead.kind === "optionals" || rHead.kind === "optionals"
290
+ ? // if either operand has postfix elements, the full-length
291
+ // intersection can't include optional elements (though they may
292
+ // exist in some of the fixed length variants)
293
+ lHasPostfix || rHasPostfix
294
+ ? "prefix"
295
+ : "optionals"
296
+ : lHead.kind === "postfix" || rHead.kind === "postfix"
297
+ ? "postfix"
298
+ : "variadic"
299
+ if (lHead.kind === "prefix" && rHead.kind === "variadic" && rHasPostfix) {
300
+ const postfixBranchResult = intersectSequences({
301
+ ...state,
302
+ fixedVariants: [],
303
+ r: rTail.map((element) => ({ ...element, kind: "prefix" }))
304
+ })
305
+ if (postfixBranchResult.disjoint.isEmpty()) {
306
+ state.fixedVariants.push(postfixBranchResult)
307
+ }
308
+ } else if (
309
+ rHead.kind === "prefix" &&
310
+ lHead.kind === "variadic" &&
311
+ lHasPostfix
312
+ ) {
313
+ const postfixBranchResult = intersectSequences({
314
+ ...state,
315
+ fixedVariants: [],
316
+ l: lTail.map((element) => ({ ...element, kind: "prefix" }))
317
+ })
318
+ if (postfixBranchResult.disjoint.isEmpty()) {
319
+ state.fixedVariants.push(postfixBranchResult)
320
+ }
321
+ }
322
+ const result = lHead.node.intersect(rHead.node)
323
+ if (result instanceof Disjoint) {
324
+ if (kind === "prefix" || kind === "postfix") {
325
+ state.disjoint.add(
326
+ result.withPrefixKey(
327
+ // TODO: more precise path handling for Disjoints
328
+ kind === "prefix"
329
+ ? `${state.result.length}`
330
+ : `-${lTail.length + 1}`
331
+ )
332
+ )
333
+ state.result = [
334
+ ...state.result,
335
+ { kind, node: lHead.node.$.keywords.never }
336
+ ]
337
+ } else if (kind === "optionals") {
338
+ // if the element result is optional and unsatisfiable, the
339
+ // intersection can still be satisfied as long as the tuple
340
+ // ends before the disjoint element would occur
341
+ return state
342
+ } else {
343
+ // if the element is variadic and unsatisfiable, the intersection
344
+ // can be satisfied with a fixed length variant including zero
345
+ // variadic elements
346
+ return intersectSequences({
347
+ ...state,
348
+ fixedVariants: [],
349
+ // if there were any optional elements, there will be no postfix elements
350
+ // so this mapping will never occur (which would be illegal otherwise)
351
+ l: lTail.map((element) => ({ ...element, kind: "prefix" })),
352
+ r: lTail.map((element) => ({ ...element, kind: "prefix" }))
353
+ })
354
+ }
355
+ } else {
356
+ state.result = [...state.result, { kind, node: result }]
357
+ }
358
+ const lRemaining = state.l.length
359
+ const rRemaining = state.r.length
360
+ if (
361
+ lHead.kind !== "variadic" ||
362
+ (lRemaining >= rRemaining &&
363
+ (rHead.kind === "variadic" || rRemaining === 1))
364
+ ) {
365
+ state.l = lTail
366
+ }
367
+ if (
368
+ rHead.kind !== "variadic" ||
369
+ (rRemaining >= lRemaining &&
370
+ (lHead.kind === "variadic" || lRemaining === 1))
371
+ ) {
372
+ state.r = rTail
373
+ }
374
+ return intersectSequences(state)
375
+ }
376
+ //# sourceMappingURL=sequence.js.map