mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-29 07:25:05 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
function set(obj, key, val) {
|
|
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === '__proto__') {
|
|
Object.defineProperty(obj, key, val);
|
|
} else obj[key] = val.value;
|
|
}
|
|
|
|
function klona(x) {
|
|
if (typeof x !== 'object') return x;
|
|
|
|
var i=0, k, list, tmp, str=Object.prototype.toString.call(x);
|
|
|
|
if (str === '[object Object]') {
|
|
tmp = Object.create(x.__proto__ || null);
|
|
} else if (str === '[object Array]') {
|
|
tmp = Array(x.length);
|
|
} else if (str === '[object Set]') {
|
|
tmp = new Set;
|
|
x.forEach(function (val) {
|
|
tmp.add(klona(val));
|
|
});
|
|
} else if (str === '[object Map]') {
|
|
tmp = new Map;
|
|
x.forEach(function (val, key) {
|
|
tmp.set(klona(key), klona(val));
|
|
});
|
|
} else if (str === '[object Date]') {
|
|
tmp = new Date(+x);
|
|
} else if (str === '[object RegExp]') {
|
|
tmp = new RegExp(x.source, x.flags);
|
|
} else if (str === '[object DataView]') {
|
|
tmp = new x.constructor( klona(x.buffer) );
|
|
} else if (str === '[object ArrayBuffer]') {
|
|
tmp = x.slice(0);
|
|
} else if (str.slice(-6) === 'Array]') {
|
|
// ArrayBuffer.isView(x)
|
|
// ~> `new` bcuz `Buffer.slice` => ref
|
|
tmp = new x.constructor(x);
|
|
}
|
|
|
|
if (tmp) {
|
|
for (list=Object.getOwnPropertySymbols(x); i < list.length; i++) {
|
|
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
}
|
|
|
|
for (i=0, list=Object.getOwnPropertyNames(x); i < list.length; i++) {
|
|
if (Object.hasOwnProperty.call(tmp, k=list[i]) && tmp[k] === x[k]) continue;
|
|
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
}
|
|
}
|
|
|
|
return tmp || x;
|
|
}
|
|
|
|
exports.klona = klona; |