const WeightToMg = (value, unit) => { if (unit == 'g') { return value * 1000; } if (unit == 'kg') { return value * 1000000; } } const MgToWeight = (value, unit, display) => { if (typeof display === 'undefined') display = false; if (unit == 'g') { return Math.round(100 * value / 1000.0) / 100; } if (unit == 'kg') { return Math.round(100 * value / 1000000.0, 2) / 100; } } export default { WeightToMg, MgToWeight, };