_parse-int.js 390 B

123456789
  1. var $parseInt = require('./_global').parseInt;
  2. var $trim = require('./_string-trim').trim;
  3. var ws = require('./_string-ws');
  4. var hex = /^[-+]?0[xX]/;
  5. module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix) {
  6. var string = $trim(String(str), 3);
  7. return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
  8. } : $parseInt;