1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/app/scripts/lib/obj-proxy.js

19 lines
396 B
JavaScript
Raw Normal View History

2017-10-11 02:15:52 +02:00
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
}
}