/** * XmlStreamParser.ts * ─────────────────── * A Node.js Transform stream that accepts UTF-8 XML bytes in arbitrary * chunks and emits a parsed `XmlDocument` once the full document has * been buffered. * * Design * ────── * XML is not a line-delimited format — a single element can span many * chunks, so we cannot parse incrementally without a full SAX engine. * Instead we buffer all incoming chunks (memory-efficient for files up * to ~500 MB on a typical server) and parse once the stream ends. * * For truly huge files (> available RAM) callers should use the async * `readXmlFile` API together with OS-level file streaming. * * Events emitted by XmlStreamParser * ─────────────────────────────────── * 'document' (doc: XmlDocument) – emitted once, on stream end * 'error' (err: Error) – emitted on parse failure * * Usage (pipe) * ──────────── * import { createReadStream } from 'fs'; * import { XmlStreamParser } from 'xml-xsd-engine/stream'; * * const parser = new XmlStreamParser(); * parser.on('document', doc => console.log(doc.root?.tagName)); * createReadStream('large.xml').pipe(parser); * * Usage (async iterator) * ────────────────────── * const doc = await parseXmlStream(createReadStream('large.xml')); */ import { Transform, TransformCallback, Readable } from 'stream'; import { XmlDocument } from '../parser/XmlNodes'; export declare class XmlStreamParser extends Transform { private _chunks; constructor(); _transform(chunk: Buffer | string, _encoding: BufferEncoding, callback: TransformCallback): void; _flush(callback: TransformCallback): void; } /** * Parse an XML Readable stream and return a Promise. * * ```ts * import { createReadStream } from 'fs'; * import { parseXmlStream } from 'xml-xsd-engine/stream'; * * const doc = await parseXmlStream(createReadStream('data.xml')); * ``` */ export declare function parseXmlStream(source: Readable): Promise; /** * Stream a large XML file from disk and return a Promise. * Uses `fs.createReadStream` internally. */ export declare function parseXmlFileStream(filePath: string): Promise; //# sourceMappingURL=XmlStreamParser.d.ts.map