Function: minMaxBy()
Returns an iterable containing a MinMax value of iterable
based on
the fn
Compare function if iterable
contains at least one value.
Otherwise, returns an empty iterable.
Example
console.log(
pipe(
[`eating`, `sleeping`, `yawning`],
minMaxBy((a, b) => a.length - b.length),
get,
),
)
//=> { min: 'eating', max: 'sleeping' }
minMaxBy(fn, iterable)
minMaxBy<
Value
>(fn
,iterable
):Iterable
<MinMax
<Value
>,any
,any
>
Returns an iterable containing a MinMax value of iterable
based on
the fn
Compare function if iterable
contains at least one value.
Otherwise, returns an empty iterable.
Type Parameters
• Value
Parameters
• fn: Compare
<Value
>
• iterable: Iterable
<Value
, any
, any
>
Returns
Iterable
<MinMax
<Value
>, any
, any
>
Example
console.log(
pipe(
[`eating`, `sleeping`, `yawning`],
minMaxBy((a, b) => a.length - b.length),
get,
),
)
//=> { min: 'eating', max: 'sleeping' }
Defined in
minMaxBy(fn)
minMaxBy<
Value
>(fn
): (iterable
) =>Iterable
<MinMax
<Value
>,any
,any
>
Returns an iterable containing a MinMax value of iterable
based on
the fn
Compare function if iterable
contains at least one value.
Otherwise, returns an empty iterable.
Type Parameters
• Value
Parameters
• fn: Compare
<Value
>
Returns
Function
Parameters
• iterable: Iterable
<Value
, any
, any
>
Returns
Iterable
<MinMax
<Value
>, any
, any
>
Example
console.log(
pipe(
[`eating`, `sleeping`, `yawning`],
minMaxBy((a, b) => a.length - b.length),
get,
),
)
//=> { min: 'eating', max: 'sleeping' }