UNPKG

@lou.codes/iterables

Version:
31 lines (30 loc) 895 B
import type { IsomorphicIterable, IsomorphicIterableItem, } from "@lou.codes/types"; /** * Takes a value, iterable or asynchronous iterable and yields it. * * @category Asynchronous Generators * @example * ```typescript * const iterable = toIterable(1); * const iterator = getIterator(iterable); * iterator.next(); // { value: 1, done: false } * iterator.next(); // { value: undefined, done: true } * ``` * @see {@link createIterableIterator} * * @template ValueOrIterable Generic of value or iterable to yield. * @param valueOrIterable Vale or iterable to yield. * @returns Yielded item or iterable. */ export declare const toIterable: <const ValueOrAsyncIterable>( valueOrIterable: ValueOrAsyncIterable, ) => Readonly< AsyncIterableIterator< ValueOrAsyncIterable extends IsomorphicIterable ? IsomorphicIterableItem<ValueOrAsyncIterable> : ValueOrAsyncIterable > >;