UNPKG

@lou.codes/iterables

Version:
20 lines (19 loc) 659 B
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}`;