Bool
constBool:object
Defined in: Data/Bool.ts:85
Type Declaration
Section titled “Type Declaration”all: (
booleans) =>boolean
N-ary AND aggregation across an array of booleans.
Returns true if every boolean is true, or for an empty array (vacuous truth).
Short-circuits on the first false.
Parameters
Section titled “Parameters”booleans
Section titled “booleans”readonly boolean[]
Returns
Section titled “Returns”boolean
Example
Section titled “Example”and: (
that) => (self) =>boolean
Logical AND combinator. Returns true only if both self and that are true.
Data-last: pipe(self, Bool.and(that)).
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”(self) => boolean
Example
Section titled “Example”andLazy
Section titled “andLazy”andLazy: (
that) => (self) =>boolean
Lazy logical AND combinator.
If self is false, the that computation is never evaluated.
Data-last: pipe(self, Bool.andLazy(that)).
Parameters
Section titled “Parameters”() => boolean
Returns
Section titled “Returns”(self) => boolean
Example
Section titled “Example”any: (
booleans) =>boolean
N-ary OR aggregation across an array of booleans.
Returns true if at least one boolean is true. Returns false for an empty array.
Short-circuits on the first true.
Parameters
Section titled “Parameters”booleans
Section titled “booleans”readonly boolean[]
Returns
Section titled “Returns”boolean
Example
Section titled “Example”fold: <
A,B>(onFalse,onTrue) => (b) =>A|B
Catamorphism for boolean: evaluates onFalse() when false and onTrue() when true.
Positional ordering: onFalse first, onTrue second.
Aligned with Result.fold(onErr, onOk) and Maybe.fold(onNone, onSome).
Type Parameters
Section titled “Type Parameters”A
B
Parameters
Section titled “Parameters”onFalse
Section titled “onFalse”() => A
onTrue
Section titled “onTrue”() => B
Returns
Section titled “Returns”(b) => A | B
Example
Section titled “Example”from:
object
from.number
Section titled “from.number”number: (
n) =>Maybe<boolean> =fromNumber
Converts a number into a Maybe<boolean>.
Returns Some(true) for 1, Some(false) for 0, and None for any other number.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Maybe<boolean>
Example
Section titled “Example”from.string
Section titled “from.string”string: (
s) =>Maybe<boolean> =fromString
Parses a string into a Maybe<boolean>.
Returns Some(true) for "true", Some(false) for "false" (case-insensitive & trimmed),
and None for any other string.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Maybe<boolean>
Example
Section titled “Example”from.truthy
Section titled “from.truthy”truthy: (
value) =>boolean=fromTruthy
Coerces any unknown value into a boolean via standard JS Boolean(value).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Example
Section titled “Example”is:
object
is.boolean
Section titled “is.boolean”boolean: (
u) =>u is boolean=isBoolean
Type guard — checks if a value is a primitive boolean.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”u is boolean
Example
Section titled “Example”is.false
Section titled “is.false”false: (
u) =>u is false=isFalse
Narrowing guard — checks if a value is strictly false.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”u is false
Example
Section titled “Example”is.falsy
Section titled “is.falsy”falsy: (
u) => u is false | “” | 0 | 0n | null | undefined =isFalsy
Type guard — checks if a value is falsy (false, 0, 0n, "", null, undefined, or NaN).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”u is false | “” | 0 | 0n | null | undefined
Example
Section titled “Example”is.true
Section titled “is.true”true: (
u) =>u is true=isTrue
Narrowing guard — checks if a value is strictly true.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”u is true
Example
Section titled “Example”is.truthy
Section titled “is.truthy”truthy: <
T>(u) => u is Exclude<T, false | “” | 0 | 0n | null | undefined> =isTruthy
Type guard — checks if a value is truthy (not false, 0, 0n, "", null, undefined, or NaN).
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”u is Exclude<T, false | “” | 0 | 0n | null | undefined>
Example
Section titled “Example”match: <
A,B>(cases) => (b) =>A|B
Pattern matching on boolean using named cases { true, false }.
Type Parameters
Section titled “Type Parameters”A
B
Parameters
Section titled “Parameters”BoolMatchCases<A, B>
Returns
Section titled “Returns”(b) => A | B
Example
Section titled “Example”not: (
b) =>boolean
Unary boolean negation: inverts the given boolean value.
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”boolean
Example
Section titled “Example”or: (
that) => (self) =>boolean
Logical OR combinator. Returns true if either self or that is true.
Data-last: pipe(self, Bool.or(that)).
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”(self) => boolean
Example
Section titled “Example”orLazy
Section titled “orLazy”orLazy: (
that) => (self) =>boolean
Lazy logical OR combinator.
If self is true, the that computation is never evaluated.
Data-last: pipe(self, Bool.orLazy(that)).
Parameters
Section titled “Parameters”() => boolean
Returns
Section titled “Returns”(self) => boolean
Example
Section titled “Example”to:
object
to.Maybe
Section titled “to.Maybe”Maybe: <
A>(onTrue) => (b) =>Maybe<A> =toMaybe
Lifts a boolean condition into a Maybe.
Returns Some(onTrue()) when true, and None when false.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”onTrue
Section titled “onTrue”() => A
Returns
Section titled “Returns”(b) => Maybe<A>
Example
Section titled “Example”to.number
Section titled “to.number”number: (
b) =>0|1=toNumber
Converts a boolean to numeric 1 or 0.
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”0 | 1
Example
Section titled “Example”to.Result
Section titled “to.Result”Result: <
E,A>(onErr,onOk) => (b) =>Result<E,A> =toResult
Lifts a boolean condition into a Result.
Returns Ok(onOk()) when true, and Err(onErr()) when false.
Type Parameters
Section titled “Type Parameters”E
A
Parameters
Section titled “Parameters”() => E
() => A
Returns
Section titled “Returns”(b) => Result<E, A>
Example
Section titled “Example”to.string
Section titled “to.string”string: (
b) =>"false"|"true"=toString
Converts a boolean to literal string "true" or "false".
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”"false" | "true"
Example
Section titled “Example”xor: (
that) => (self) =>boolean
Logical XOR (exclusive OR) combinator. Returns true if exactly one of self and that is true.
Data-last: pipe(self, Bool.xor(that)).
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”(self) => boolean