Conversions
Utilities for converting data types.
Example:
import { toBoolean } from "@travisspomer/tidbits"
const trueOrFalse: boolean = toBoolean(value)
toBoolean
toBoolean(value: any): boolean
value: A string or number to be converted to a Boolean. (Or, an existing Boolean will be returned as-is.)- Returns:
trueifvalueistrue,1, or"true"(case- and whitespace-insensitive).falseifvalueis"false"or any falsy value (false,0,"",null,undefined,NaN).- Anything else (
"daffodil", 42,{}, etc.) throws an exception.