Last active
September 27, 2016 03:57
-
-
Save saschanaz/55aaa80adb2eba58160b847026b5770d to your computer and use it in GitHub Desktop.
Partial class creator
This file contains hidden or 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 partial(base, extension) { | |
extension.prototype.__proto__ = base.prototype.__proto__; // to enable 'super' reference | |
const descriptors = Object.getOwnPropertyDescriptors(extension.prototype); | |
delete descriptors.constructor; // must not override constructor | |
Object.defineProperties(base.prototype, descriptors); | |
return base; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment