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
| let | |
| inherit (import <nixpkgs> {system = builtins.currentSystem;}) lib; | |
| inherit (lib) isFunction isString isInt isAttrs attrsToList any all isList imap0 length elemAt; | |
| P = { | |
| # Wildcard | |
| _ = { | |
| __type = "pattern"; | |
| __kind = "any wildcard"; | |
| __functor = _: value: value != null; |
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); |