Bool
constBool:object
Defined in: Data/Bool.ts:81
Type Declaration
Section titled “Type Declaration”all: (
conditions) =>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”conditions
Section titled “conditions”readonly boolean[]
Returns
Section titled “Returns”boolean
Bool.any to check if at least one boolean is true.
Example
Section titled “Example”and: (
that) => (condition) =>boolean
Logical AND combinator. Returns true only if both condition and that are true.
Data-last: pipe(condition, Bool.and(that)).
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”(condition) => boolean
- Bool.or for logical OR combinator.
- Bool.andLazy for short-circuiting lazy evaluation.
Example
Section titled “Example”andLazy
Section titled “andLazy”andLazy: (
that) => (condition) =>boolean
Lazy logical AND combinator.
If condition is false, the that computation is never evaluated.
Data-last: pipe(condition, Bool.andLazy(that)).
Parameters
Section titled “Parameters”() => boolean
Returns
Section titled “Returns”(condition) => boolean
- Bool.orLazy for lazy logical OR combinator.
- Bool.and for strict logical AND evaluation.
Example
Section titled “Example”any: (
conditions) =>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”conditions
Section titled “conditions”readonly boolean[]
Returns
Section titled “Returns”boolean
Bool.all to check if all booleans are true.
Example
Section titled “Example”from:
object
Parsers and converters from external values to boolean.
from.number
Section titled “from.number”number: (
value) =>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: (
text) =>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
Predicates and type guards for boolean values.
is.boolean
Section titled “is.boolean”boolean: (
value) =>value is boolean=isBoolean
Type guard — checks if a value is a primitive boolean.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”value is boolean
Example
Section titled “Example”is.false
Section titled “is.false”false: (
value) =>value is false=isFalse
Narrowing guard — checks if a value is strictly false.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”value is false
Bool.is.true to check if a value is strictly true.
Example
Section titled “Example”is.falsy
Section titled “is.falsy”falsy: (
value) => value 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”value is false | “” | 0 | 0n | null | undefined
Bool.is.truthy to check if a value is truthy.
Example
Section titled “Example”is.true
Section titled “is.true”true: (
value) =>value is true=isTrue
Narrowing guard — checks if a value is strictly true.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”value is true
Bool.is.false to check if a value is strictly false.
Example
Section titled “Example”is.truthy
Section titled “is.truthy”truthy: <
T>(value) => value 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”value is Exclude<T, false | “” | 0 | 0n | null | undefined>
Bool.is.falsy to check if a value is falsy.
Example
Section titled “Example”match: <
A,B>(cases) => (condition) =>A|B
Pattern matching on boolean using named cases { true, false }.
Type Parameters
Section titled “Type Parameters”A
B
Parameters
Section titled “Parameters”() => B
() => A
Returns
Section titled “Returns”(condition) => A | B
Example
Section titled “Example”not: (
condition) =>boolean
Unary boolean negation: inverts the given boolean value.
Parameters
Section titled “Parameters”condition
Section titled “condition”boolean
Returns
Section titled “Returns”boolean
Example
Section titled “Example”or: (
that) => (condition) =>boolean
Logical OR combinator. Returns true if either condition or that is true.
Data-last: pipe(condition, Bool.or(that)).
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”(condition) => boolean
- Bool.and for logical AND combinator.
- Bool.orLazy for short-circuiting lazy evaluation.
Example
Section titled “Example”orLazy
Section titled “orLazy”orLazy: (
that) => (condition) =>boolean
Lazy logical OR combinator.
If condition is true, the that computation is never evaluated.
Data-last: pipe(condition, Bool.orLazy(that)).
Parameters
Section titled “Parameters”() => boolean
Returns
Section titled “Returns”(condition) => boolean
- Bool.andLazy for lazy logical AND combinator.
- Bool.or for strict logical OR evaluation.
Example
Section titled “Example”to:
object
Converters from boolean conditions into strings, Maybe, or Result.
to.Maybe
Section titled “to.Maybe”Maybe: <
A>(onTrue) => (condition) =>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”(condition) => Maybe<A>
Example
Section titled “Example”to.number
Section titled “to.number”number: (
condition) =>0|1=toNumber
Converts a boolean to numeric 1 or 0.
Parameters
Section titled “Parameters”condition
Section titled “condition”boolean
Returns
Section titled “Returns”0 | 1
Example
Section titled “Example”to.Result
Section titled “to.Result”Result: <
E,A>(onErr,onOk) => (condition) =>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”(condition) => Result<E, A>
Example
Section titled “Example”to.string
Section titled “to.string”string: (
condition) =>"false"|"true"=toString
Converts a boolean to literal string "true" or "false".
Parameters
Section titled “Parameters”condition
Section titled “condition”boolean
Returns
Section titled “Returns”"false" | "true"
Example
Section titled “Example”xor: (
that) => (condition) =>boolean
Logical XOR (exclusive OR) combinator. Returns true if exactly one of condition and that is true.
Data-last: pipe(condition, Bool.xor(that)).
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”(condition) => boolean