deep-proxy #1

Merged
SethTrowbridge merged 16 commits from deep-proxy into master 2025-02-22 17:28:43 -05:00
3 changed files with 20 additions and 7 deletions
Showing only changes of commit 62c8351b24 - Show all commits

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"deno.cacheOnSave": true,
"deno.codeLens.test": true
}

View File

@ -4,14 +4,22 @@
/** @type {<T>(obj:T, key:string)=>T} */
const Deep =(obj, key)=>
{
const proxInner =(context, key)=> new Proxy({}, {
get(_, prop)
{
const path = key+" . "+prop;
console.log(path, "accessed!");
const value = context[key];
return proxInner(value, path);
if(typeof prop === "string")
{
const path = key+" . "+prop;
console.log(path, "accessed!");
const value = context[prop];
return proxInner(value, path);
}
else
{
return context[prop]
}
}
});

View File

@ -4,6 +4,7 @@ import Deep from "./proxy.js";
Deno.test("proxy", ()=>{
const d1 = Deep({name:"seth", age:41, tags:[]}, "p1");
const dig = d1.name.other;
const dig2 = dig.so.deep;
const dig = d1.name;
//const dig2 = dig.so.deep;
});