grammy-class-composer
Version:
A simple composer to use Grammy js in a more Object oriented way
34 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createOrFindClassEntry = exports.MethodType = exports.ClassEntry = exports.classEntries = void 0;
exports.classEntries = [];
class ClassEntry {
constructor(instance, constructor) {
this.instance = instance;
this.classConstructor = constructor;
this.entries = [];
}
findEntryByType(type) {
return this.entries.filter(entry => entry.type == type);
}
}
exports.ClassEntry = ClassEntry;
var MethodType;
(function (MethodType) {
MethodType[MethodType["COMMAND"] = 0] = "COMMAND";
MethodType[MethodType["INLINE"] = 1] = "INLINE";
MethodType[MethodType["AFTER_CONSTRUCT"] = 2] = "AFTER_CONSTRUCT";
MethodType[MethodType["HEARS"] = 3] = "HEARS";
MethodType[MethodType["ON"] = 4] = "ON";
})(MethodType = exports.MethodType || (exports.MethodType = {}));
function createOrFindClassEntry(target) {
let classEntry = exports.classEntries.filter(classInstance => classInstance.constructor == target.constructor)[0];
if (!classEntry) {
const classInstance = new target.constructor();
classEntry = new ClassEntry(classInstance, target.constructor);
exports.classEntries.push(classEntry);
}
return classEntry;
}
exports.createOrFindClassEntry = createOrFindClassEntry;
//# sourceMappingURL=Registry.js.map