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.
32 lines
781 B
32 lines
781 B
import isArray from './is-array';
|
|
var clone = function (obj) {
|
|
if (typeof obj !== 'object' || obj === null) {
|
|
return obj;
|
|
}
|
|
var rst;
|
|
if (isArray(obj)) {
|
|
rst = [];
|
|
for (var i = 0, l = obj.length; i < l; i++) {
|
|
if (typeof obj[i] === 'object' && obj[i] != null) {
|
|
rst[i] = clone(obj[i]);
|
|
}
|
|
else {
|
|
rst[i] = obj[i];
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
rst = {};
|
|
for (var k in obj) {
|
|
if (typeof obj[k] === 'object' && obj[k] != null) {
|
|
rst[k] = clone(obj[k]);
|
|
}
|
|
else {
|
|
rst[k] = obj[k];
|
|
}
|
|
}
|
|
}
|
|
return rst;
|
|
};
|
|
export default clone;
|
|
//# sourceMappingURL=clone.js.map
|