import type { Asyncable, Asyncerator } from '../asyncerator.ts'; export type SourceIterator = Iterator | AsyncIterator; export interface AcquiredIterator { iterator: SourceIterator; isSynchronous: boolean; } /** * Acquire the underlying iterator without advancing or wrapping it. * Prefer the async iterable protocol over the sync protocol, calling the selected * method once with the source as its receiver. Bare iterators are treated as async. * Keeping the original iterator identity lets callers share adapters and cleanup. * * @param source The iterable or iterator to acquire. * @returns The underlying iterator and whether it uses the synchronous protocol. */ export declare function acquireIterator(source: Asyncable | (() => Asyncerator)): AcquiredIterator; /** * Adapt an acquired iterator for use with `for await...of`. * For async sources, return an existing async iterable iterator unchanged. * Otherwise, wrap iteration and forward cancellation, sharing one cleanup operation * across return() and throw() calls. The wrapper awaits synchronous cleanup values * and preserves the original iteration error if cleanup also fails. * * @returns The existing async iterable iterator or an adapter around it. */ export declare function adaptIterator({ iterator, isSynchronous, }: AcquiredIterator): AsyncIterableIterator;