Function: maxByAsync()
Returns an async iterable containing a maximum 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`]),
maxByAsync((a, b) => a.length - b.length),
getAsync,
),
)
//=> sleeping
maxByAsync(fn, asyncIterable)
maxByAsync<
Value
>(fn
,asyncIterable
):AsyncIterable
<Value
,any
,any
>
Returns an async iterable containing a maximum value of asyncIterable
based
on the fn
AsyncCompare function if asyncIterable
contains at
least one value. Otherwise, returns an empty async iterable.
Type Parameters
• Value
Parameters
• fn: AsyncCompare
<Value
>
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncIterable
<Value
, any
, any
>
Example
console.log(
await pipe(
asAsync([`eating`, `sleeping`, `yawning`]),
maxByAsync((a, b) => a.length - b.length),
getAsync,
),
)
//=> sleeping
Defined in
maxByAsync(fn)
maxByAsync<
Value
>(fn
): (asyncIterable
) =>AsyncIterable
<Value
,any
,any
>
Returns an async iterable containing a maximum value of asyncIterable
based
on the fn
AsyncCompare function if asyncIterable
contains at
least one value. Otherwise, returns an empty async iterable.
Type Parameters
• Value
Parameters
• fn: AsyncCompare
<Value
>
Returns
Function
Parameters
• asyncIterable: AsyncIterable
<Value
, any
, any
>
Returns
AsyncIterable
<Value
, any
, any
>
Example
console.log(
await pipe(
asAsync([`eating`, `sleeping`, `yawning`]),
maxByAsync((a, b) => a.length - b.length),
getAsync,
),
)
//=> sleeping