Last active
August 11, 2016 11:13
-
-
Save jpwilliams/1a6a8f2c32c5a7bf06f1a2884126014c to your computer and use it in GitHub Desktop.
For if you ever wanted to do something insane and pointless.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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