const bool = (value: string) => {
  const truthy = ['true', '1', 'yes', 'y', 'on', 'Y', 1, true];
  const falsy = ['false', '0', 'no', 'n', 'off', 'N', 0, false];

  if (truthy.includes(value)) {
    return true;
  } else if (falsy.includes(value)) {
    return false;
  } else {
    return null;
  }
};

const int = (value: string) =>
  isNaN(parseInt(value)) ? undefined : parseInt(value);

const float = (value: string) =>
  isNaN(parseFloat(value)) ? undefined : parseFloat(value);

export const typeParser = {
  bool,
  int,
  float,
};
