MCPcopy Create free account
hub / github.com/RubyLouvre/anu / toNumber

Function toNumber

test/babel.js:55200–55217  ·  view source on GitHub ↗

* Converts `value` to a number. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {number} Returns the number. * @example * * _.toNumber(3.2); * // => 3.2 * * _.toNumber(Number.MIN_VALUE); * // => 5e-324 * *

(value)

Source from the content-addressed store, hash-verified

55198 * // => 3.2
55199 */
55200 function toNumber(value) {
55201 if (typeof value == 'number') {
55202 return value;
55203 }
55204 if (isSymbol(value)) {
55205 return NAN;
55206 }
55207 if (isObject(value)) {
55208 var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
55209 value = isObject(other) ? other + '' : other;
55210 }
55211 if (typeof value != 'string') {
55212 return value === 0 ? value : +value;
55213 }
55214 value = value.replace(reTrim, '');
55215 var isBinary = reIsBinary.test(value);
55216 return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
55217 }
55218
55219 module.exports = toNumber;
55220

Callers 1

toFiniteFunction · 0.85

Calls 2

isSymbolFunction · 0.70
isObjectFunction · 0.70

Tested by

no test coverage detected