UNPKG

@tai-kun/surrealdb

Version:

The SurrealDB SDK for JavaScript

131 lines 4.86 kB
import type { Uint8ArrayLike } from "@tai-kun/surrealdb/types"; import { MT_BYTE_STRING, MT_UTF8_STRING, Simple } from "./spec"; import Tagged from "./tagged"; type InputValue = unknown; declare const PARENT_ROOT = 0; declare const PARENT_STR = 1; declare const PARENT_ARR = 2; declare const PARENT_OBJ = 3; declare const PARENT_MAP = 4; declare const PARENT_TAG = 5; declare namespace Parent { type Root = { readonly $: typeof PARENT_ROOT; readonly put: (val: InputValue) => false; readonly out: () => unknown; val: unknown; }; namespace Str { type Byte = { readonly $: typeof PARENT_STR; readonly mt: typeof MT_BYTE_STRING; readonly put: (val: InputValue) => boolean; readonly out: () => Uint8Array; readonly acc: Uint8Array[]; size: number; }; type Utf8 = { readonly $: typeof PARENT_STR; readonly mt: typeof MT_UTF8_STRING; readonly put: (val: InputValue) => boolean; readonly out: () => string; acc: string; }; } type Str = Str.Byte | Str.Utf8; type Arr = { readonly $: typeof PARENT_ARR; readonly put: (val: InputValue) => boolean; readonly out: () => unknown[]; readonly acc: unknown[]; readonly len: number; idx: number; }; namespace Obj { type Obj = { readonly $: typeof PARENT_OBJ; readonly put: (val: InputValue) => boolean; readonly out: () => { [p: string]: unknown; }; readonly acc: { [p: string]: unknown; }; readonly v8n: IsSafeObjectKey; readonly len: number; idx: number; key: string | number | typeof NONE; }; type Maq = { readonly $: typeof PARENT_MAP; readonly put: (val: InputValue) => boolean; readonly out: () => Map<unknown, unknown>; readonly acc: Map<unknown, unknown>; readonly v8n: IsSafeMapKey; readonly len: number; idx: number; key: unknown | typeof NONE; }; } type Obj = Obj.Obj | Obj.Maq; type Tag = { readonly $: typeof PARENT_TAG; readonly put: (val: InputValue) => boolean; readonly out: () => unknown; readonly fns: readonly TaggedItemReviver[]; readonly tag: number | bigint; val: unknown; }; } type Parent = Parent.Root | Parent.Str | Parent.Arr | Parent.Obj | Parent.Tag; declare const FRAGMENT_STR = 0; declare namespace Fragment { type Str = { readonly $: typeof FRAGMENT_STR; readonly mt: typeof MT_BYTE_STRING | typeof MT_UTF8_STRING; readonly data: Uint8Array; readonly size: number; offset: number; }; } type Fragment = Fragment.Str | never; declare const NONE: unique symbol; export declare const CONTINUE: unique symbol; export type TaggedItemReviver = (tagged: Tagged) => unknown | typeof CONTINUE; export type SimpleItemReviver = (simple: Simple) => unknown | typeof CONTINUE; export interface ReviverObject { readonly tagged?: TaggedItemReviver | undefined; readonly simple?: SimpleItemReviver | undefined; } export type Reviver = (value: Tagged | Simple) => unknown | typeof CONTINUE; export type IsSafeMapKey = (key: unknown, map: Map<unknown, unknown>) => boolean; export type IsSafeObjectKey = (key: string | number, obj: Record<string, unknown>) => boolean; export interface DecoderOptions { readonly isSafeMapKey?: IsSafeMapKey | undefined; readonly isSafeObjectKey?: IsSafeObjectKey | undefined; readonly mapType?: "Object" | "Map" | undefined; readonly maxDepth?: number | undefined; readonly reviver?: Reviver | ReviverObject | readonly (Reviver | ReviverObject)[] | undefined; } export declare class _Decoder { protected readonly mapType: "Object" | "Map"; protected readonly maxDepth: number; protected readonly revivers: { tagged: TaggedItemReviver[]; simple: SimpleItemReviver[]; }; protected readonly isSafeMapKey: (key: unknown, map: Map<unknown, unknown>) => boolean; protected readonly isSafeObjectKey: (key: string | number, obj: Record<string, unknown>) => boolean; constructor(options?: DecoderOptions | undefined); protected depth: number; protected readonly parents: [Parent.Root, ...Exclude<Parent, Parent.Root>[]]; protected parent: Parent; protected fragment: Fragment | null; protected putValue(value: InputValue): void; protected begin(parent: Exclude<Parent, Parent.Root>): void; private end; process(input: Uint8ArrayLike): void; output(): unknown; } export {}; //# sourceMappingURL=decoder.d.ts.map