All files / src/helpers evalBreakpoints.js

100% Statements 7/7
75% Branches 6/8
100% Functions 1/1
100% Lines 7/7

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          8x 1x   7x 1x 1x   1x   6x    
/**
 * Normalizes `breakpoint` component attribute to an array of numbers
 * @param {Function|Array|String} valueOrGetter
 */
export function evalBreakpoints(valueOrGetter) {
  if (typeof valueOrGetter === "function") {
    return valueOrGetter();
  }
  if (typeof valueOrGetter === "string") {
    const firstChar = valueOrGetter.slice(0, 1)
    const lastChar = valueOrGetter.slice(-1)
 
    return JSON.parse(`${firstChar === '[' ? '' : '['}${valueOrGetter}${lastChar === ']' ? '' : ']'}`)
  }
  return valueOrGetter;
}