perf: 优化定时器

This commit is contained in:
xiaojunnuo
2023-05-24 15:41:35 +08:00
parent 6f6606d76d
commit 3751fcd4c9
29 changed files with 381 additions and 163 deletions
@@ -4,23 +4,23 @@ export type Registrable = {
desc?: string;
};
export type RegistryItem = {
export type RegistryItem<T> = {
define: Registrable;
target: any;
target: T;
};
export class Registry {
export class Registry<T> {
storage: {
[key: string]: RegistryItem;
[key: string]: RegistryItem<T>;
} = {};
register(key: string, value: RegistryItem) {
register(key: string, value: RegistryItem<T>) {
if (!key || value == null) {
return;
}
this.storage[key] = value;
}
get(name: string): RegistryItem {
get(name: string): RegistryItem<T> {
if (!name) {
throw new Error("插件名称不能为空");
}