Skip to main content

Variable: first()

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

Defined in: splices.d.ts:469

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

Type Parameters

Value

Value

Parameters

iterable

Iterable<Value>

Returns

Optional<Value>

Example

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

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

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

Since

v0.0.1