https://en.wikipedia.org/wiki/Hectare#Are
Let say runtime known meter unit, be we want work with Are (1a = 100m2) and this unit is not known by the runtime.
Should this proposal allow to add custom units and describe possible conversions ?
API Idea (pseudocode):
Measure.addUnit({
symbol: 'a',
name: 'are',
kind: {type: 'distance', exponent: 2} // surface
conversions: [
{
type: 'distance',
exponent: 2,
unit: 'meter',
convertTo: (ares: number) => ares * 100,
convertFrom: (m2: number) => m2 / 100,
}
],
});
const measureAre = new Measure(1, {unit: 'are'});
const measureM2 = measureAre.convertTo('meter');
// Measure { value: 100, unit: 'meter', exponent: 2}
https://en.wikipedia.org/wiki/Hectare#Are
Let say runtime known
meterunit, be we want work withAre(1a = 100m2) and this unit is not known by the runtime.Should this proposal allow to add custom units and describe possible conversions ?
API Idea (pseudocode):