Very cool, but it didn’t quite work for me.
Pete Burkindine
13

With the inclusion of @mischamolhoek’s suggestion, it becomes like

export function mixIn(baseCtors: Function[]) {
return function (derivedCtor: Function) {
baseCtors.forEach((baseCtor) => {
const fieldCollector = {};
baseCtor.apply(fieldCollector);
Object.getOwnPropertyNames(fieldCollector).forEach((name) => {
derivedCtor.prototype[name] = fieldCollector[name];
})

Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
if (name !== 'constructor') {
derivedCtor.prototype[name] = baseCtor.prototype[name];
}
});
});
};
}
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.