tweb-i2p/src/helpers/object/safeReplaceObject.ts
Eduard Kuzmenko 37d5b2a9ad Peer-to-Peer calls
Refactor bigInt
Refactor factorizing
2022-03-23 17:15:07 +02:00

20 lines
393 B
TypeScript

export default function safeReplaceObject(wasObject: any, newObject: any) {
if(!wasObject) {
return newObject;
}
for(var key in wasObject) {
if(!newObject.hasOwnProperty(key)) {
delete wasObject[key];
}
}
for(var key in newObject) {
//if (newObject.hasOwnProperty(key)) { // useless
wasObject[key] = newObject[key];
//}
}
return wasObject;
}