aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/converter.js
blob: 8fdb4b862fdc3a62b5342d3eade027fee138a040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const speedConverter = (value, unit) => {
  let factor;
  switch (unit) {
    case 'kmh':
      factor = 1.852;
    case 'mph':
      factor = 1.15078;
    case 'kn':
    default:
      factor = 1;
  }
  return (value * factor).toFixed(2);
};

export const getConverter = (key) => {
  switch (key) {
    case 'speed':
      return speedConverter;
    default:
      return function (value) {
        return value;
      }
  }
};