effect-io-ai

Package: effect
Module: Boolean

Boolean.match

This function returns the result of either of the given functions depending on the value of the boolean parameter. It is useful when you have to run one of two functions depending on the boolean value.

Example

import * as assert from "node:assert"
import { Boolean } from "effect"

assert.deepStrictEqual(Boolean.match(true, { onFalse: () => "It's false!", onTrue: () => "It's true!" }), "It's true!")

Signature

declare const match: { <A, B = A>(options: { readonly onFalse: LazyArg<A>; readonly onTrue: LazyArg<B>; }): (value: boolean) => A | B; <A, B>(value: boolean, options: { readonly onFalse: LazyArg<A>; readonly onTrue: LazyArg<B>; }): A | B; }

Source

Since v2.0.0