avocado-old/packages/core/virtualize.js

32 lines
922 B
JavaScript
Raw Permalink Normal View History

2019-10-03 16:39:27 -05:00
export function virtualize(fields) {
return (Superclass) => {
class Virtualized extends Superclass {}
fields.forEach((field) => {
Virtualized.prototype[field] = function() {
const prototype = Object.getPrototypeOf(this);
const className = prototype.constructor.name;
throw new ReferenceError(
`"${className}" has undefined pure virtual method "${field}"`
);
}
});
return Virtualized;
}
}
export function virtualizeStatic(fields) {
return (Superclass) => {
class Virtualized extends Superclass {}
fields.forEach((field) => {
Virtualized[field] = function() {
const prototype = Virtualized.prototype;
const className = prototype.constructor.name;
throw new ReferenceError(
`"${className}" has undefined pure virtual static method "${field}"`
);
}
});
return Virtualized;
}
}