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

Method constructor

ark/type/fn.ts:146–161  ·  view source on GitHub ↗
(raw: Fn, params: BaseRoot, returns: BaseRoot)

Source from the content-addressed store, hash-verified

144 returns: BaseRoot
145
146 constructor(raw: Fn, params: BaseRoot, returns: BaseRoot) {
147 const typedName = `typed ${functionNameOf(raw)}`
148 const typed = {
149 // assign to a key with the expected name to force it to be created that way
150 [typedName](this: unknown, ...args: unknown[]) {
151 const validatedArgs = params.assert(args) as unknown[]
152 const returned = raw.apply(this, validatedArgs)
153 return returns.assert(returned)
154 }
155 }[typedName]
156
157 super(typed, { bind: null })
158 this.raw = raw
159 this.params = params
160 this.returns = returns
161 }
162
163 // a standalone validator may lack an expression
164 get expression(): string {

Callers

nothing calls this directly

Calls 1

functionNameOfFunction · 0.90

Tested by

no test coverage detected