@thangk/easythemer
Version:
Easily generate shades from a colour palette for use in your app
13 lines (10 loc) • 468 B
text/typescript
export default function toBoolean(input: any): boolean | undefined {
if (typeof input !== "number" && typeof input !== "string" && typeof input !== "boolean") {
return undefined;
}
if (typeof input === "boolean") return input;
if (typeof input === "number") return input ? false : true;
if (typeof input === "string")
return input.toLowerCase() === "on" ? true : input.toLowerCase() === "off" ? false : undefined;
return undefined;
}