1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 02:58:09 +01:00
metamask-extension/app/scripts/lib/obj-proxy.js
2017-10-10 17:15:52 -07:00

19 lines
396 B
JavaScript

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