Forked from KoryNunn/gist:5c6cb954a6d9be930d2a9b873cc34797
Created
November 3, 2017 01:30
-
-
Save fud/cd432afe11549e051c7db9d8b184391f to your computer and use it in GitHub Desktop.
prototypical method binding Proxy
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 bindContext(object){ | |
return new Proxy({ | |
get: function(target, key){ | |
if(typeof target[key] === 'function' && !target.hasOwnProperty(key)){ | |
return target[key].bind(target); | |
} | |
return target[key]; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment