Merge pull request #175 from BennyDaBee/patch-1

Update measurement.js
This commit is contained in:
Michael Woods 2022-06-22 20:55:34 -04:00 committed by GitHub
commit 9a5daf33c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,9 @@ class Measurement {
'°C',
'km',
'kPa',
'km/l(e)'
'km/l(e)',
// Helps with conversion to Gallons.
'lit'
];
constructor(value, unit) {
@ -35,6 +37,8 @@ class Measurement {
case 'volts':
case 'Volts':
return 'V';
case 'l':
return 'lit';
// these are states
case 'Stat':
case 'N/A':
@ -66,6 +70,9 @@ class Measurement {
// km/L = (1.609344 / 3.785411784) * MPG
value = _.round(value / (1.609344 / 3.785411784), 1);
break;
case 'lit':
value = _.round(value / 3.785411784, 1);
break;
}
return value;
}
@ -85,6 +92,8 @@ class Measurement {
return 'psi';
case 'km/l(e)':
return 'mpg(e)';
case 'lit':
return 'gal';
default:
return unit;
}
@ -95,4 +104,4 @@ class Measurement {
}
}
module.exports = Measurement;
module.exports = Measurement;