gale/proxy.js

49 lines
980 B
JavaScript
Raw Normal View History

2025-02-21 07:55:08 -05:00
//const person = van.state({name:"seth", age:41});
//console.log(Object.hasOwn(person, "rawVal"));
const isLeaf =(obj, key)=>
{
const type = typeof arg;
if(arg == null || type == "")
{
}
}
2025-02-19 17:01:11 -05:00
/** @type {<T>(obj:T, key:string)=>T} */
const Deep =(obj, key)=>
{
2025-02-21 07:55:08 -05:00
2025-02-19 17:01:11 -05:00
const proxInner =(context, key)=> new Proxy({}, {
get(_, prop)
{
2025-02-21 07:55:08 -05:00
if(typeof prop === "string")
{
const path = key+" . "+prop;
console.log(path, "accessed!");
const value = context[prop];
return proxInner(value, path);
}
else
{
return context[prop]
}
2025-02-19 17:01:11 -05:00
}
});
const proxOuter = new Proxy({}, {
get(_, prop)
{
return proxInner(obj, prop);
},
set(_, prop, val)
{
obj[prop] = val;
}
});
return proxOuter;
}
export default Deep;