UNPKG

@deepkit/bson

Version:
68 lines (67 loc) 2.36 kB
import { Type } from '@deepkit/type'; /** * This creates a JS string from a utf8 byte buffer. This is the fastest way possible to create * small strings (< 14chars). Everything else should be cached or created by Buffer.toString('utf8'). */ export declare function decodeUTF8Parser(parser: BaseParser, size?: number): string; /** * This is the (slowest) base parser which parses all property names as utf8. */ export declare class BaseParser { buffer: Uint8Array; offset: number; size: number; dataView: DataView; constructor(buffer: Uint8Array, offset?: number); peek(elementType: number, type?: Type): any; parse(elementType: number, type?: Type): any; parseRegExp(): RegExp; /** * read the content without moving the parser offset. */ read(elementType: number, type?: Type): any; parseBoolean(): boolean; parseLong(): bigint; parseString(): string; parseBinaryBigInt(): BigInt; parseSignedBinaryBigInt(): BigInt; parseBinary(type?: Type): any; readBigIntBinary(size: number): bigint; readSignedBigIntBinary(size: number): bigint; parseNumber(): number; parseOid(): string; parseUUID(): string; parseInt(): number; parseDate(): Date; peekUInt32(): number; /** * Returns the size including \0. */ stringSize(): number; eatObjectPropertyName(): string; seek(size: number): void; eatByte(): number; eatInt32(): number; eatUInt32(): number; eatDouble(): number; /** * Size includes the \0. If not existend, increase by 1. */ eatString(size: number): string; } /** * This is a general purpose Parser assuming ascii names as property names. * It falls back automatically to UTF8 when a UTF8 byte was found. * This is way faster than BaseParser when property names are mainly ascii (which is usually the case). */ export declare class ParserV2 extends BaseParser { eatObjectPropertyName(): any; eatString(size: number): string; } export declare class ParserV3 extends BaseParser { eatObjectPropertyName(): string; eatString(size: number): string; } export declare function parseObject(parser: BaseParser): any; export declare function parseArray(parser: BaseParser): any[]; export declare function deserializeBSONWithoutOptimiser(buffer: Uint8Array, offset?: number): any;