This repository was archived by the owner on Apr 1, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @opencode-ai/util" ,
3+ "version" : " 0.0.0" ,
4+ "private" : true ,
5+ "type" : " module" ,
6+ "exports" : {
7+ "./*" : " ./src/*.ts"
8+ },
9+ "scripts" : {
10+ "typecheck" : " tsc --noEmit"
11+ },
12+ "dependencies" : {
13+ "zod" : " catalog:"
14+ },
15+ "devDependencies" : {
16+ "typescript" : " catalog:"
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ import { z } from "zod"
2+
3+ export function fn < T extends z . ZodType , Result > ( schema : T , cb : ( input : z . infer < T > ) => Result ) {
4+ const result = ( input : z . infer < T > ) => {
5+ const parsed = schema . parse ( input )
6+ return cb ( parsed )
7+ }
8+ result . force = ( input : z . infer < T > ) => cb ( input )
9+ result . schema = schema
10+ return result
11+ }
Original file line number Diff line number Diff line change 1+ export function iife < T > ( fn : ( ) => T ) {
2+ return fn ( )
3+ }
Original file line number Diff line number Diff line change 1+ export function lazy < T > ( fn : ( ) => T ) {
2+ let value : T | undefined
3+ let loaded = false
4+
5+ return ( ) : T => {
6+ if ( loaded ) return value as T
7+ loaded = true
8+ value = fn ( )
9+ return value as T
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "target" : " ESNext" ,
4+ "module" : " ESNext" ,
5+ "moduleResolution" : " bundler" ,
6+ "skipLibCheck" : true ,
7+ "allowSyntheticDefaultImports" : true ,
8+ "esModuleInterop" : true ,
9+ "allowJs" : true ,
10+ "noEmit" : true ,
11+ "strict" : true ,
12+ "isolatedModules" : true
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments