fx-flow v0.7.0 / pipe/strict / last
Function: last()
last<
A
>(iterable
):LastReturnValue
<A
>
Return the last element of iterable/asyncIterable
Type parameters
• A extends UniversalIterable
Parameters
• iterable: A
Returns
Example
typescript
last([1, 2, 3, 4, 5]); // 5
// with pipe
pipe(
[1, 2, 3, 4, 5],
last,
); // 5
await pipe(
Promise.resolve([1, 2, 3, 4, 5]),
last,
); // 5
// with toAsync
await pipe(
[Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)],
toAsync,
last,
); // 3