(raw: Fn, params: BaseRoot, returns: BaseRoot)
| 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 { |
nothing calls this directly
no test coverage detected