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
import { map, pipe, reduce, toGrouped, toJoin, toMap } from 'lfi'
console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
map(word => [word.length, word]),
reduce(toGrouped(toJoin(`,`), toMap())),
),
)
//=> Map(2) {
//=> 5 => 'sloth,sleep',
//=> 4 => 'lazy'
//=> }
Since
v2.0.0