1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

util - add obj-proxy

This commit is contained in:
kumavis 2017-10-10 17:15:52 -07:00
parent e32d75965f
commit 7d50a56198

View File

@ -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
}
}