Converts one value object to another one with a different compatible unit
The value object to be converted
The unit to convert into, must be compatible with the value object's unit
a new value object that contains the converted value
const value = { value: 1, unit: m/s }; const toUnit = mm/s; const convertedValue = convertValue(value, toUnit); console.log(convertedValue); // outputs { value: 1000, unit: mm/s }; Copy
const value = { value: 1, unit: m/s }; const toUnit = mm/s; const convertedValue = convertValue(value, toUnit); console.log(convertedValue); // outputs { value: 1000, unit: mm/s };
Error if the value object and the provided unit are incompatible
valueRawConverter
Converts one value object to another one with a different compatible unit