Function: uniqueBy()
Returns an iterable containing the values of iterable
in iteration order,
except values for which fn
returns the same value are deduplicated.
When values are deduplicated, the value earlier in iteration order wins.
Example
import { pipe, reduce, toArray, uniqueBy } from 'lfi'
console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
uniqueBy(word => word.length),
reduce(toArray()),
),
)
//=> [ 'sloth', 'lazy' ]
Since
v0.0.1
Call Signature
uniqueBy<
Value
>(fn
): (iterable
) =>Iterable
<Value
,any
,any
>
Type Parameters
• Value
Parameters
fn
(value
) => unknown
Returns
Function
Parameters
iterable
Iterable
<Value
, any
, any
>
Returns
Iterable
<Value
, any
, any
>
Defined in
Call Signature
uniqueBy<
Value
>(fn
,iterable
):Iterable
<Value
,any
,any
>
Type Parameters
• Value
Parameters
fn
(value
) => unknown
iterable
Iterable
<Value
, any
, any
>
Returns
Iterable
<Value
, any
, any
>