Skip to content

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

LastReturnValue<A>

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

More examples

Source

packages/core/src/pipe/strict/last.ts:45

Released under the MIT License.