mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
19 lines
396 B
JavaScript
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
|
|
}
|
|
} |