All files / src/Map/Utilities Utils.js

77.78% Statements 14/18
0% Branches 0/4
83.33% Functions 5/6
76.47% Lines 13/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 271x 1x 1x   1x 1x   1x 2x               1x 1x 1x     1x 19x   19x    
export const loadJS = (src) =>
  new Promise((resolve, reject) => {
    const script = window.document.createElement('script')
 
    script.id = 'mapScript'
    const head = window.document.getElementsByTagName('head')[0]
 
    head.appendChild(script)
    const handleResult = (state) => (evt) => {
      if (state === 'loaded') {
        resolve(src)
      } else if (state === 'error') {
        reject(evt)
      }
    }
 
    script.addEventListener('load', handleResult('loaded'))
    script.addEventListener('error', handleResult('loaded'))
    script.src = src
  })
 
export const camelize = (str) =>
  str
    .split(' ')
    .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
    .join('')