function parseNumberAndUnit(str) {
  if (typeof str !== "string") {
    return null;
  }
  const match = str.trim().match(/^([+-]?\d*\.?\d+)(.*)$/);
  if (!match) {
    return null;
  }
  const number = parseFloat(match[1]);
  const unit = match[2].trim();
  if (isNaN(number)) {
    return null;
  }
  return { number, unit };
}

export { parseNumberAndUnit };
