Skip to main content

Variable: minMaxByAsync()

const minMaxByAsync: {<Value>(fn, asyncIterable): AsyncOptional<MinMax<Value>>; <Value>(fn): (asyncIterable) => AsyncOptional<MinMax<Value>>; }

Defined in: statistics.d.ts:614

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.

Call Signature​

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

Type Parameters​

Value​

Value

Parameters​

fn​

AsyncCompare<Value>

asyncIterable​

AsyncIterable<Value>

Returns​

AsyncOptional<MinMax<Value>>

Call Signature​

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

Type Parameters​

Value​

Value

Parameters​

fn​

AsyncCompare<Value>

Returns​

(asyncIterable): AsyncOptional<MinMax<Value>>

Parameters​

asyncIterable​

AsyncIterable<Value>

Returns​

AsyncOptional<MinMax<Value>>

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