aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/converter.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/common/converter.js')
-rw-r--r--modern/src/common/converter.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/modern/src/common/converter.js b/modern/src/common/converter.js
index 930dba15..26e2a82b 100644
--- a/modern/src/common/converter.js
+++ b/modern/src/common/converter.js
@@ -1,4 +1,4 @@
-export const speedConverter = (value, unit, back = false) => {
+const speedConverter = (value, unit, back = false) => {
let factor;
switch (unit) {
case 'kmh':
@@ -11,10 +11,10 @@ export const speedConverter = (value, unit, back = false) => {
default:
factor = 1;
}
- return back ? (value / factor).toFixed(2):(value * factor).toFixed(2);
+ return back ? value / factor: value * factor;
};
-export const distanceConverter = (value, unit, back = false) => {
+const distanceConverter = (value, unit, back = false) => {
let factor;
switch (unit) {
case 'mi':
@@ -28,4 +28,20 @@ export const distanceConverter = (value, unit, back = false) => {
factor = 0.001;
}
return back ? value / factor : value * factor;
-} \ No newline at end of file
+}
+
+export const speedFromKnots = (value, unit) => {
+ return speedConverter(value, unit);
+}
+
+export const speedToKnots = (value, unit) => {
+ return speedConverter(value, unit, true);
+}
+
+export const distanceFromMeters = (value, unit) => {
+ return distanceConverter(value, unit);
+}
+
+export const distanceToMeters = (value, unit) => {
+ return distanceConverter(value, unit, true);
+}