Skip to main content


Utility functions for Boolean.


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


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'


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


Negates the given boolean.

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


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


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


Alias for inverse.

function not(value: boolean): boolean


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


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


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