You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
417 B
15 lines
417 B
var isNum = require('./isNum'); |
|
var isObj = require('./isObj'); |
|
var isFn = require('./isFn'); |
|
var isStr = require('./isStr'); |
|
exports = function(val) { |
|
if (isNum(val)) return val; |
|
if (isObj(val)) { |
|
var temp = isFn(val.valueOf) ? val.valueOf() : val; |
|
val = isObj(temp) ? temp + '' : temp; |
|
} |
|
if (!isStr(val)) return val === 0 ? val : +val; |
|
return +val; |
|
}; |
|
|
|
module.exports = exports;
|
|
|