Function: toJoin()
toJoin(
separator
):Reducer
<unknown
,unknown
,string
>
Returns a Reducer that concatenates values to a string where values
are separated by separator
.
Joins like Array.prototype.join
, but does not treat null
, undefined
,
or []
specially.
Use when composing reducers. Prefer join, joinAsync, and joinConcur for direct use on iterables.
Parameters
• separator: string
Returns
Reducer
<unknown
, unknown
, string
>
Example
console.log(
pipe(
[`sloth`, `more sloth`, `sleep`, `some sloth`],
map(string => [string.length, string]),
reduce(toGrouped(toJoin(`,`), toMap())),
),
)
//=> Map(2) { 5 => 'sloth,sleep', 10 => 'more sloth,some sloth' }