UNPKG

@jsonjoy.com/json-type

Version:

High-performance JSON Pointer implementation

28 lines (27 loc) 2.23 kB
import { JsExpression } from '@jsonjoy.com/util/lib/codegen/util/JsExpression'; import { CapacityEstimatorCodegenContext } from './CapacityEstimatorCodegenContext'; import type { CapacityEstimatorCodegenContextOptions, CompiledCapacityEstimator } from './CapacityEstimatorCodegenContext'; import type { Type } from '../../type'; type EstimatorFunction = (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; export declare const any: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; export declare const bool: (ctx: CapacityEstimatorCodegenContext, value: JsExpression) => void; export declare const num: (ctx: CapacityEstimatorCodegenContext, value: JsExpression) => void; export declare const str: (ctx: CapacityEstimatorCodegenContext, value: JsExpression) => void; export declare const bin: (ctx: CapacityEstimatorCodegenContext, value: JsExpression) => void; export declare const const_: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; export declare const arr: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; export declare const tup: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; export declare const obj: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type, estimateCapacityFn: EstimatorFunction) => void; export declare const map: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; export declare const ref: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; export declare const or: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type, estimateCapacityFn: EstimatorFunction) => void; /** * Main router function that dispatches capacity estimation to the appropriate * estimator function based on the type's kind. */ export declare const generate: (ctx: CapacityEstimatorCodegenContext, value: JsExpression, type: Type) => void; /** * Standalone function to generate a capacity estimator for a given type. */ export declare const codegen: (type: Type, options: Omit<CapacityEstimatorCodegenContextOptions, "type">) => CompiledCapacityEstimator; export {};