UNPKG

json-accelerator

Version:

Speed up JSON stringification by providing OpenAPI/TypeBox model

24 lines (23 loc) 937 B
import type { TAnySchema } from '@sinclair/typebox'; export declare const mergeObjectIntersection: (schema: TAnySchema) => TAnySchema; interface Instruction { array: number; optional: number; hasString: boolean; properties: string[]; /** * If unsafe character is found, how should the encoder handle it? * * This value only applied to string field. * * - 'throw': Throw an error * - 'ignore': Ignore the unsafe character, this implied that end user should handle it * - 'sanitize': Sanitize the string and continue encoding * * @default 'sanitize' **/ sanitize: 'auto' | 'manual' | 'throw'; definitions: Record<string, TAnySchema>; } export declare const createAccelerator: <T extends TAnySchema>(schema: T, { sanitize, definitions }?: Partial<Pick<Instruction, "sanitize" | "definitions">>) => ((v: T["static"]) => string); export default createAccelerator;