chore: improve code quality

chore: improve code quality
This commit is contained in:
idranme
2024-09-05 21:53:10 +08:00
parent e185e700b7
commit f93e2b5a95
18 changed files with 109 additions and 398 deletions

View File

@@ -108,7 +108,7 @@ interface InvokeOptions<ReturnType> {
}
export function invoke<
R extends Awaited<ReturnType<Extract<NTService[S][M], (...args: any) => any>>>,
R extends Awaited<ReturnType<Extract<NTService[S][M], (...args: any) => unknown>>>,
S extends keyof NTService = any,
M extends keyof NTService[S] & string = any
>(method: Extract<unknown, `${S}/${M}`> | string, args: unknown[], options: InvokeOptions<R> = {}) {
@@ -137,7 +137,7 @@ export function invoke<
const secondCallback = () => {
const hookId = registerReceiveHook<R>(options.cbCmd!, (payload) => {
// log(methodName, "second callback", cbCmd, payload, cmdCB);
if (!!options.cmdCB) {
if (options.cmdCB) {
if (options.cmdCB(payload, result)) {
removeReceiveHook(hookId)
success = true
@@ -174,7 +174,7 @@ export function invoke<
channel,
{
sender: {
send: (..._args: unknown[]) => {
send: () => {
},
},
},