(str, i)
| 3490 | } |
| 3491 | |
| 3492 | function parseNumber(str, i) { |
| 3493 | var originalIdx = i; |
| 3494 | var num; |
| 3495 | var zero = str[i] === '1'; |
| 3496 | if (zero) { |
| 3497 | num = 0; |
| 3498 | i++; |
| 3499 | } else { |
| 3500 | var neg = str[i] === '0'; |
| 3501 | i++; |
| 3502 | var numAsString = ''; |
| 3503 | var magAsString = str.substring(i, i + MAGNITUDE_DIGITS); |
| 3504 | var magnitude = parseInt(magAsString, 10) + MIN_MAGNITUDE; |
| 3505 | /* istanbul ignore next */ |
| 3506 | if (neg) { |
| 3507 | magnitude = -magnitude; |
| 3508 | } |
| 3509 | i += MAGNITUDE_DIGITS; |
| 3510 | while (true) { |
| 3511 | var ch = str[i]; |
| 3512 | if (ch === '\u0000') { |
| 3513 | break; |
| 3514 | } else { |
| 3515 | numAsString += ch; |
| 3516 | } |
| 3517 | i++; |
| 3518 | } |
| 3519 | numAsString = numAsString.split('.'); |
| 3520 | if (numAsString.length === 1) { |
| 3521 | num = parseInt(numAsString, 10); |
| 3522 | } else { |
| 3523 | /* istanbul ignore next */ |
| 3524 | num = parseFloat(numAsString[0] + '.' + numAsString[1]); |
| 3525 | } |
| 3526 | /* istanbul ignore next */ |
| 3527 | if (neg) { |
| 3528 | num = num - 10; |
| 3529 | } |
| 3530 | /* istanbul ignore next */ |
| 3531 | if (magnitude !== 0) { |
| 3532 | // parseFloat is more reliable than pow due to rounding errors |
| 3533 | // e.g. Number.MAX_VALUE would return Infinity if we did |
| 3534 | // num * Math.pow(10, magnitude); |
| 3535 | num = parseFloat(num + 'e' + magnitude); |
| 3536 | } |
| 3537 | } |
| 3538 | return {num, length : i - originalIdx}; |
| 3539 | } |
| 3540 | |
| 3541 | // move up the stack while parsing |
| 3542 | // this function moved outside of parseIndexableString for performance |
no outgoing calls
no test coverage detected
searching dependent graphs…