UNPKG

@lou.codes/iterables

Version:
19 lines (18 loc) 541 B
import type { IsomorphicIterable, Numeric } from "@lou.codes/types"; /** * Take the given amount of items from the iterable or asynchronous iterable. * * @category Asynchronous Generators * @example * ```typescript * const take2 = take(2); * take2([1, 2, 3, 4, 5]); // [1, 2] * ``` * @param amount Amount of items to take. * @returns Curried function with `amount` in context. */ export declare const take: ( amount: Numeric, ) => <Item>( iterable: IsomorphicIterable<Item>, ) => Readonly<AsyncIterableIterator<Awaited<Item>>>;