@rimbu/common
Version:
Common types and objects used in many other Rimbu packages
26 lines • 708 B
JavaScript
class TraverseStateImpl {
constructor(startIndex) {
this.startIndex = startIndex;
this.halted = false;
this.halt = () => {
this.halted = true;
};
this.currentIndex = startIndex;
}
nextIndex() {
return this.currentIndex++;
}
reset() {
this.currentIndex = this.startIndex;
this.halted = false;
}
}
/**
* Returns a new `TraverseState` instance, using optionally given `startIndex` as a start
* index value.
* @param startIndex - (default: 0) the start index to use
*/
export function TraverseState(startIndex = 0) {
return new TraverseStateImpl(startIndex);
}
//# sourceMappingURL=traverse-state.mjs.map