mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: bail: change to async
This commit is contained in:
1 parent
8c83a79bee
commit
c184d94dae
2 files changed
+4
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.29.20",
|
||||
"version": "2.29.21",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -173,11 +173,12 @@ export async function serial<K extends keyof EventMap>(name: K, ...args: Paramet
|
||||
}
|
||||
}
|
||||
|
||||
export function bail<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): ReturnType<EventMap[K]> {
|
||||
export async function bail<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): ReturnType<EventMap[K]> {
|
||||
if (argv.options.showBus && name !== 'message/log') logger.debug('bail: %s %o', name, args);
|
||||
const hooks = Array.from(_hooks[name] || []);
|
||||
for (const callback of hooks) {
|
||||
const result = callback.apply(this, args);
|
||||
let result = callback.apply(this, args);
|
||||
if (result instanceof Promise) result = await result;
|
||||
if (isBailed(result)) return result;
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user