all files / candela/util/ index.js

86.67% Statements 26/30
100% Branches 12/12
50% Functions 1/2
75% Lines 12/16
4 statements, 3 branches Ignored     
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 27 28 29 30 31 32 33 34 35                                                
export function getElementSize (el) {
  const style = window.getComputedStyle(el, null);
  const width = window.parseInt(style.getPropertyValue('width'));
  const height = window.parseInt(style.getPropertyValue('height'));
 
  return {
    width,
    height
  };
}
 
export function minmax (data) {
  let range = {
    min: null,
    max: null
  };
 
  if (data.length > 0) {
    range.min = range.max = data[0];
 
    for (let val of data) {
      if (val < range.min) {
        range.min = val;
      }
 
      if (val > range.max) {
        range.max = val;
      }
    }
  }
 
  return range;
}