all files / src/imageLoader/wadors/metaData/ getNumberString.js

0% Statements 0/4
0% Branches 0/2
0% Functions 0/1
0% Lines 0/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                                           
import getValue from './getValue.js';
 
/**
 * Returns the first string value as a Javascript number
 *
 * @param element - The javascript object for the specified element in the metadata
 * @param [index] - the index of the value in a multi-valued element, default is 0
 * @param [defaultValue] - The default value to return if the element does not exist
 * @returns {*}
 */
function getNumberString (element, index, defaultValue) {
  const value = getValue(element, index, defaultValue);
 
  if (value === undefined) {
    return;
  }
 
  return parseFloat(value);
}
 
export default getNumberString;