Created
November 17, 2017 02:35
-
-
Save techanon/ea2b4024d976814d4d68f78835fafc90 to your computer and use it in GitHub Desktop.
Proxy protocol on the fly.
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
class T { | |
constructor(){ | |
this.value = 'test'; | |
} | |
test() { | |
return this.value + '-amend'; | |
} | |
wrap() { | |
return proxy(this.test).bind(this); | |
} | |
} | |
function proxy(target) { | |
return new Proxy(target,{apply(T,that,args){ return T.bind(that)()+'-proxy'; }}) | |
} | |
// let t = new T(); | |
// t.test(); | |
// >> 'test-amend' | |
// t.wrap()(); | |
// >> 'test-amend-proxy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment