Variable: atAsync()
const
atAsync: {<Index
>(index
): <Value
>(asyncIterable
) =>AsyncOptional
<Value
>; <Index
,Value
>(index
,asyncIterable
):AsyncOptional
<Value
>; }
Defined in: splices.d.ts:807
Returns an async iterable containing the value at the given index
of
asyncIterable
or an empty async iterable if index
is out of bounds.
WARNING: This function linearly iterates up to index
because async
iterables do not support random access.
Call Signature
<
Index
>(index
): <Value
>(asyncIterable
) =>AsyncOptional
<Value
>
Type Parameters
Index
Index
extends number
Parameters
index
NonNegativeInteger
<Index
>
Returns
<
Value
>(asyncIterable
):AsyncOptional
<Value
>
Type Parameters
Value
Value
Parameters
asyncIterable
AsyncIterable
<Value
>
Returns
AsyncOptional
<Value
>
Call Signature
<
Index
,Value
>(index
,asyncIterable
):AsyncOptional
<Value
>
Type Parameters
Index
Index
extends number
Value
Value
Parameters
index
NonNegativeInteger
<Index
>
asyncIterable
AsyncIterable
<Value
>
Returns
AsyncOptional
<Value
>
Throws
if index
is not a non-negative integer.
Example
const asyncIterable = asAsync([`sloth`, `more sloth`, `even more sloth`])
console.log(
await pipe(
asyncIterable,
atAsync(1),
getAsync,
),
)
//=> 'more sloth'
Since
v3.5.0