UNPKG

@drorgl/xml-streamer

Version:

XML stream parser for parsing large files efficiently with less usage of memory.

62 lines (61 loc) 2.14 kB
/// <reference types="node" /> import stream from "stream"; import { ParserState } from "./parserState"; export interface IXmlParserOptions { /** * Optional field. Used to extract the XML nodes that you are interested in. * * @type {string} * @memberof IXmlParserOptions */ resourcePath?: string; /** * Optional field. Set this to true if you want to listen on node names instead of data event. default: false * * @type {boolean} * @memberof IXmlParserOptions */ emitOnNodeName?: boolean; /** * Optional field. pass the value with which you want to reference attributes of a node in its object form. default: '$' * * @type {string} * @memberof IXmlParserOptions */ attrsKey?: string; /** * Optional field. pass the value with which you want to reference node value in its object form. default: '_' * * @type {string} * @memberof IXmlParserOptions */ textKey?: string; /** * Optional field. Default value is true. All children nodes will come in an array when this option is true. * * @type {boolean} * @memberof IXmlParserOptions */ explicitArray?: boolean; /** * Optional field. Default value is false. When set, text attribute will include all blanks found in xml. * When unset, blanks are removed as long as they come in one expat single block (blank lines, newlines and entities). * * @type {boolean} * @memberof IXmlParserOptions */ verbatimText?: boolean; preserveWhitespace?: boolean; } export declare class XmlParser extends stream.Transform { parserState: ParserState; private opts; private _readableState; private parser; constructor(opts?: IXmlParserOptions); _flush(callback: () => void): void; _transform(chunk: Buffer | string, encoding: string, callback: () => void): void; parse(chunk: Buffer | string, cb: (error: Error, data?: Buffer) => void): void; private processChunk; private checkForInterestedNodeListeners; }