Skip to content

join() function

Returns all elements in the given iterable into a string separated by separator.

Signature:

typescript
declare function join<A extends readonly []>(sep: string, iterable: A): "";

Example

ts
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'

Open Source Code

Released under the Apache-2.0 License.