DigitalConsumer.FixMyGlass/src/helpers/boolean-helper.js
2025-01-27 18:02:34 -05:00

19 lines
360 B
JavaScript

export function getBoolFromString(str) {
// Catch edge cases
if (str === null || str === undefined) {
return false;
}
if (typeof str === "boolean") {
return str;
}
if (typeof str !== "string") {
return false;
}
// string logic
const toLower = str?.toLowerCase();
return toLower === "true";
}