@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
22 lines (21 loc) • 782 B
TypeScript
/**
* Checks if a value is a valid boolean or a string representation of a boolean.
*
* The function recognizes the following boolean representations:
* - `true`, `false` (boolean values)
* - `"true"`, `"false"` (string values)
* - `"yes"`, `"no"` (string values)
* - `1`, `0` (numeric values)
*
* @param value - The value to check.
* @returns A boolean indicating whether the value is a valid boolean or a recognized string representation of a boolean.
*
* @example
* isBoolean(true); // Output: true
* isBoolean("true"); // Output: true
* isBoolean("yes"); // Output: true
* isBoolean(1); // Output: true
* isBoolean("no"); // Output: true
* isBoolean("random"); // Output: false
*/
export default function isBoolean(value: string | number | boolean): boolean;