UNPKG

tiinvo

Version:

A library of types and utilities for your TypeScript and JavaScript projects

74 lines (73 loc) 1.26 kB
import type * as Functors from './Functors.js'; /** * Represents a boolean value * * @example * * ```ts * import { Bool } from 'tiinvo' * * let x: Bool.T = true; * * ``` * * @since 4.0.0 */ export type T = boolean; /** * Checks if parameter `x` is `boolean` * * @example * * ```ts * import { Bool } from 'tiinvo' * * Bool.guard(true) // true * Bool.guard(1000) // false * ``` * * @param x the value to check if is a boolean * @returns * - `true` if `x` is a `boolean` * - `false` otherwise * @since 4.0.0 */ export declare const guard: Functors.Guardable<boolean>; /** * Flips a boolean value * * @example * * ```ts * import { Bool } from 'tiinvo' * * Bool.flip(true) // false * ``` * * @param x the bool to flip * @returns * - `false` if `x` is `true` * - `true` if `x` is `false` * @since 4.0.0 */ export declare const flip: Functors.Mappable<T, T>; /** * Returns 1 if true, 0 otherwise * * @example * * ```ts * import { Bool } from 'tiinvo' * * Bool.toNumber(true) // 1 * Bool.toNumber(false) // 0 * ``` * * @param t the bool * @returns * - `1` if `t` is `false` * - `0` if `t` is `true` * @group Serializables * @since 4.0.0 */ export declare const toNumber: (t: T) => 1 | 0;