elearning/Frontend-Learner/node_modules/srvx/dist/_chunks/_inherit.mjs
2026-01-13 10:48:02 +07:00

31 lines
No EOL
907 B
JavaScript

//#region src/_inherit.ts
function lazyInherit(target, source, sourceKey) {
for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) {
if (key === "constructor") continue;
const targetDesc = Object.getOwnPropertyDescriptor(target, key);
const desc = Object.getOwnPropertyDescriptor(source, key);
let modified = false;
if (desc.get) {
modified = true;
desc.get = targetDesc?.get || function() {
return this[sourceKey][key];
};
}
if (desc.set) {
modified = true;
desc.set = targetDesc?.set || function(value) {
this[sourceKey][key] = value;
};
}
if (!targetDesc?.value && typeof desc.value === "function") {
modified = true;
desc.value = function(...args) {
return this[sourceKey][key](...args);
};
}
if (modified) Object.defineProperty(target, key, desc);
}
}
//#endregion
export { lazyInherit as t };