1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 02:01:51 +00:00

Add Extending of Class's Constructor

This commit is contained in:
Bagel03 2022-01-24 12:10:45 -05:00 committed by GitHub
parent 431453f1a2
commit bdd19405cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -483,6 +483,22 @@ export class ModInterface {
this.extendObject(classHandle.prototype, extender);
}
/**
* Creates a new class that extends another class (DOES NOT OVERWRITE)
*
* @template {constructable} C
* @param {C} classHandle
* @param {bindThis<(...args: ConstructorParameters<C>) => any, InstanceType<C>>} constructor
*/
extendConstructor(classHandle, constructor) {
return function (...args) {
const obj = new classHandle();
//@ts-ignore
constructor.apply(obj, args);
return obj;
};
}
/**
*
* @param {string} id