join
join() function
Returns all elements in the given iterable into a string separated by separator.
Signature:declare function join<A>(sep: string, iterable: Iterable<A>): string;
declare function join<A extends readonly []>(sep: string, iterable: A): "";
declare function join<A>(sep: string, iterable: AsyncIterable<A>): Promise<string>;
declare function join<A extends Iterable<unknown> | AsyncIterable<unknown>>(sep: string): (iterable: A) => ReturnJoinType<A>;
Example
const joined = join('~', ['a', 'b', 'c']); // 'a~b~c'
// with pipe
pipe(
[1, 2, 3, 4],
map(a => a + 10),
filter(a => a % 2 === 0)
join('-'),
); // '12-14'
await pipe(
Promise.resolve([1, 2, 3, 4]),
join('-'),
); // '1-2-3-4'
// with toAsync
await pipe(
[Promise.resolve(1), Promise.resolve(2), Promise.resolve(3), Promise.resolve(4)],
toAsync,
join('-'),
); // '1-2-3-4'