Skip to main content

Variable: last()

const last: <Value>(iterable) => Optional<Value>

Defined in: splices.d.ts:564

Returns an iterable containing the last value of iterable, or an empty iterable if iterable is empty.

Type Parameters

Value

Value

Parameters

iterable

Iterable<Value>

Returns

Optional<Value>

Example

import { last, or, pipe } from 'lfi'

console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
last,
or(() => `empty`),
),
)
//=> sleep

console.log(
pipe(
[],
last,
or(() => `empty`),
),
)
//=> empty
Playground

Since

v0.0.1