Skip to main content

Function: findLast()

Returns an iterable containing the last value of iterable for which fn returns a truthy value. Otherwise, returns an empty iterable.

Example

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

console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
findLast(word => word.includes(`s`)),
or(() => `not found!`),
),
)
//=> sleep

console.log(
pipe(
[`sloth`, `lazy`, `sleep`],
findLast(word => word.includes(`x`)),
or(() => `not found!`),
),
)
//=> not found!
Playground

Since

v0.0.1

Call Signature

findLast<Value>(fn): (iterable) => Optional<Value>

Type Parameters

Value

Parameters

fn

(value) => unknown

Returns

Function

Parameters

iterable

Iterable<Value, any, any>

Returns

Optional<Value>

Defined in

filters.d.ts:796

Call Signature

findLast<Value>(fn, iterable): Optional<Value>

Type Parameters

Value

Parameters

fn

(value) => unknown

iterable

Iterable<Value, any, any>

Returns

Optional<Value>

Defined in

filters.d.ts:796