Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
989 B
38 lines
989 B
![]()
3 years ago
|
export default function applyMixins(derivedCtor: any, constructors: any[]) {
|
||
|
const callbacks: Array<(...args: any[]) => any> = [];
|
||
|
|
||
|
constructors.forEach((baseCtor) => {
|
||
|
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
|
||
|
const value: PropertyDescriptor = Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null);
|
||
|
if(name === '_constructor') {
|
||
|
callbacks.push(value.value);
|
||
|
return;
|
||
|
} else if(name === 'constructor') {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Object.defineProperty(
|
||
|
derivedCtor.prototype,
|
||
|
name,
|
||
|
value
|
||
|
);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
if(callbacks.length) {
|
||
|
function c(...args: any[]): any {
|
||
|
callbacks.forEach((cb, idx) => {
|
||
|
// @ts-ignore
|
||
|
cb.apply(this, args[idx] || []);
|
||
|
});
|
||
|
};
|
||
|
|
||
|
Object.defineProperty(derivedCtor.prototype, 'superConstructor', {
|
||
|
configurable: true,
|
||
|
enumerable: true,
|
||
|
value: c,
|
||
|
writable: true
|
||
|
});
|
||
|
}
|
||
|
}
|