Skip to main content

Function: always()

always<T>(): Predicate<T>

Defined in: predicate/combinators/index.ts:201

Creates a predicate that always returns true.

Useful as a default or fallback predicate.

Type Parameters

T

T

Returns

Predicate<T>

A predicate that always returns true

Example

import * as R from 'remeda'
import { always } from 'receta/predicate'

// Keep all items
R.filter([1, 2, 3], always()) // => [1, 2, 3]

// Real-world: Default case in conditional filtering
const shouldFilter = Math.random() > 0.5
const predicate = shouldFilter ? (n: number) => n > 5 : always<number>()
R.filter([1, 5, 10], predicate)

See

never - for a predicate that always returns false