import { ERRORTYPES as error } from "./error";
Copyright 2015-2021 JC Fisher
import { ERRORTYPES as error } from "./error";
PARSEBOOL converts a truthy value into a boolean value.
export default function parsebool(val) {
if (val instanceof Error) {
return val;
} else if (typeof val === "boolean") {
return val;
} else if (typeof val === "number") {
return val !== 0;
} else if (typeof val === "string") {
var up = val.toUpperCase();
if (up === "TRUE" || up === "FALSE") {
return up === "TRUE";
}
}
return error.value;
}