/** * StringBuf - Cross-Platform String Buffer * * Efficient string builder that accumulates UTF-8 encoded bytes into a single * `Uint8Array`. Designed for hot paths that build large XML / text payloads * (XLSX worksheet writers, streaming DOCX writer) where naïve `string +=` * concatenation triggers O(n²) re-allocations. * * Works identically in Node.js and Browser environments — uses only * `TextEncoder` and `Uint8Array`. */ interface StringBufOptions { /** Initial capacity in bytes (default: 16384). */ size?: number; /** * Encoding label, accepted for API symmetry. Only UTF-8 is supported by * `TextEncoder`, so this option is ignored. */ encoding?: string; } /** * Efficient string builder backed by a growable `Uint8Array`. */ declare class StringBuf { private _buf; private _inPos; private _buffer; constructor(options?: StringBufOptions); get length(): number; get capacity(): number; get buffer(): Uint8Array; /** Return a snapshot of the bytes written so far. Cached until next mutation. */ toBuffer(): Uint8Array; reset(position?: number): void; private _grow; /** Append a string, encoded as UTF-8. */ addText(text: string): void; /** Append the contents of another StringBuf without re-encoding. */ addStringBuf(inBuf: StringBuf): void; } export { StringBuf }; export type { StringBufOptions };