This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { z, ZodDate, ZodNumber, ZodBoolean, ZodString, ZodObject, ZodDiscriminatedUnion, ZodEnum, ZodArray, ZodTypeAny, ZodLiteral } from "zod"; | |
const textEncoder = new TextEncoder(); | |
const textDecoder = new TextDecoder(); | |
export async function serialize<T extends ZodTypeAny>(schema: T, data: z.infer<T>): Promise<ArrayBuffer> { | |
let accumulation = new Uint8Array(); | |
for await (const k of _serialize(schema, data, '')) { | |
accumulation = concatTypedArrays(accumulation, k); |