Used by commander to parse numbers and fails if invalid
value is passed in
@private
491116
function parseInteger (name, port) {
  const portNumber = Number(port)
  if (!portNumber) {
    console.error(`Provided ${name} must be an integer`)
    process.exit(1)
  }
  return portNumber
}
23302
def parse_number(self, s):
        """"""
        start = 1 if s[0] in ["-","+"] else 0

        all_digits = lambda x: all(map(lambda c: c.isdigit(), x))
        ishex = lambda c: c.isdigit() or ord(c.lower()) in range(ord("a"), ord("f"))
        all_hex = lambda x: all(map(ishex, x))

        if all_digits(s[start:]):
            try:
                return (Tokenizer.INTEGER, int(s))
            except ValueError:
                raise ParseError("%d:%d: Invalid integer '%s'" % (self.lineno,
                    self.column, s))

        if s[start:].startswith("0x") and all_hex(s[start+2:]):
            try:
                return (Tokenizer.INTEGER, int(s, base=16))
            except ValueError:
                raise ParseError("%d:%d: Invalid hexadecimal integer '%s'" %
                        (self.lineno, self.column, s))

        if any(map(lambda c: c==".", s)) or any(map(lambda c: c=="e", s)):
            try:
                return (Tokenizer.FLOAT, float(s))
            except ValueError:
                raise ParseError("%d:%d: Invalid float '%s'" % (self.lineno,
                    self.column, s))

        raise ParseError("%d:%d: Invalid number '%s'" % (self.lineno,
            self.column, s))
1246356
function parseSimpleNumbers (parser) {
  const length = parser.buffer.length - 1
  var offset = parser.offset
  var number = 0
  var sign = 1

  if (parser.buffer[offset] === 45) {
    sign = -1
    offset++
  }

  while (offset < length) {
    const c1 = parser.buffer[offset++]
    if (c1 === 13) { // \r\n
      parser.offset = offset + 1
      return sign * number
    }
    number = (number * 10) + (c1 - 48)
  }
}
1319163
function parseLength (parser) {
  const length = parser.buffer.length - 1
  var offset = parser.offset
  var number = 0

  while (offset < length) {
    const c1 = parser.buffer[offset++]
    if (c1 === 13) {
      parser.offset = offset + 1
      return number
    }
    number = (number * 10) + (c1 - 48)
  }
}
53471
function parseValue(expr) {
  switch(expr.kind) {
    case 'array':
      if (expr.items.length === 0) {
        return [];
      }
      var isKeyed = expr.items.every((item) => item.key !== null)
      var items = expr.items.map(parseValue)
      if (isKeyed) {
        items = items.reduce((acc, val) => Object.assign({}, acc, val), {})
      }
      return items
    case 'entry':
      if (expr.key) {
        return { [parseKey(expr.key)]: parseValue(expr.value) }
      }
      return parseValue(expr.value)
    case 'string':
      return expr.value
    case 'number':
      return parseInt(expr.value, 10)
    case 'boolean':
      return expr.value
    default:
      throw new Error(`Unexpected PHP value: "${expr.kind}", details: ${JSON.stringify(expr)}`)
  }
}
734804
function isNumberString(value) {
    let numberReg = /^((-?\d*\.?\d*(?:e[+-]?\d*(?:\d?\.?|\.?\d?)\d*)?)|(0[0-7]+)|(0x[0-9a-f]+))$/i;
    return lodash.isString(value) && !isEmpty(value) && numberReg.test(value);
}
747792
function isValidArrayIndex (val) {
  const n = parseFloat(String(val));
  return n >= 0 && Math.floor(n) === n && isFinite(val)
}
391916
function parseAnimationValue(value) {
  value = value.toString();

  if (value === 'initial') {
    value = 0;
  } else if (/ms$/.test(value)) {
    value = parseFloat(value);
  } else {
    value = parseFloat(value) * 1000;
  }

  return value;
}
14552
function parseIntValue(value, description) {
        if (description === void 0) { description = "integer"; }
        if (angular.isString(value)) {
            try {
                return parseInt(value);
            }
            catch (e) {
                console.log("Failed to parse " + description + " with text '" + value + "'");
            }
        }
        else if (angular.isNumber(value)) {
            return value;
        }
        return null;
    }
1109726
function parseNumber (inp) {
    var res = "";
    if (inp.takeAPeek("-")) res += "-";
  
    var match = parseInteger(inp);
    if (match) res += match;
  
    match = parseFraction(inp);
    if (match) res += match;
  
    if (res && res !== "-") {
      match = parseExponent(inp);
      if (match) res += match;
    }
  
    if (res === "-") syntaxError(inp, "Expected number");
    return res || null;
  }
734178
function parseNumber(fmt, value) {
    var format = replace(fmt, /^\?/);
    if (format!=fmt && !trim(value))
      return _null;
    var decSep = (/(^|[^0#.,])(,|[0#.]*,[0#]+|[0#]+\.[0#]+\.[0#.,]*)($|[^0#.,])/.test(format)) ? ',' : '.';
    var r = parseFloat(replace(replace(replace(value, decSep == ',' ? /\./g : /,/g), decSep, '.'), /^[^\d-]*(-?\d)/, '$1'));
    return isNaN(r) ? undef : r;
  }
1185112
function readNumericString(s, minValue) {
    var length = readLength(s);
    length = (length + minValue + 1) / 2;
    s.readPadding(length);
}
1337423
function isNumber( value ) {
	return ( typeof value === 'number' || Object.prototype.toString.call( value ) === '[object Number]' ) && value.valueOf() === value.valueOf();
}
566927
function financialNumber (value) {
  const num = Number(value)
  if (value !== num || num < -99999999.99 || num > 99999999.99) {
    throw new Error(`Value '${value}' is not a valid number.`)
  }
}
535720
function mkNumber(val) {
            var sign = 1;
            if (val.charAt(0) == '-') {
                sign = -1;
                val = val.substring(1);
            }
            if (Lang.NUMBER_DEC.test(val))
                return sign * parseInt(val, 10);
            else if (Lang.NUMBER_HEX.test(val))
                return sign * parseInt(val.substring(2), 16);
            else if (Lang.NUMBER_OCT.test(val))
                return sign * parseInt(val.substring(1), 8);
            else if (val === 'inf')
                return sign * Infinity;
            else if (val === 'nan')
                return NaN;
            else if (Lang.NUMBER_FLT.test(val))
                return sign * parseFloat(val);
            throw Error("illegal number value: " + (sign < 0 ? '-' : '') + val);
        }
1239477
function parseNamedHues(value) {
        var tokens = value.split(/\s+/);
        var l = tokens.length;

        if (l < 1 || l > 2) {
            return false;
        }

        var t1 = tokens[l - 1].toLowerCase();

        if (!(t1 in BASE_HUE)) {
            return false;
        }

        var h1 = BASE_HUE[t1];

        // single-value syntax
        if (l === 1) {
            return h1;
        }

        // double-value syntax
        var h2;
        var t2 = tokens[0].toLowerCase();
        var hues;
        if (t2 in BASE_HUE) {
            h2 = BASE_HUE[t2];
            hues = fixHues(h1, h2);
            return hues ? (hues.h1 + hues.h2) / 2 : false;
        } else if (t2 in SPLASH_HUE) {
            h2 = SPLASH_HUE[t2];
            hues = fixHues(h1, h2);
            return hues ? (hues.h1 + (hues.h2 - hues.h1) / 4) : false;
        } else {
            var found = t2.match(/(\w+)\(\s*([^\)]+)\s*\)/i);
            if (!found) {
                return false;
            }
            t2 = found[1];
            if (t2 in SPLASH_HUE) {
                h2 = SPLASH_HUE[t2];
                hues = fixHues(h1, h2);
                var percent = DATATYPES[PERCENT].parse(found[2]);
                if (percent === false) {
                    return percent;
                }
                return hues ? (hues.h1 + (hues.h2 - hues.h1) * percent) : false;
            }
        }

        return false;
    }
986576
function parseQueryStringItemValue(key, value) {
  if (Array.isArray(value)) {
    // deduplicate and simplify arrays
    value = value.filter((v, idx) => value.indexOf(v) === idx);
    if (value.length === 1) value = value[0];
  } else if (value.indexOf(':') > 0) {
    value = value.split(',').reduce((result, pair) => {
      const parts = pair.split(':');
      result[parts[0]] = parseQueryStringItemValue(key, parts[1]);
      return result;
    }, {});
  } else if (value.indexOf(',') > 0) {
    value = value.split(',').map(v => {
      return parseQueryStringItemValue(key, v);
    });
  } else if (value.toLowerCase() === 'true' || value.toLowerCase() === 'false') {
    value = value.toLowerCase() === 'true';
  } else if (!Number.isNaN(value) && !STRING_OPTIONS.has(key)) {
    const numericValue = parseFloat(value);
    if (!Number.isNaN(numericValue)) {
      value = parseFloat(value);
    }
  }

  return value;
}