Skip to content

Latest commit

 

History

History
67 lines (58 loc) · 2.74 KB

index.adoc

File metadata and controls

67 lines (58 loc) · 2.74 KB

Boolean

The @perfective/common/boolean package provides types and functions to work with the boolean type.

Proposition

Proposition<T> is a boolean value, or a nullary function that returns a boolean value.

  • isTrue(proposition: Proposition): boolean — returns true if a given proposition is true or returns true. Otherwise, returns false.

  • isFalse(proposition: Proposition): boolean — returns true if a given proposition is false or returns false. Otherwise, returns false.

  • negated(proposition: Proposition): boolean — returns true if a given proposition is false or returns false. Otherwise, returns false.

Predicate

Predicate<T> is a unary function that returns a boolean value.

  • isBoolean<T>(value: T | boolean): value is boolean — returns true if a given value is boolean.

  • isNotBoolean<T>(value: T | boolean): value is T — returns true if a given value is not boolean.

  • isTruthy<T>(value: T): boolean — returns true when the value is neither undefined, null, false, NaN, 0, -0, 0n (a BigInt zero), "" (an empty string), or the document.all builtin.

  • isFalsy<T>(value: T): boolean — returns true when the value is undefined, null, false, NaN, 0, -0, 0n (a BigInt zero), "" (an empty string), or the document.all builtin.

  • is<T>(input: T): Predicate<T> — creates a Predicate that is true if its argument strictly equals a given input.

  • isNot<T>(input: T): Predicate<T> — creates a Predicate that is true if its argument does not equal a given input.

  • not<T>(predicate: Predicate<T>): Predicate<T> — creates a Predicate that inverses the result of a given Predicate.

  • all<T>(…​predicates: Predicate<T>[]): Predicate<T> — creates a Predicate that is true when all given predicates are true (logical AND).

  • either<T>(…​predicates: Predicate<T>[]): Predicate<T> — creates a Predicate that is true when at least one of given predicates is true (logical OR).

  • neither<T>(…​predicates: Predicate<T>[]): Predicate<T> — creates a Predicate that is true when none of given predicates is true.

  • atLeast<T>(minimum: number, …​predicates: Predicate<T>[]): Predicate<T> — creates a Predicate that is true when at least a given minimum number of given predicates is true.

  • atMost<T>(maximum: number, …​predicates: Predicate<T>[]): Predicate<T> — creates a Predicate that is true when no more than a given maximum number of given predicates is true.

  • exactly<T>(count: number, …​predicates: Predicate<T>[]): Predicate<T> — creates a Predicate that is true when exactly a given count number of given predicates is true.