mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-01-25 14:42:47 +00:00
优化判断是否是数字类字符串的实现方式
This commit is contained in:
parent
299462d7ce
commit
81ffdaf29c
@ -245,12 +245,9 @@ global.isDir = function(p){
|
||||
* @param {[type]} obj [description]
|
||||
* @return {Boolean} [description]
|
||||
*/
|
||||
var numberReg = /^((\d*\.?\d*(?:e[+-]?\d*(?:\d?\.?|\.?\d?)\d*)?)|(0[0-7]+)|(0x[0-9a-f]+))$/i;
|
||||
global.isNumberString = function(obj){
|
||||
var parseValue = parseFloat(obj);
|
||||
if (isNaN(parseValue)) {
|
||||
return false;
|
||||
};
|
||||
return (parseValue + "").length == (obj + "").length
|
||||
return numberReg.test(obj);
|
||||
}
|
||||
/**
|
||||
* 判断是否是个promise
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user