From 93484f3900726cfbd9bf47ea2299029d21d22be7 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Fri, 21 Feb 2025 07:55:08 -0500 Subject: [PATCH] test fixes --- .vscode/settings.json | 4 ++++ proxy.js | 31 ++++++++++++++++++++++++------- proxy.test.ts | 5 +++-- 3 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b0c98a8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "deno.cacheOnSave": true, + "deno.codeLens.test": true +} \ No newline at end of file diff --git a/proxy.js b/proxy.js index 40d355e..7da72dc 100644 --- a/proxy.js +++ b/proxy.js @@ -1,17 +1,34 @@ -const person = van.state({name:"seth", age:41}); -console.log(Object.hasOwn(person, "rawVal")); +//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 == "") + { + + } +} /** @type {(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] + } } }); diff --git a/proxy.test.ts b/proxy.test.ts index e3323f2..a86ebae 100644 --- a/proxy.test.ts +++ b/proxy.test.ts @@ -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; + }); \ No newline at end of file