All files / platform/core/src/utils toNumber.js

100% Statements 4/4
83.33% Branches 5/6
100% Functions 2/2
100% Lines 3/3

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              6578615x 11195875x   3294327x      
/**
 * Returns the values as an array of javascript numbers
 *
 * @param val - The javascript object for the specified element in the metadata
 * @returns {*}
 */
export default function toNumber(val) {
  if (Array.isArray(val)) {
    return [...val].map(v => (v !== undefined ? Number(v) : v));
  } else {
    return val !== undefined ? Number(val) : val;
  }
}