"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class NodeStream {
    constructor(nodeList) {
        this.index = 0;
        this.nodes = NodeStream.filterCommentAndBlankNodes(nodeList);
        this.len = this.nodes.length;
    }
    static filterCommentAndBlankNodes(nodeList) {
        const nodes = [];
        for (const node of nodeList) {
            const type = node.type;
            if (type != 'comment' &&
                (type != 'text' || node.text.trim().length > 0)) {
                nodes.push(node);
            }
        }
        return nodes;
    }
    matchNodeName(nodeName) {
        return (this.hasMore() &&
            nodeName.toLowerCase() == this.nodes[this.index].name);
    }
    matchNodeType(nodeType) {
        return this.hasMore() && nodeType == this.nodes[this.index].type;
    }
    consume() {
        return this.nodes[this.index++];
    }
    hasMore() {
        return this.index < this.len;
    }
}
exports.default = NodeStream;
//# sourceMappingURL=NodeStream.js.map