import type { AnyFunctionOfReturn, BooleanNot, CastBoolean } from '../@types'; /** * Convert any value to `true` or `false`. * * @refer https://developer.mozilla.org/en-US/docs/Glossary/Truthy * @refer https://developer.mozilla.org/en-US/docs/Glossary/Falsy */ export declare const bool: BooleanConstructor; /** * Logic `NOT`, invert a boolean value to its opposite. * * @param b - The boolean value to invert. * * @example * ```md * | Input A | Output Q | * | 0 | 1 | * | 1 | 0 | * ``` * * @refer https://en.wikipedia.org/wiki/Logic_gate */ export declare function not(b: true): false; export declare function not(b: false): true; export declare function not(b: boolean): boolean; export declare function not(b: unknown): boolean; /** * Logic `AND`. * * @example * ```md * | Input A | Input B | Output Q | * | 0 | 0 | 0 | * | 0 | 1 | 0 | * | 1 | 0 | 0 | * | 1 | 1 | 1 | * ``` * ```ts * const x = true * const y = false * const z = and(x, y) // false * ``` * * @refer https://en.wikipedia.org/wiki/Logic_gate */ export declare const and: (x: unknown, y: unknown) => boolean; /** * @see {@link and} */ export declare const and_: (...args: any[]) => any; /** * Logic `OR`. * * @example * ```md * | Input A | Input B | Output Q | * | 0 | 0 | 0 | * | 0 | 1 | 1 | * | 1 | 0 | 1 | * | 1 | 1 | 1 | * ``` * ```ts * const x = true * const y = false * const z = or(x, y) // true * ``` * * @refer https://en.wikipedia.org/wiki/Logic_gate */ export declare const or: (x: unknown, y: unknown) => boolean; /** * @see {@link or} */ export declare const or_: (...args: any[]) => any; /** * Logic `NAND`. * * @example * ```md * | Input A | Input B | Output Q | * | 0 | 0 | 1 | * | 0 | 1 | 1 | * | 1 | 0 | 1 | * | 1 | 1 | 0 | * ``` * ```ts * const x = true * const y = false * const z = nand(x, y) // true * ``` * * @refer https://en.wikipedia.org/wiki/Logic_gate */ export declare const nand: (x: unknown, y: unknown) => boolean; /** * @see {@link nand} */ export declare const nand_: (...args: any[]) => any; /** * Logic `NOR`. * * @example * ```md * | Input A | Input B | Output Q | * | 0 | 0 | 1 | * | 0 | 1 | 0 | * | 1 | 0 | 0 | * | 1 | 1 | 0 | * ``` * ```ts * const x = true * const y = false * const z = nor(x, y) // false * ``` * * @refer https://en.wikipedia.org/wiki/Logic_gate */ export declare const nor: (x: unknown, y: unknown) => boolean; /** * @see {@link nor} */ export declare const nor_: (...args: any[]) => any; /** * Logic `XOR`. * * @example * ```md * | Input A | Input B | Output Q | * | 0 | 0 | 0 | * | 0 | 1 | 1 | * | 1 | 0 | 1 | * | 1 | 1 | 0 | * ``` * ```ts * const x = true * const y = false * const z = xor(x, y) // true * ``` * * @refer https://en.wikipedia.org/wiki/Logic_gate */ export declare const xor: (x: unknown, y: unknown) => boolean; /** * @see {@link xor} */ export declare const xor_: (...args: any[]) => any; /** * Logic `XNOR`. * * @example * ```md * | Input A | Input B | Output Q | * | 0 | 0 | 1 | * | 0 | 1 | 0 | * | 1 | 0 | 0 | * | 1 | 1 | 1 | * ``` * ```ts * const x = true * const y = false * const z = xnor(x, y) // false * ``` * * @refer https://en.wikipedia.org/wiki/Logic_gate */ export declare const xnor: (x: unknown, y: unknown) => boolean; /** * @see {@link xnor} */ export declare const xnor_: (...args: any[]) => any; export declare type InvertFunctionReturn> = FN extends (...args: unknown[]) => infer R ? (...args: Parameters) => BooleanNot> : never; /** * Take a function that returns a boolean value, return a complement function that return the opposite boolean value. * i.e. whenever target function return `true`, the complement function will return `false`, and vice versa. * * @param fn - The function returns boolean. * * @typeParam FN - The target function's type. */ export declare const complement: >(fn: FN) => InvertFunctionReturn; /** * Predicate whether the target value is exactly `true`. */ export declare const isTrue: (v: unknown) => boolean; /** * Predicate whether the target value is exactly `false`. */ export declare const isFalse: (v: unknown) => boolean; /** * Predicate whether the target value is a truthy value. * * @refer https://developer.mozilla.org/en-US/docs/Glossary/Truthy * @see {@link isFalsy} */ export declare const isTruthy: (v: unknown) => boolean; /** * Predicate whether the target value is a falsy value. * * @refer https://developer.mozilla.org/en-US/docs/Glossary/Falsy * @see {@link isTruthy} */ export declare const isFalsy: (v: unknown) => boolean; /** * Use `===` to check whether two value are equal. * * @refer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness */ export declare const isStrictEqual: (v1: unknown, v2: unknown) => boolean; /** * @see {@link isStrictEqual} */ export declare const isStrictEqual_: (...args: any[]) => any; /** * Use `==` to check whether two value are equal. * * @refer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness */ export declare const isLooseEqual: (v1: unknown, v2: unknown) => boolean; /** * @see {@link isLooseEqual} */ export declare const isLooseEqual_: (...args: any[]) => any; /** * Use `Object.is` to check whether two value are equal. * * @refer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness * @refer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is */ export declare const isObjetEqual: (v1: unknown, v2: unknown) => boolean; /** * @see {@link isObjetEqual} */ export declare const isObjectEqual_: (...args: any[]) => any; /** * Invoke the conditional function with the target value, according to the predicate result. * * @param pred - Value of type `any`, the value will be converted to `boolean` using `bool` function. * If `pred` is of type `NormalFunction`, it will be invoked with provided `x`. * then the invoke result will be converted to `boolean` using `bool` function. * @param thenFn - The function to be invoked if `pred` result is truthy. * @param elseFn - The function to be invoked if `pred` result is falsy. * @param x - The target value, which will be pass to `pred` | `thenFn` | `elseFn`. * * @typeParam T - The type of the target value. * @typeParam TR - The return type of `thenFn`. * @typeParam ER - The return type of `elseFn`. */ export declare const ifElse: (pred: unknown, thenFn: (x?: X | undefined) => TR, elseFn: (x?: X | undefined) => ER, x?: X | undefined) => TR | ER; /** * @see {@link ifElse} */ export declare const ifElse_: (...args: any[]) => any; /** * Invoke the target function with target value, when the predicate result is truthy. * * @param pred - Value of type `any`, the value will be converted to `boolean` using `bool` function. * If `pred` is of type `NormalFunction`, and `x` is provided, it will be invoked with provided `x`. * then the invoke result will be converted to `boolean` using `bool` function. * @param thenFn - The function to be invoked if `pred` result is truthy. * If `x` is provided, it will be passed to `thenFn`. * @param x - The target value, which will be pass to `pred` | `thenFn`. * * @typeParam X - The type of the target value. * @typeParam WR - The return type of `whenFn`. */ export declare function when(pred: unknown, whenFn: (x?: X) => WR): WR; export declare function when(pred: unknown, whenFn: (x?: X) => WR, x: X): WR | X; /** * @see {@link when} */ export declare const when_: (...args: any[]) => any; /** * Invoke the target function with target value, unless the predicate result is truthy. * * @param pred - Value of type `any`, the value will be converted to `boolean` using `bool` function. * If `pred` is of type `NormalFunction`, and `x` is provided, it will be invoked with provided `x`. * then the invoke result will be converted to `boolean` using `bool` function. * @param unlessFn - The function to be invoked if `pred` result is falsy. * If `x` is provided, it will be passed to `unlessFn`. * @param x - The target value, which will be pass to `pred` | `unlessFn`. * * @typeParam X - The type of the target value. * @typeParam UR - The return type of `unlessFn`. */ export declare function unless(pred: unknown, unlessFn: (x?: X) => UR): UR; export declare function unless(pred: unknown, unlessFn: (x?: X) => UR, x: X): UR; /** * @see {@link unless} */ export declare const unless_: (...args: any[]) => any; /** * IIF: Immediate If Function * * @param cond - Value of type `any`, the value will be converted to `boolean` using `bool` function. * If `cond` is of type `NormalFunction`, it will be invoked with provided `trueValue` * then the invoke result will be converted to `boolean` using `bool` function. * * @typeParam X - Type of the trueValue. * @typeParam Y - Type of the falseValue. * * @see {@link bool} */ export declare const iif: (cond: unknown, trueValue: X, falseValue: Y) => X | Y; /** * @see {@link iif} */ export declare const iif_: (...args: any[]) => any; export declare type GuardCondition = [judgement: boolean, value: V]; /** * @refer https://hackage.haskell.org/package/Boolean-0.2.4/candidate/docs/Data-Boolean.html * @refer https://hackage.haskell.org/package/Boolean-0.2.4/candidate/docs/src/Data-Boolean.html#guardedB */ export declare const guards: (conditions: GuardCondition[], defaultValue: V) => V; export declare type CaseCondition = [predicate: (predicated?: P) => boolean, value: V]; /** * @refer https://hackage.haskell.org/package/Boolean-0.2.4/candidate/docs/src/Data-Boolean.html#caseB */ export declare const cases:

(predicated: P, conditions: CaseCondition[], defaultValue: V) => V; //# sourceMappingURL=boolean.d.ts.map