UNPKG

@lou.codes/iterables

Version:
23 lines (22 loc) 765 B
import type { IsomorphicIterable } from "@lou.codes/types"; /** * Takes a `separator` string and a iterable or asynchronous iterable and * returns a string with the concatenation of all the elements separated by the * `separator`. * * @category Asynchronous 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: <Separator extends string>( separator: Separator, ) => <Iterable extends IsomorphicIterable>( iterable: Iterable, ) => Iterable extends AsyncIterable<unknown> ? Promise<`${string}${Separator}${string}`> : `${string}${Separator}${string}`;