Using standard es5 I have this method that allows me to add methods to my library's prototype chain (it allows extension of the core library and also any components that are attached to the library):
library.extend = function(extendId, extendObj) {
//if it's an extension of the core library object...
if(extendId === 'library') {
library.prototype[extendObj.name] = extendObj.func;
} else {
library.component[extendId].prototype[extendObj.name] = extendObj;
}
};
Usage would be:
/* create some new class */
var somecomponent = function() {}
somecomponent.protoype.somemethod = function() {}
/* extend the base libraries prototype chain with the new class*/
library.extend('library', somecomponent)
In es6 classes we also have prototypes but they are masked by the class syntax and you are supposed to add methods to the class using the extends method.
Because of this I'm not sure how I can programmatically add methods to es6 classes using a method similar to what I have above.