feat(shell): api: support api.has()

This commit is contained in:
Il Harper 2024-09-07 14:24:14 +08:00
parent f62febad1e
commit 73164c4cdc
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC

View File

@ -21,6 +21,8 @@ export type Api = {
method: M,
impl: (...args: Methods[M][0]) => Promise<Methods[M][1]>,
) => void
has: <M extends keyof Methods>(method: M) => boolean
}
const buildNotimpl = (name: string) => {
@ -74,3 +76,5 @@ api.register =
api[method].engine = engine
api[method].priority = newPriority
}
api.has = <M extends keyof Methods>(method: M) => !api[method].notimpl