@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
18 lines (17 loc) • 511 B
TypeScript
import type { Numeric } from "@lou.codes/types";
/**
* Repeat given item the specified amount of times (can be `BigInt` or
* `Infinity` times) as an iterable.
*
* @category Generators
* @example
* ```typescript
* const repeat3Times = repeat(3);
* repeat3Times("foo"); // ["foo", "foo", "foo"]
* ```
* @param item Item to repeat.
* @returns Curried function with `item` in context.
*/
export declare const repeat: (
times: Numeric,
) => <const Item>(item: Item) => Readonly<IterableIterator<Item>>;