/// import { BS } from './bs'; import { Token } from './token'; import { NsResolverMap } from './ns-resolver'; /** * Produces tokens while scanning the input stream. * @public * * @remarks * * Will emit (using `nextToken()`) any of StartTag, EndTag, Text, Comment, CDATA or undefined when the stream chunk is exhauseted (the last full tag was scanned). * On the next write, scanning resumes taking into account any uncomplete tag from the previous chunk. * * @example * Writing the xml in 2 chunks: * * ```javascript * const tokenizer = new Tokenizer() * tokenizer.write('someinn') * while ((token = tokenizer.nextToken())) { * // do something * } * tokenizer.write('ertext') * while ((token = tokenizer.nextToken())) { * // do some more * } * ``` * */ export declare class Tokenizer { private at; private bs; /** carry over partial names or content to next chunk */ private tail; /** tag name of pending start or end tag */ private name; /** name of pending attribute */ private attName; /** list of pending attributes */ private atts; /** list of pending name spaces */ private ns; /** state of tokenizer of previous chunk */ private state; private seenLength; /** namespace resolver */ private nsResolver?; private nsResolverStack; private parentNames; private skippingLevel; private skippingEndTag; constructor(nsResolverMap?: NsResolverMap); /** * Write some bytes to be scanned. * * @param bs - byte sequence as an instance of `BS`, `Buffer` or `string` */ write(bs: BS | string | Buffer | Uint8Array): void; get exhausted(): boolean; /** * Gets the next token * * return `undefined` when fully scanned or last tag was incomplete, waiting for more. */ nextToken(): Token.EndTag | Token.StartTag | Token.Text | Token.CDATA | Token.Comment | undefined; /** * When called, the tokenizer will skip decoding the child nodes of the last tag. * But scanning will resume on its end-tag. This end-tag will not be emitted when called with `true` (`tokenizer.skipChildNodes(true)`) * This is a performance optimization as there's no need to decode text, attribute values... * * @example * Skipping nodes * * ```javascript * tokenizer.write('someinnertext') * const aStart = tokenizer.nextToken() * const bStart = tokenizer.nextToken() * bStart.getAttribute('att') === 'value' * tokenizer.skipChildNodes() * const bEnd = tokenizer.nextToken() * bEnd.toString() === '' * ``` */ skipChildNodes(skippingEndTag?: boolean): void; /** Capuring a name */ private getName; /** Capuring a sequence */ private capture; /** Capuring content ending with a given byte */ private startingContentCapture; /** detecting the possible end of content */ private mayBeEndingContentCapture; /** detecting the actual end of content */ private hasContentCaputreEnded; /** returns the catpure (value) */ private flushCapture; /** returns the content of comment or CDATA */ private flushCaptureContent; /** if skipping this token */ private get isSkipping(); /** creates a StartTag */ private startTag; /** creates an EndTag */ private endTag; /** skipping spaces, ie after names */ private skipSpaceLike; /** testing 'XMLNS' or 'xmlns' sequence */ private isAtXmlns; /** testing 'xmlns' sequence */ private isAt_xmlns; /** testing 'XMLNS' sequence */ private isAt_XMLNS; }