Skip to content

Instantly share code, notes, and snippets.

@saschanaz
Last active September 27, 2016 03:57
Show Gist options
  • Save saschanaz/55aaa80adb2eba58160b847026b5770d to your computer and use it in GitHub Desktop.
Save saschanaz/55aaa80adb2eba58160b847026b5770d to your computer and use it in GitHub Desktop.
Partial class creator
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