| 1 | import { setOptions } from 'leaflet'; |
| 2 | |
| 3 | export const debounce = (fn, time) => { |
| 4 | let timeout; |
| 5 | |
| 6 | const debouncedFunction = function(...args) { |
| 7 | const context = this; |
| 8 | if (timeout) { |
| 9 | clearTimeout(timeout); |
| 10 | } |
| 11 | timeout = setTimeout(() => { |
| 12 | fn.apply(context, args); |
| 13 | timeout = null; |
| 14 | }, time); |
| 15 | }; |
| 16 | |
| 17 | debouncedFunction.cancel = function() { |
| 18 | if (timeout) { |
| 19 | clearTimeout(timeout); |
| 20 | } |
| 21 | }; |
| 22 | |
| 23 | return debouncedFunction; |
| 24 | }; |
| 25 | |
| 26 | export const capitalizeFirstLetter = string => { |
| 27 | if (!string || typeof string.charAt !== 'function') { |