acdr-ui/dist/dev/mp-weixin/sheep/helper/utils.js

42 lines
980 B
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
function isArray(value) {
if (typeof Array.isArray === "function") {
return Array.isArray(value);
} else {
return Object.prototype.toString.call(value) === "[object Array]";
}
}
function isObject(value) {
return Object.prototype.toString.call(value) === "[object Object]";
}
function isEmpty(value) {
if (value === "" || value === void 0 || value === null) {
return true;
}
if (isArray(value)) {
return value.length === 0;
}
if (isObject(value)) {
return Object.keys(value).length === 0;
}
return false;
}
function cloneDeep(obj) {
const d = isArray(obj) ? [...obj] : {};
if (isObject(obj)) {
for (const key in obj) {
if (obj[key]) {
if (obj[key] && typeof obj[key] === "object") {
d[key] = cloneDeep(obj[key]);
} else {
d[key] = obj[key];
}
}
}
}
return d;
}
exports.cloneDeep = cloneDeep;
exports.isEmpty = isEmpty;
//# sourceMappingURL=utils.js.map