(input: unknown): booleanChecks 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)Source effect/Predicate.ts:4413 lines
export function function isTruthy(input: unknown): booleanChecks 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)
isTruthy(input: unknowninput: unknown): boolean {
return !!input: unknowninput
}