UNPKG

@rimbu/common

Version:

Common types and objects used in many other Rimbu packages

34 lines (33 loc) 945 B
/** * An object used to track the state of a traversal, e.g. a `forEach`. */ export interface TraverseState { /** * Returns true if the traversal has been halted by the user. */ readonly halted: boolean; /** * Returns the current index of the traversal. */ readonly currentIndex: number; /** * Increases the `currentIndex` of this traversal * @returns the next index that the traversal should use */ nextIndex(): number; /** * Sets the `halted` value to true. */ halt(): void; /** * Sets the `halted` value to false, and resets the `currentIndex` * value to its start value. */ reset(): void; } /** * Returns a new `TraverseState` instance, using optionally given `startIndex` as a start * index value. * @param startIndex - (default: 0) the start index to use */ export declare function TraverseState(startIndex?: number): TraverseState;