UNPKG

node-web-mvc

Version:
29 lines (28 loc) 794 B
"use strict"; 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, };