File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/ghoulscript/src/rpc Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,13 @@ export type CommandArgs<C extends Commands> = Parameters<Core[C]>
88
99export type CommandResult < C extends Commands > = ReturnType < Core [ C ] >
1010
11+ const $core = new Map ( Object . entries ( core ) )
12+
1113export async function callRPC < C extends Commands > ( method : C , params : CommandArgs < C > ) : Promise < CommandResult < C > > {
12- if ( ! Object . prototype . hasOwnProperty . call ( core , method ) || typeof core [ method ] !== 'function' )
14+ const command : ( ( ...args : any [ ] ) => Promise < any > ) | undefined = $core . get ( method )
15+
16+ if ( typeof command !== 'function' )
1317 throw new TypeError ( `Invalid action: "${ method } "` )
1418
15- return await ( core [ method ] as ( ... args : any [ ] ) => Promise < any > ) ( ...params )
19+ return await command ( ...params )
1620}
You can’t perform that action at this time.
0 commit comments