first
This commit is contained in:
22
node_modules/vant/es/utils/deep-clone.js
generated
vendored
Normal file
22
node_modules/vant/es/utils/deep-clone.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import { isDef } from './index';
|
||||
export function deepClone(obj) {
|
||||
if (!isDef(obj)) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(function (item) {
|
||||
return deepClone(item);
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
var to = {};
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
to[key] = deepClone(obj[key]);
|
||||
});
|
||||
return to;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
Reference in New Issue
Block a user