产品一张表luckysheet前端代码库
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.

56 lines
1.1 KiB

5 years ago
/**
* Common tool methods
*/
/**
* Determine whether a string is in standard JSON format
* @param {String} str
*/
function isJsonString(str) {
try {
if (typeof JSON.parse(str) == "object") {
return true;
}
} catch (e) { }
return false;
}
/**
* Determine whether a variable is a pure number, null/""/undefined/"34rt"/"34e" is not a number, 34/"34"/"34e10" is a number
* @param {Number | String | } val
*/
function isRealNum(val) {
if (val == null || val.toString().replace(/\s/g, "") === "") {
return false;
}
if (!isNaN(val)) {
return true;
} else {
return false;
}
}
5 years ago
/**
* extend two objects
* @param {Object } jsonbject1
* @param {Object } jsonbject2
*/
function common_extend(jsonbject1, jsonbject2) {
var resultJsonObject = {};
for (var attr in jsonbject1) {
resultJsonObject[attr] = jsonbject1[attr];
}
for (var attr in jsonbject2) {
resultJsonObject[attr] = jsonbject2[attr];
}
return resultJsonObject;
};
5 years ago
export {
isJsonString,
5 years ago
isRealNum,
common_extend
5 years ago
}