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