mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Merge pull request #538 from MetaMask/i512
deps - extracted ensnare to module
This commit is contained in:
commit
4572e689cf
@ -1,5 +1,5 @@
|
||||
const once = require('once')
|
||||
const ensnare = require('./ensnare.js')
|
||||
const ensnare = require('ensnare')
|
||||
|
||||
module.exports = setupDappAutoReload
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
module.exports = ensnare
|
||||
|
||||
// creates a proxy object that calls cb everytime the obj's properties/fns are accessed
|
||||
function ensnare (obj, cb) {
|
||||
var proxy = {}
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var val = obj[key]
|
||||
switch (typeof val) {
|
||||
case 'function':
|
||||
proxy[key] = function () {
|
||||
cb()
|
||||
val.apply(obj, arguments)
|
||||
}
|
||||
return
|
||||
default:
|
||||
Object.defineProperty(proxy, key, {
|
||||
get: function () { cb(); return obj[key] },
|
||||
set: function (val) { cb(); obj[key] = val; return val },
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
return proxy
|
||||
}
|
@ -35,6 +35,7 @@
|
||||
"debounce": "^1.0.0",
|
||||
"dnode": "^1.2.2",
|
||||
"end-of-stream": "^1.1.0",
|
||||
"ensnare": "^1.0.0",
|
||||
"eth-bin-to-ops": "^1.0.0",
|
||||
"eth-lightwallet": "^2.3.3",
|
||||
"eth-query": "^1.0.3",
|
||||
|
Loading…
Reference in New Issue
Block a user