-
-
Save joaquimnetocel/c46ff8c7e2f6cd5e5176a0c7cc75859e to your computer and use it in GitHub Desktop.
Revisions
-
jherr created this gist
Sep 22, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ export function runify(obj) { if(Array.isArray(obj)) { return obj.map(runify); } else if(typeof obj === 'object') { let rune = $state(obj); let output = {}; for(let key in rune) { if(typeof obj[key] === 'object') { obj[key] = runify(obj[key]); } Object.defineProperty(output, key, { get() { return rune[key]; }, set(val) { console.log('setting', key, val); rune[key] = val; }, enumerable: true, }); } return output; } else { return obj; } }