2c8595098c
git-svn-id: http://google-refine.googlecode.com/svn/trunk@883 7d457c2a-affb-35e4-300a-418c747d4874
23 lines
512 B
JavaScript
23 lines
512 B
JavaScript
function cloneDeep(o) {
|
|
if (o === undefined || o === null) {
|
|
return o;
|
|
} else if (o instanceof Function) {
|
|
return o;
|
|
} else if (o instanceof Array) {
|
|
var a = [];
|
|
for (var i = 0; i < o.length; i++) {
|
|
a.push(cloneDeep(o[i]));
|
|
}
|
|
return a;
|
|
} else if (o instanceof Object) {
|
|
var a = {};
|
|
for (var n in o) {
|
|
if (o.hasOwnProperty(n)) {
|
|
a[n] = cloneDeep(o[n]);
|
|
}
|
|
}
|
|
return a;
|
|
} else {
|
|
return o;
|
|
}
|
|
} |