UNPKG

@cloudpss/ubjson

Version:

Opinionated UBJSON encoder/decoder for CloudPSS.

59 lines 2.45 kB
import type { DecodeOptions } from '../options.js'; /** 数据包装 */ export interface DecodeCursor { /** 数据 */ readonly view: DataView; /** 数据 */ readonly data: Uint8Array; /** 当前读指针位置 */ offset: number; /** 读取到末尾时调用 */ eof(): never; /** 选项 */ readonly options: DecodeOptions | undefined; } /** 创建数据包装 */ export declare function DecodeCursor(data: BufferSource, options?: DecodeOptions): DecodeCursor; /** * 读取第一个非 NOOP 的字节 * @returns 返回读取到的字节,如果读取到末尾则返回 undefined */ export declare function readMarkerOrUndefined(cursor: DecodeCursor): number | undefined; /** * 读取第一个非 NOOP 的字节 */ export declare function readMarker(cursor: DecodeCursor): number; /** 读取一个大于 0 的整数 */ export declare function readLength(cursor: DecodeCursor): number; /** readInt8Data */ export declare function readInt8Data(cursor: DecodeCursor): number; /** readUint8Data */ export declare function readUint8Data(cursor: DecodeCursor): number; /** readInt16Data */ export declare function readInt16Data(cursor: DecodeCursor): number; /** readInt32Data */ export declare function readInt32Data(cursor: DecodeCursor): number; /** readInt64Data */ export declare function readInt64Data(cursor: DecodeCursor): bigint; /** readFloat32Data */ export declare function readFloat32Data(cursor: DecodeCursor): number; /** readFloat64Data */ export declare function readFloat64Data(cursor: DecodeCursor): number; /** 读取数据 */ export declare function read(cursor: DecodeCursor): unknown; /** 处理 `__proto__` */ export declare function protoAction(cursor: Pick<DecodeCursor, 'options'>, obj: Record<string, unknown>, value: unknown): void; /** 处理 `constructor` */ export declare function constructorAction(cursor: Pick<DecodeCursor, 'options'>, obj: Record<string, unknown>, value: unknown): void; /** 根据标签读取后续数据 */ export declare function readData(cursor: DecodeCursor, marker: number): unknown; /** readKey */ export declare function readKey(cursor: DecodeCursor): string; /** Optimized Format 数据 */ export type OptimizedFormatMarkers = { type?: number; count: number; }; /** 读取 Optimized Format 数据 */ export declare function readOptimizedFormatMarkers(cursor: DecodeCursor): OptimizedFormatMarkers | undefined; //# sourceMappingURL=decode.d.ts.map