super-proxy
v0.0.2
Published
`superProxy` is a function that returns a function/object that has *every* property as a recursive version of itself. This is useful if you want to fake that an object exists but you want to remove the behaviour.
Downloads
7
Readme
super-proxy
superProxy is a function that returns a function/object that has every property as a recursive version of itself. This is useful if you want to fake that an object exists but you want to remove the behaviour.
Installation
In a browser
<script src="http://unpkg.com/[email protected]/umd/super-proxy.js"></script>With npm
npm install super-proxyUsage
const foo = superProxy()
foo.bar // this is okay
foo.bar() // also okay
new foo.bar().baz // all of this is okayUse Case Example
Let's say you have loaded Segment with a script tag and in your application you have many calls to window.analytics.track that you would like to skip.
With super-proxy you can do:
window.analytics = superProxy()
window.analytics.identify(...) // this does nothing now
window.analytics.track(...) // same here
window.analytics.whatever(...) // there is no tracking!