@mobily/ts-belt
Version:
🔧 Fast, modern, and practical utility library for FP in TypeScript.
67 lines (56 loc) • 1.87 kB
Flow
// @flow
/**
* Folds a boolean value into a value of a different type, using a function for the `true` and `false` cases.
*/
declare export function ifElse<A>(
value: boolean,
truthyFn: () => A,
falsyFn: () => A
): A;
declare export function ifElse<A>(
truthyFn: () => A,
falsyFn: () => A
): (value: boolean) => A;
/**
* Negates the given boolean.
*/
declare export function inverse(value: boolean): boolean;
/**
* Alias for inverse.
*/
declare export function not(value: boolean): boolean;
/**
* Combines two boolean using `AND` → `a && b`.
*/
declare export function and(b: boolean): (a: boolean) => boolean;
declare export function and(a: boolean, b: boolean): boolean;
/**
* Combines two boolean using `OR` → `a || b`.
*/
declare export function or(b: boolean): (a: boolean) => boolean;
declare export function or(a: boolean, b: boolean): boolean;
/**
* Combines two booleans using `NAND` → `!(a && b)`.
*/
declare export function nand(b: boolean): (a: boolean) => boolean;
declare export function nand(a: boolean, b: boolean): boolean;
/**
* Combines two booleans using `NOR` → `!(a || b)`.
*/
declare export function nor(b: boolean): (a: boolean) => boolean;
declare export function nor(a: boolean, b: boolean): boolean;
/**
* Combines two booleans using `XOR` → `(!a && b) || (a && !b)`.
*/
declare export function xor(b: boolean): (a: boolean) => boolean;
declare export function xor(a: boolean, b: boolean): boolean;
/**
* Combines two booleans using `XNOR` → `!xor(a, b)`.
*/
declare export function xnor(b: boolean): (a: boolean) => boolean;
declare export function xnor(a: boolean, b: boolean): boolean;
/**
* Combines two booleans using an implication (`!a || b`).
*/
declare export function implies(b: boolean): (a: boolean) => boolean;
declare export function implies(a: boolean, b: boolean): boolean;