@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
19 lines (18 loc) • 589 B
TypeScript
import type { ReadOnlyIterable } from "@lou.codes/types";
/**
* Add the given `separator` between each element of the given iterable.
*
* @category Generators
* @example
* ```typescript
* const intersperseComma = intersperse(",");
* intersperseComma([1, 2, 3]); // [1, ",", 2, ",", 3]
* ```
* @param separator Separator to add between each element.
* @returns Curried function with `separator` in context.
*/
export declare const intersperse: <Separator>(
separator: Separator,
) => <Item>(
iterable: ReadOnlyIterable<Item>,
) => Readonly<IterableIterator<Separator | Item>>;