function boolean(value, allowEmptyString = false) {
  if (value === "" && allowEmptyString) {
    value = true;
  }
  switch (typeof value) {
    case "string":
      return ["true", "t", "yes", "y", "on", "1"].includes(value.trim().toLowerCase());
    case "number":
      return value.valueOf() === 1;
    case "boolean":
      return value.valueOf();
    default:
      return false;
  }
}

export { boolean };
