effect-io-ai

Package: effect
Module: Predicate

Predicate.isTruthy

Checks whether a value is truthy.

When to use

Use when you want a predicate that mirrors JavaScript truthiness and filters out falsy values like 0, "", and false.

Details

This uses !!input and treats 0, "", false, null, and undefined as false.

Example (Filtering truthy values)

import { Predicate } from "effect"

const values = [0, 1, "", "ok", false]
const truthy = values.filter(Predicate.isTruthy)

console.log(truthy)

See

Signature

declare const isTruthy: (input: unknown) => boolean

Source

Since v2.0.0