Skip to main content

Variable: findLast

const findLast: Find

Defined in: filters.d.ts:796

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