kitchen-simulator
Version:
It is a kitchen simulator (self-contained micro-frontend).
29 lines • 647 B
JavaScript
var lengthFactors = {
m: 1,
cm: 100,
mm: 1000,
"in": 39.3701,
ft: 3.28084,
m2: 1,
cm2: 10000,
// (100^2)
mm2: 1000000,
// (1000^2)
in2: 1550.0031,
// (39.3701^2)
ft2: 10.7639 // (3.28084^2)
};
export function convert(value) {
return {
from: function from(fromUnit) {
return {
to: function to(toUnit) {
if (!(fromUnit in lengthFactors) || !(toUnit in lengthFactors)) {
throw new Error("Unsupported unit conversion: ".concat(fromUnit, " \u2192 ").concat(toUnit));
}
return value / lengthFactors[fromUnit] * lengthFactors[toUnit];
}
};
}
};
}