MCPcopy Create free account
hub / github.com/arktypeio/arktype / parseBound

Function parseBound

ark/type/parser/shift/operator/bounds.ts:32–52  ·  view source on GitHub ↗
(
	s: RootedRuntimeState,
	start: ComparatorStartChar
)

Source from the content-addressed store, hash-verified

30import { writeUnexpectedCharacterMessage } from "./operator.ts"
31
32export const parseBound = (
33 s: RootedRuntimeState,
34 start: ComparatorStartChar
35): void => {
36 const comparator = shiftComparator(s, start)
37 if (s.root.is("unit")) {
38 if (typeof s.root.unit === "number" && Number.isFinite(s.root.unit)) {
39 s.reduceLeftBound(s.root.unit, comparator)
40 s.unsetRoot()
41 return
42 }
43 if (s.root.unit instanceof Date) {
44 const literal =
45 `d'${s.root.meta.description ?? s.root.unit.toISOString()}'` as const
46 s.unsetRoot()
47 s.reduceLeftBound(literal, comparator)
48 return
49 }
50 }
51 return parseRightBound(s, comparator)
52}
53
54export type parseBound<
55 s extends StaticState,

Callers 1

parseOperatorFunction · 0.90

Calls 5

shiftComparatorFunction · 0.85
parseRightBoundFunction · 0.85
isMethod · 0.80
reduceLeftBoundMethod · 0.80
unsetRootMethod · 0.80

Tested by

no test coverage detected