function getNextLevel(dataObj, prop) {
const temp = {
"v": dataObj.v[prop],
"g": dataObj.g
}
return createPointerObject(temp)
}
function createPointerObject(dataObj) {
return new Proxy(dataObj, { get(obj, prop) {
if(typeof obj.v[prop] == "object"){
return getNextLevel(obj, prop)
} else {
return obj.g[obj.v[prop]]
}
}, set(obj, prop, value) {
obj.g[obj.v[prop]] = value
}})
}
const t = {
"v": {
"a": 0,
"b": 0,
"c": 1,
"d": {
"e": 1
}
},
"g": [
"Original",
"SomethingElse"
]
};
const v = createPointerObject(t);
v.c = "eple"
console.log(v.d.e)
//console.log(v.a, v.b, v.c)
//v.a = "Replace_"
//console.log(v.a, v.b, v.c)