@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
20 lines (19 loc) • 659 B
TypeScript
import type { ReadOnlyIterable, Strigifiable } from "@lou.codes/types";
/**
* Takes a `separator` string and a iterable and returns a string with the
* concatenation of all the elements separated by the `separator`.
*
* @category Reducers
* @example
* ```typescript
* const joinWithSpaces = join(" ");
* joinWithSpaces([1, 2, 3]); // "1 2 3"
* ```
* @param separator String to use as separator.
* @returns Curried function with `separator` in context.
*/
export declare const join: <const Separator extends string>(
separator: Separator,
) => <Item extends Strigifiable>(
iterable: ReadOnlyIterable<Item>,
) => `${string}${Separator}${string}`;