Try if you can make this workaround work for you.
function parseUnitValue(s, baseUnit) {
if (s === undefined || s === '' || s.length === 0) {
s = '0';
}
const regex = /\+*(\-*\d*[\.|,]?\d*\s*)(in|inch|inches|ft|foot|feet|yd|yard|yards|mi|mile|miles|mm|millimeter|millimeters|cm|centimeter|centimeters|m|meter|meters|km|kilometer|kilometers|pt|point|points|pc|pica|picas|ci|cicero|ciceros)?/gi;
const match = s.match(regex);
let stringIsValid = false;
let sVal = 0;
let sUnit = baseUnit;
if (match && s === match[0]) {
stringIsValid = true;
sVal = s.replace(regex, '$1').replace(',', '.');
sUnit = s.replace(regex, '$2').toLowerCase() || baseUnit;
}
if (!stringIsValid) {
console.warn("Unknown Unit. Try: in, inch, inches, ft, foot, feet, yd, yard, yards, mi, mile, miles, pt, point, points, pc, pica, picas, ci, cicero, ciceros, mm, millimeter, millimeters, cm, centimeter, centimeters, m, meter, meters, km, kilometer, kilometers");
return 0;
}
return convertToBaseUnit(parseFloat(sVal), sUnit, baseUnit);
}
function convertToBaseUnit(value, fromUnit, toUnit) {
const units = {
'in': 72, 'inch': 72, 'inches': 72,
'ft': 864, 'foot': 864, 'feet': 864,
'yd': 2592, 'yard': 2592, 'yards': 2592,
'mi': 4572288, 'mile': 4572288, 'miles': 4572288,
'mm': 2.834645669, 'millimeter': 2.834645669, 'millimeters': 2.834645669,
'cm': 28.34645669, 'centimeter': 28.34645669, 'centimeters': 28.34645669,
'm': 2834.645669, 'meter': 2834.645669, 'meters': 2834.645669,
'km': 2834645.669, 'kilometer': 2834645.669, 'kilometers': 2834645.669,
'pt': 1, 'point': 1, 'points': 1,
'pc': 12, 'pica': 12, 'picas': 12,
'ci': 12.7872, 'cicero': 12.7872, 'ciceros': 12.7872
};
if (!units[fromUnit] || !units[toUnit]) {
console.error('Invalid unit conversion');
return 0;
}
const pointValue = value * units[fromUnit];
return pointValue / units[toUnit];
}