src/utils/utils.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1.5

Size

Lines of Code 32
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 20
mnd 2
bc 2
fnc 4
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
bpm 0.5
cpm 1.5
noi 0
c 0
b 0
f 0
1
import L from 'leaflet';
2
import marker2x from 'leaflet/dist/images/marker-icon-2x.png';
3
import marker from 'leaflet/dist/images/marker-icon.png';
4
import markerShadow from 'leaflet/dist/images/marker-shadow.png';
5
import { isEmpty, isNil, range } from 'ramda';
6
7 23
export const determineOrderDir = (clickedField, currentOrderField, currentOrderDir) => {
8 27
  if (currentOrderField !== clickedField) {
9 10
    return 'ASC';
10
  }
11
12 17
  const newOrderMap = {
13
    ASC: 'DESC',
14
    DESC: undefined,
15
  };
16
17 17
  return currentOrderDir ? newOrderMap[currentOrderDir] : 'ASC';
18
};
19
20 23
export const fixLeafletIcons = () => {
21 1
  delete L.Icon.Default.prototype._getIconUrl;
22
23 1
  L.Icon.Default.mergeOptions({
24
    iconRetinaUrl: marker2x,
25
    iconUrl: marker,
26
    shadowUrl: markerShadow,
27
  });
28
};
29
30 39
export const rangeOf = (size, mappingFn, startAt = 1) => range(startAt, size + 1).map(mappingFn);
31
32
export const hasValue = (value) => !isNil(value) && !isEmpty(value);
33