UNPKG

obj-codec

Version:

Encode objects into binary and decode binary back into objects, supporting nested references, custom object encoding/decoding, unique pointers...

35 lines (33 loc) 1.46 kB
import { BaseType, BasicType, BinaryType, CUSTOM_TYPE_ID_BEGIN, DecodeOptions, EncodeOptions, IClass, ICodec, INTERNAL_CODEC, INTERNAL_CODEC_MAP, INTERNAL_TYPE_ID, IObjCodec, InternalCodec, InternalType, InternalTypeName, ObjDecoderOptions, ObjEncoderOptions, Pointer, VERSION, bufferToUint8Array, concatBuffers, isBinary } from "./utils-CkllbhpT.js"; //#region src/web.d.ts declare class ObjEncoder extends ReadableStream<Uint8Array> { #private; constructor(options: EncodeOptions); /** 启动编码 */ encode(): Generator<Uint8Array, void, unknown>; } declare class ObjDecoder extends WritableStream<Uint8Array> { #private; constructor(options: DecodeOptions); /** 解码 */ decode(buffer: BinaryType): void; /** * 获取结果 * @description * 调用此方法将结束解码 */ getResult(): any; } declare class ObjCodec extends IObjCodec { /** * 编码 * @param root 编码根对象 */ static encode(root: any, options?: ObjEncoderOptions): ObjEncoder; /** 解码 */ static decode(options?: ObjDecoderOptions): ObjDecoder; encode(root: any, options?: ObjEncoderOptions): ObjEncoder; decode(options?: ObjDecoderOptions): ObjDecoder; } //#endregion export { BaseType, BasicType, BinaryType, CUSTOM_TYPE_ID_BEGIN, IClass, ICodec, INTERNAL_CODEC, INTERNAL_CODEC_MAP, INTERNAL_TYPE_ID, InternalCodec, InternalType, InternalTypeName, ObjCodec, Pointer, VERSION, bufferToUint8Array, concatBuffers, isBinary };