32 lines
922 B
JavaScript
32 lines
922 B
JavaScript
|
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;
|
||
|
}
|
||
|
}
|