All files helpers.js

78.57% Statements 11/14
25% Branches 2/8
75% Functions 3/4
78.57% Lines 11/14

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 27 28 291x 21x 21x 21x     1x           1x 22x       1x 1x   1x       1x        
export const isValidStyleColor = (color) => {
  const style = new Option().style;
  style.color = color;
  return !!style.color;
};
 
export const getTranslucent = (color) => {
  const colorIndex = color.split(",");
 
  return colorIndex.length === 4 ? parseFloat(colorIndex.pop() || "") : 1;
};
 
export const matchRgba = (color) =>
  color.match(
    /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/
  );
 
export const getRgba = (color, opacity) => {
  const match = matchRgba(color);
 
  Iif (!match) {
    return color;
  }
 
  return `rgba(${Number(match[1])}, ${Number(match[2])},  ${Number(
    match[3]
  )}, ${opacity !== undefined ? opacity : Number(match[4])})`;
};