UNPKG

@lou.codes/iterables

Version:
31 lines (30 loc) 827 B
import type { IsomorphicIterable, IsomorphicIterableItem, } from "@lou.codes/types"; /** * Takes a value, iterable and yields it. * * @category 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 ValueOrIterable>( valueOrIterable: ValueOrIterable, ) => Readonly< IterableIterator< ValueOrIterable extends IsomorphicIterable ? IsomorphicIterableItem<ValueOrIterable> : ValueOrIterable > >;