Skip to main content

Variable: minMaxBy()

const minMaxBy: {<Value>(fn, iterable): Optional<MinMax<Value>>; <Value>(fn): (iterable) => Optional<MinMax<Value>>; }

Defined in: statistics.d.ts:569

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.

Call Signature

<Value>(fn, iterable): Optional<MinMax<Value>>

Type Parameters

Value

Value

Parameters

fn

Compare<Value>

iterable

Iterable<Value>

Returns

Optional<MinMax<Value>>

Call Signature

<Value>(fn): (iterable) => Optional<MinMax<Value>>

Type Parameters

Value

Value

Parameters

fn

Compare<Value>

Returns

(iterable): Optional<MinMax<Value>>

Parameters

iterable

Iterable<Value>

Returns

Optional<MinMax<Value>>

Example

console.log(
pipe(
[`eating`, `sleeping`, `yawning`],
minMaxBy((a, b) => a.length - b.length),
get,
),
)
//=> { min: 'eating', max: 'sleeping' }

Since

v0.0.2