node-web-mvc
Version:
node spring mvc
29 lines (28 loc) • 794 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const blacklist = ['length', 'name', 'prototype'];
function extendInstance(target, parentType, args, wrapper) {
const ParentClazz = parentType;
const parent = new ParentClazz(...args);
let proto = target.__proto__;
while (proto) {
if (proto.constructor == Object) {
break;
}
if (proto.constructor == wrapper) {
proto.__proto__ = parent;
}
proto = proto.__proto__;
}
}
function extendStatic(target, source) {
Reflect.ownKeys(source).forEach((k) => {
if (typeof k == 'string' && blacklist.indexOf(k) < 0) {
target[k] = source[k];
}
});
}
exports.default = {
extendInstance,
extendStatic,
};