@rimbu/common
Version:
Common types and objects used in many other Rimbu packages
33 lines • 1.09 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.TraverseState = void 0;
var TraverseStateImpl = /** @class */ (function () {
function TraverseStateImpl(startIndex) {
var _this = this;
this.startIndex = startIndex;
this.halted = false;
this.halt = function () {
_this.halted = true;
};
this.currentIndex = startIndex;
}
TraverseStateImpl.prototype.nextIndex = function () {
return this.currentIndex++;
};
TraverseStateImpl.prototype.reset = function () {
this.currentIndex = this.startIndex;
this.halted = false;
};
return TraverseStateImpl;
}());
/**
* Returns a new `TraverseState` instance, using optionally given `startIndex` as a start
* index value.
* @param startIndex - (default: 0) the start index to use
*/
function TraverseState(startIndex) {
if (startIndex === void 0) { startIndex = 0; }
return new TraverseStateImpl(startIndex);
}
exports.TraverseState = TraverseState;
//# sourceMappingURL=traverse-state.cjs.map
;