Hyperlinkv0.8.0-beta.28

Predicate

Predicate.isTruthyfunctioneffect/Predicate.ts:441
(input: unknown): boolean

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)
export function isTruthy(input: unknown): boolean {
  return !!input
}