All files / platform/core/src/DICOMWeb getNumber.js

0% Statements 0/7
0% Branches 0/3
0% Functions 0/1
0% Lines 0/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 18 19 20 21 22                                           
/**
 * Returns the first string value as a Javascript Number
 * @param element - The group/element of the element (e.g. '00200013')
 * @param [defaultValue] - The default value to return if the element does not exist
 * @returns {*}
 */
export default function getNumber(element, defaultValue) {
  Iif (!element) {
    return defaultValue;
  }
  // Value is not present if the attribute has a zero length value
  Iif (!element.Value) {
    return defaultValue;
  }
  // Sanity check to make sure we have at least one entry in the array.
  Iif (!element.Value.length) {
    return defaultValue;
  }
 
  return parseFloat(element.Value[0]);
}