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

Method jsCond

ark/schema/roots/unit.ts:99–111  ·  view source on GitHub ↗
(js: NodeCompiler, data: string)

Source from the content-addressed store, hash-verified

97 }
98
99 jsCond(js: NodeCompiler, data: string): string {
100 const time = dateTimeOf(this.unit)
101 return (
102 time !== undefined ?
103 Number.isNaN(time) ?
104 `${data} instanceof Date && Number.isNaN(${js.ref(timeOf)}(${data}))`
105 : `${data} instanceof Date && ${js.ref(timeOf)}(${data}) === ${time}`
106 : Number.isNaN(this.unit) ? `Number.isNaN(${data})`
107 : hasDomain(this.unit, "object") || typeof this.unit === "symbol" ?
108 `${data} === ${js.ref(this.unit)}`
109 : `${data} === ${this.jsUnit}`
110 )
111 }
112
113 expression: string =
114 dateTimeOf(this.unit) !== undefined ?

Callers 7

defaultFailsMethod · 0.45
security.test.tsFile · 0.45
jsApplyMethod · 0.45
jsExpressionFunction · 0.45
keyFailsFunction · 0.45
conditionFunction · 0.45
checkFunction · 0.45

Calls 3

hasDomainFunction · 0.90
dateTimeOfFunction · 0.85
refMethod · 0.45

Tested by

no test coverage detected