Skip to main content

Boolean

Utility functions for Boolean.

and

Combines two boolean using ANDa && b.

function and(b: boolean): (a: boolean) => boolean
function and(a: boolean, b: boolean): boolean
B.and(true, true) // → true
pipe(true, B.and(false)) // → false

ifElse

Folds a boolean value into a value of a different type, using a function for the true and false cases.

function ifElse<A>(value: boolean, truthyFn: () => A, falsyFn: () => A): A
function ifElse<A>(truthyFn: () => A, falsyFn: () => A): (value: boolean) => A
B.ifElse(true, F.always('ts'), F.always('belt')) // → 'ts'
pipe(false, B.ifElse(F.always('ts'), F.always('belt'))) // → 'belt'

implies

Combines two booleans using an implication (!a || b).

function implies(b: boolean): (a: boolean) => boolean
function implies(a: boolean, b: boolean): boolean
B.implies(false, true) // → true
pipe(true, B.implies(false)) // → false

inverse

Negates the given boolean.

function inverse(value: boolean): boolean
B.inverse(false) // → true
pipe(true, B.inverse) // → false

nand

Combines two booleans using NAND!(a && b).

function nand(b: boolean): (a: boolean) => boolean
function nand(a: boolean, b: boolean): boolean
B.nand(true, false) // → true
pipe(false, B.nand(false)) // → true

nor

Combines two booleans using NOR!(a || b).

function nor(b: boolean): (a: boolean) => boolean
function nor(a: boolean, b: boolean): boolean
B.nor(true, false) // → false
pipe(false, B.nor(false)) // → true

not

Alias for inverse.

function not(value: boolean): boolean

or

Combines two boolean using ORa || b.

function or(b: boolean): (a: boolean) => boolean
function or(a: boolean, b: boolean): boolean
B.or(true, false) // → true
pipe(false, B.or(false)) // → false

xnor

Combines two booleans using XNOR!xor(a, b).

function xnor(b: boolean): (a: boolean) => boolean
function xnor(a: boolean, b: boolean): boolean
B.xnor(true, false) // → false
pipe(false, B.xnor(false)) // → true

xor

Combines two booleans using XOR(!a && b) || (a && !b).

function xor(b: boolean): (a: boolean) => boolean
function xor(a: boolean, b: boolean): boolean
B.xor(true, false) // → true
pipe(false, B.xor(false)) // → false