UNPKG

@tempots/std

Version:

Std library for TypeScript. Natural complement to the Tempo libraries.

56 lines (55 loc) 1.55 kB
/** * Utility functions to manipulate `boolean` values. */ /** * Returns a comparison value (`Int`) from two boolean values. * * @param a - The first boolean value. * @param b - The second boolean value. * @returns A comparison value. * @public */ export declare const compareBooleans: (a: boolean, b: boolean) => number; /** * Converts a boolean to an integer value (`true` => `1`, `false` => `0`). * * @param v - The boolean value. * @returns The integer value. * @public */ export declare const booleanToInt: (v: boolean) => number; /** * Returns `true` if the passed value can be parsed as a boolean. The following values are considered parsable: * * - `'true'` / `'false'` * - `'0'` / `'1'` * - `'on'` / `'off'` * * The comparison is case insensitive. * * @param v - The value to check. * @returns `true` if the value can be parsed; otherwise, `false`. * @public */ export declare const canParseBoolean: (v: string) => boolean; /** * Returns `true`/`false` if the passed value can be parsed. The following values are considered parsable: * * - `'true'` / `'false'` * - `'0'` / `'1'` * - `'on'` / `'off'` * * @param v - The value to parse. * @returns The parsed boolean value. * @public */ export declare const parseBoolean: (v: string) => boolean; /** * Returns `true` when arguments are different. * * @param a - The first boolean value. * @param b - The second boolean value. * @returns The result of the XOR operation. * @public */ export declare const xorBoolean: (a: boolean, b: boolean) => boolean;