/** * JData encoding: JavaScript values (typed and N-D arrays, complex and sparse arrays, maps, byte * streams, NaN and infinities, 64-bit integers) as JData-annotated JSON or BJData values. * * Copyright (c) 2019-2026 Qianqian Fang . BSD 3-clause license. */ import { Codec } from './codecs'; import { ZipJob } from './payloads'; export interface EncodeOptions { /** 'json' (default): the result is for JSON (base64 payloads, "_NaN_"/"_Inf_" strings, * numbers in arrays); 'bjdata': for a BJData writer such as bjd (raw payloads, IEEE numbers, * typed arrays left as they are) */ target?: 'json' | 'bjdata'; /** compress the arrays: 'zlib', 'gzip', 'lz4', 'base64', or a registered codec */ compression?: string; /** the fewest elements an array needs to be compressed (default 1) */ compressArraySize?: number; /** shuffle the bytes of the elements before compressing (true: by the element size) */ shuffle?: boolean | number; /** compression level */ level?: number; /** _ArrayZipData_ as base64 text (default: true for JSON, false for BJData) */ base64?: boolean; /** codecs for this call */ codecs?: { [name: string]: Codec; }; /** zlib payloads in zlibmt blocks, which zmat, jdai and decodeAsync inflate on several threads * (a standard zlib stream still; default false, and true in encodeAsync) */ zlibmt?: boolean; } export declare class JDataEncoder { private o; private json; private stack; private jobs?; /** jobs: zlib and gzip payloads are left there to compress later (encodeAsync) */ constructor(opts?: EncodeOptions, jobs?: ZipJob[]); value(x: any): any; private zip; /** Adds the compressed payload of typed data of type t (and its annotations) to out. */ private zipInto; /** The compressed payload of typed data of type t. */ private payload; /** A compressed payload as _ArrayZipData_. */ private format; /** An annotated N-D array of typed (or plain) data. */ private typed; private sparse; } /** The JData-annotated form of a value (for JSON.stringify, or for a BJData writer with * target: 'bjdata'). */ export declare function encode(value: any, opts?: EncodeOptions): any;