_baseToNumber.js 539 B

12345678910111213141516171819202122232425
  1. var isSymbol = require('./isSymbol');
  2. /** Used as references for various `Number` constants. */
  3. var NAN = 0 / 0;
  4. /**
  5. * The base implementation of `_.toNumber` which doesn't ensure correct
  6. * conversions of binary, hexadecimal, or octal string values.
  7. *
  8. * @private
  9. * @param {*} value The value to process.
  10. * @returns {number} Returns the number.
  11. */
  12. function baseToNumber(value) {
  13. if (typeof value == 'number') {
  14. return value;
  15. }
  16. if (isSymbol(value)) {
  17. return NAN;
  18. }
  19. return +value;
  20. }
  21. module.exports = baseToNumber;