/** * This is the same as TypeScript's `Iterable`, but with all three type parameters. * @todo Remove once TypeScript 5.6 is the minimum. */ export interface Iterable { [Symbol.iterator](): Iterator } /** * This is the same as TypeScript's `AsyncIterable`, but with all three type parameters. * @todo Remove once TypeScript 5.6 is the minimum. */ export interface AsyncIterable { [Symbol.asyncIterator](): AsyncIterator } /** * Determines if the given function is an iterator. */ export function isIterable( fn: any, ): fn is | Iterable | AsyncIterable { if (!fn) { return false } return ( Reflect.has(fn, Symbol.iterator) || Reflect.has(fn, Symbol.asyncIterator) ) }