"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.walk = exports.walk0 = void 0;
const iterator_1 = require("../util/iterator");
const walk0 = (node) => {
    const stack = [node];
    return () => {
        const node = stack.pop();
        if (!node)
            return;
        if (typeof node === 'string')
            return node;
        for (let i = node.length - 1; i >= 2; i--)
            stack.push(node[i]);
        return node;
    };
};
exports.walk0 = walk0;
const walk = (node) => new iterator_1.UndEndIterator((0, exports.walk0)(node));
exports.walk = walk;
//# sourceMappingURL=walk.js.map