/** * The accumulators that the tokenizer gathers strings and numbers into while * their bytes arrive. * * @module */ /** * An accumulator of utf-8 bytes that can be turned into a string. * * The tokenizer uses one of these per string and number token, since a value * can be split across any number of `write()` calls. */ export interface StringBuilder { /** How many bytes have been appended since the last {@linkcode StringBuilder.reset}. */ byteLength: number; /** Appends a single-byte (ASCII) character. */ appendChar: (char: number) => void; /** Appends the utf-8 bytes in `buf` between `start` and `end`, which must not cut through a character. */ appendBuf: (buf: Uint8Array, start?: number, end?: number) => void; appendCharCode: (code: number) => void; /** Discards everything appended so far, so the builder can be reused for the next token. */ reset: () => void; /** The string that the appended bytes decode to. */ toString: () => string; } /** * A {@linkcode StringBuilder} that accumulates the token as a JavaScript * string. This is the default: it's the fastest option for the small strings * and numbers that dominate real JSON. */ export declare class NonBufferedString implements StringBuilder { private decoder; private pending; private string; byteLength: number; appendChar(char: number): void; appendBuf(buf: Uint8Array, start?: number, end?: number): void; appendCharCode(code: number): void; reset(): void; toString(): string; } /** * A {@linkcode StringBuilder} that accumulates the token's bytes into a * fixed-size `Uint8Array` and only decodes them once the buffer is full. * * Enabled through the tokenizer's `stringBufferSize`/`numberBufferSize` * options. It avoids V8's over-allocation on repeated string concatenation, * which is what makes very large strings and numbers exhaust memory, at the * cost of an encoding/decoding round trip that isn't worth it for small values. */ export declare class BufferedString implements StringBuilder { private decoder; private buffer; private bufferOffset; private string; byteLength: number; /** * @param bufferSize The size, in bytes, of the buffer to accumulate into. */ constructor(bufferSize: number); appendChar(char: number): void; appendBuf(buf: Uint8Array, start?: number, end?: number): void; appendCharCode(code: number): void; private flushStringBuffer; reset(): void; toString(): string; } //# sourceMappingURL=bufferedString.d.ts.map