Skip to content

Commit 5b2844d

Browse files
committed
refactor: change tools from Map to Dict for improved type handling
- Updated the tools property in the Athena class from a Map to a Dict to streamline tool registration and retrieval. - Adjusted related methods to accommodate the new structure, enhancing code clarity and maintainability.
1 parent 4a9a889 commit 5b2844d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/core/athena.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ export class Athena extends EventEmitter {
9191
config: Dict<any>;
9292
states: Dict<Dict<any>>;
9393
plugins: Dict<PluginBase>;
94-
tools: Map<string, IAthenaTool<any, any>>;
94+
tools: Dict<IAthenaTool<any, any>>;
9595
events: Dict<IAthenaEvent>;
9696

9797
constructor(config: Dict<any>, states: Dict<Dict<any>>) {
9898
super();
9999
this.config = config;
100100
this.states = states;
101101
this.plugins = {};
102-
this.tools = new Map();
102+
this.tools = {};
103103
this.events = {};
104104
}
105105

@@ -180,15 +180,15 @@ export class Athena extends EventEmitter {
180180
if (tool.name in this.tools) {
181181
throw new Error(`Tool ${tool.name} already registered`);
182182
}
183-
this.tools.set(tool.name, tool as unknown as IAthenaTool<any, any>);
183+
this.tools[tool.name] = tool as unknown as IAthenaTool<any, any>;
184184
logger.warn(`Tool ${tool.name} is registered`);
185185
}
186186

187187
deregisterTool(name: string) {
188188
if (!(name in this.tools)) {
189189
throw new Error(`Tool ${name} not registered`);
190190
}
191-
this.tools.delete(name);
191+
delete this.tools[name];
192192
logger.warn(`Tool ${name} is deregistered`);
193193
}
194194

@@ -232,7 +232,7 @@ export class Athena extends EventEmitter {
232232
if (!(name in this.tools)) {
233233
throw new Error(`Tool ${name} not registered`);
234234
}
235-
const tool = this.tools.get(name);
235+
const tool = this.tools[name];
236236
if (!tool) {
237237
throw new Error(`Tool ${name} not found`);
238238
}

0 commit comments

Comments
 (0)