import { NodeDB } from "../storage/node-db.js"; //#region src/iterator/fast-iterator.d.ts /** * Error thrown when FastIterator is created with null NodeDB */ declare class ErrFastIteratorNilNdbGiven extends Error { constructor(); } /** * FastIterator implements iteration over fast nodes in a database. * It provides O(1) sequential access to keys in the latest tree version. * * Based on Go IAVL v1.3.5 fast_iterator.go (lines 13-136) */ declare class FastIterator { private start; private end; private valid; private ascending; private err; private ndb; private nextFastNode; private fastIterator; private fastIteratorPromise; /** * Creates a new FastIterator. * * Note: The constructor does NOT initialize the iterator. Use the static create() method * for proper async initialization, or manually call nextAsync() after construction. * * @param start - Start key (inclusive), null for beginning * @param end - End key (exclusive), null for end * @param ascending - True for forward iteration, false for reverse * @param ndb - NodeDB to iterate over * @private Use FastIterator.create() instead */ private constructor(); /** * Creates and initializes a new FastIterator. * * This is the recommended way to create a FastIterator as it properly handles * async database initialization. * * @param start - Start key (inclusive), null for beginning * @param end - End key (exclusive), null for end * @param ascending - True for forward iteration, false for reverse * @param ndb - NodeDB to iterate over * @returns Promise resolving to initialized FastIterator */ static create(start: Uint8Array | null, end: Uint8Array | null, ascending: boolean, ndb: NodeDB | null): Promise; /** * Domain returns the start and end keys of the iterator. * Maps the underlying nodedb iterator domain to the 'logical' keys involved. * * Based on Go IAVL fast_iterator.go lines 49-73 * * @returns Tuple of [start, end] keys */ domain(): [Uint8Array | null, Uint8Array | null]; /** * Valid returns true if the iterator is positioned at a valid element. * * Based on Go IAVL fast_iterator.go lines 75-78 * * @returns True if iterator has a valid current element */ isValid(): boolean; /** * Key returns the key of the current element. * * Based on Go IAVL fast_iterator.go lines 80-86 * * @returns Current key, or null if invalid */ key(): Uint8Array | null; /** * Value returns the value of the current element. * * Based on Go IAVL fast_iterator.go lines 88-94 * * @returns Current value, or null if invalid */ value(): Uint8Array | null; /** * Next advances the iterator to the next element. * * IMPORTANT: In async database implementations (CrossKvDB), the first call to next() * will initialize the underlying iterator asynchronously. The iterator won't be valid * until the promise resolves. Call nextAsync() for proper async handling, or ensure * the iterator is pre-initialized. * * Based on Go IAVL fast_iterator.go lines 96-120 */ next(): void; /** * Async version of next() that properly waits for iterator initialization. * Use this for async database implementations. */ nextAsync(): Promise; /** * Updates the iterator state based on the current fast iterator position. * @private */ private updateState; /** * Close releases resources held by the iterator. * * Based on Go IAVL fast_iterator.go lines 122-130 */ close(): void; /** * Error returns any error that occurred during iteration. * * Based on Go IAVL fast_iterator.go lines 132-135 * * @returns Error if any, null otherwise */ error(): Error | null; } //#endregion export { ErrFastIteratorNilNdbGiven, FastIterator }; //# sourceMappingURL=fast-iterator.d.ts.map