UNPKG

@yubing744/rooch-sdk

Version:
28 lines (27 loc) 1.03 kB
function applyMixin(targetClass, baseClass, baseClassProp) { Object.getOwnPropertyNames(baseClass.prototype).forEach((propertyName) => { const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass.prototype, propertyName); if (!propertyDescriptor) return; propertyDescriptor.value = function(...args) { return this[baseClassProp][propertyName](...args); }; Object.defineProperty(targetClass.prototype, propertyName, propertyDescriptor); }); Object.getOwnPropertyNames(baseClass).forEach((propertyName) => { const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass, propertyName); if (!propertyDescriptor) return; propertyDescriptor.value = function(...args) { return this[baseClassProp][propertyName](...args); }; if (targetClass.hasOwnProperty.call(targetClass, propertyName)) { return; } Object.defineProperty(targetClass, propertyName, propertyDescriptor); }); } export { applyMixin }; //# sourceMappingURL=mixin.js.map