19 lines
360 B
JavaScript
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";
|
|
}
|