Skip to main content

Function: minMaxByAsync()

Returns an async iterable containing a MinMax value of asyncIterable based on the fn AsyncCompare function if asyncIterable contains at least one value. Otherwise, returns an empty async iterable.

Example

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

Since

v0.0.2

Call Signature

minMaxByAsync<Value>(fn, asyncIterable): AsyncOptional<MinMax<Value>>

Type Parameters

Value

Parameters

fn

AsyncCompare<Value>

asyncIterable

AsyncIterable<Value, any, any>

Returns

AsyncOptional<MinMax<Value>>

Defined in

statistics.d.ts:615

Call Signature

minMaxByAsync<Value>(fn): (asyncIterable) => AsyncOptional<MinMax<Value>>

Type Parameters

Value

Parameters

fn

AsyncCompare<Value>

Returns

Function

Parameters

asyncIterable

AsyncIterable<Value, any, any>

Returns

AsyncOptional<MinMax<Value>>

Defined in

statistics.d.ts:619