Variable: indexAsync()
const
indexAsync: <Value
>(asyncIterable
) =>AsyncIterable
<[number
,Value
]>
Defined in: transforms.d.ts:383
Returns an async iterable equivalent to asyncIterable
except each value of
asyncIterable
is placed in an entry containing the value's 0-based index in
the iteration order followed by the value itself.
Type Parameters
Value
Value
Parameters
asyncIterable
AsyncIterable
<Value
>
Returns
AsyncIterable
<[number
, Value
]>
Example
console.log(
await pipe(
asAsync([`sloth`, `more sloth`, `even more sloth`]),
indexAsync,
reduceAsync(toArray()),
),
)
//=> [ [ 0, 'sloth' ], [ 1, 'more sloth' ], [ 2, 'even more sloth' ] ]
Since
v2.0.0