UNPKG

@jsonjoy.com/json-type

Version:

High-performance JSON Pointer implementation

21 lines (20 loc) 1.08 kB
import { Codegen } from '@jsonjoy.com/codegen'; import { JsExpression } from '@jsonjoy.com/codegen/lib/util/JsExpression'; import type { json_string } from '@jsonjoy.com/util/lib/json-brand'; import type { ArrType, MapType, ObjType, OrType, RefType, Type } from '../../type'; export type JsonEncoderFn = <T>(value: T) => json_string<T>; export declare class JsonTextCodegen { protected readonly type: Type; static readonly get: (this: unknown, type: Type, name?: string | undefined) => JsonEncoderFn; readonly codegen: Codegen<JsonEncoderFn>; constructor(type: Type, name?: string); js(js: string): void; writeText(str: string): void; compile(): JsonEncoderFn; protected onArr(value: JsExpression, type: ArrType<any, any, any>): void; protected onObj(value: JsExpression, objType: ObjType): void; protected onMap(value: JsExpression, type: MapType<any>): void; protected onRef(value: JsExpression, ref: RefType<any>): void; protected onOr(value: JsExpression, type: OrType): void; onNode(value: JsExpression, type: Type): void; }