mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 20:37:48 +00:00
Simplify isNumber.
This commit is contained in:
@@ -10233,15 +10233,12 @@
|
|||||||
* // => 3
|
* // => 3
|
||||||
*/
|
*/
|
||||||
function toNumber(value) {
|
function toNumber(value) {
|
||||||
if (!value) {
|
|
||||||
return value === 0 ? value : +value;
|
|
||||||
}
|
|
||||||
if (isObject(value)) {
|
if (isObject(value)) {
|
||||||
var other = isFunction(value.valueOf) ? value.valueOf() : value;
|
var other = isFunction(value.valueOf) ? value.valueOf() : value;
|
||||||
value = isObject(other) ? (other + '') : other;
|
value = isObject(other) ? (other + '') : other;
|
||||||
}
|
}
|
||||||
if (typeof value == 'number' || !isString(value)) {
|
if (typeof value != 'string') {
|
||||||
return +value;
|
return value === 0 ? value : +value;
|
||||||
}
|
}
|
||||||
value = value.replace(reTrim, '');
|
value = value.replace(reTrim, '');
|
||||||
var isBinary = reIsBinary.test(value);
|
var isBinary = reIsBinary.test(value);
|
||||||
|
|||||||
Reference in New Issue
Block a user