Download packages/console/core/src/util/fn.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 321 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/console/core/src/util/fn.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/console/core/src/util/fn.ts
-
curl -L -o fn.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/console/core/src/util/fn.ts
321 Bytes
| import { z } from "zod" | |
| export function fn<T extends z.ZodType, Result>(schema: T, cb: (input: z.infer<T>) => Result) { | |
| const result = (input: z.infer<T>) => { | |
| const parsed = schema.parse(input) | |
| return cb(parsed) | |
| } | |
| result.force = (input: z.infer<T>) => cb(input) | |
| result.schema = schema | |
| return result | |
| } | |