Total Complexity | 9 |
Complexity/F | 1.29 |
Lines of Code | 46 |
Function Count | 7 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 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 { range } from 'ramda'; |
||
6 | |||
7 | 10 | const TEN_ROUNDING_NUMBER = 10; |
|
8 | 10 | const DEFAULT_TIMEOUT_DELAY = 2000; |
|
9 | 10 | const { ceil } = Math; |
|
10 | |||
11 | 10 | export const stateFlagTimeout = (setTimeout) => ( |
|
12 | setState, |
||
13 | flagName, |
||
14 | initialValue = true, |
||
15 | delay = DEFAULT_TIMEOUT_DELAY |
||
16 | ) => { |
||
17 | 1 | setState({ [flagName]: initialValue }); |
|
18 | 1 | setTimeout(() => setState({ [flagName]: !initialValue }), delay); |
|
19 | }; |
||
20 | |||
21 | 10 | export const determineOrderDir = (clickedField, currentOrderField, currentOrderDir) => { |
|
22 | 11 | if (currentOrderField !== clickedField) { |
|
23 | 4 | return 'ASC'; |
|
24 | } |
||
25 | |||
26 | 7 | const newOrderMap = { |
|
27 | ASC: 'DESC', |
||
28 | DESC: undefined, |
||
29 | }; |
||
30 | |||
31 | 7 | return currentOrderDir ? newOrderMap[currentOrderDir] : 'ASC'; |
|
32 | }; |
||
33 | |||
34 | 10 | export const fixLeafletIcons = () => { |
|
35 | 1 | delete L.Icon.Default.prototype._getIconUrl; |
|
36 | |||
37 | 1 | L.Icon.Default.mergeOptions({ |
|
38 | iconRetinaUrl: marker2x, |
||
39 | iconUrl: marker, |
||
40 | shadowUrl: markerShadow, |
||
41 | }); |
||
42 | }; |
||
43 | |||
44 | 10 | export const rangeOf = (size, mappingFn, startAt = 1) => range(startAt, size + 1).map(mappingFn); |
|
45 | |||
46 | 10 | export const roundTen = (number) => ceil(number / TEN_ROUNDING_NUMBER) * TEN_ROUNDING_NUMBER; |
|
47 | |||
48 |