parent
e32d75965f
commit
7d50a56198
@ -0,0 +1,19 @@ |
||||
module.exports = function createObjectProxy(obj) { |
||||
let target = obj |
||||
const proxy = new Proxy({}, { |
||||
get: (obj, name) => { |
||||
// intercept setTarget
|
||||
if (name === 'setTarget') return setTarget |
||||
return target[name] |
||||
}, |
||||
set: (obj, name, value) => { |
||||
target[name] = value |
||||
return true |
||||
}, |
||||
}) |
||||
return proxy |
||||
|
||||
function setTarget (obj) { |
||||
target = obj |
||||
} |
||||
} |
Loading…
Reference in new issue