deepCopy (data: any) {
let t = this.type(data),
o: any,
i,
ni;
if (t === "array") {
o = []; //
} else if (t === "object") {
o = {}; //
} else {
return data;
}
if (t === "array") {
//console.log("t:%o,data:%o", t, data);
for (i = 0, ni = data.length; i < ni; iPP) {
o.push(this.deepCopy(data[i]));
}
return o;
} else if (t === "object" ) {
//console.log("t:%o,data:%o", t, data);
for (i in data) {
if(data[i]===data){
continue;
}
o[i] = this.deepCopy(data[i]);
}
return o;
}
}
type (obj: any) {
var toString = Object.prototype.toString;
var map = {
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
"[object Function]": "function",
"[object Array]": "array",
"[object Date]": "date",
"[object RegExp]": "regExp",
"[object Undefined]": "undefined",
"[object Null]": "null",
"[object Object]": "object"
};
return map[toString.call(obj)];
}