Skip to content

Instantly share code, notes, and snippets.

@jpwilliams
Last active August 11, 2016 11:13
Show Gist options
  • Save jpwilliams/1a6a8f2c32c5a7bf06f1a2884126014c to your computer and use it in GitHub Desktop.
Save jpwilliams/1a6a8f2c32c5a7bf06f1a2884126014c to your computer and use it in GitHub Desktop.
For if you ever wanted to do something insane and pointless.
function proxy () {
return new Proxy(function () {
return proxy()
}, {
apply (target, name) {
return proxy()
},
get (target, name) {
switch (name) {
case 'constructor':
return Function
break
case 'prototype':
return Function.prototype
break
case 'inspect':
return function () {
return {}
}
break
default:
if (typeof name === 'symbol') {
return function () {
return '{}'
}
}
return proxy()
}
}
})
}
var foo = proxy()
foo
foo()
foo.bar
foo().bar
foo.bar.baz.quux().woop
foo.things.are.looking(function (test) {
console.log('Yeehaw!')
}, 250).up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment