feat: add OTP plugin

This commit is contained in:
dswbx
2025-11-06 20:03:02 +01:00
parent 4575d89cfe
commit ff86240b0e
4 changed files with 491 additions and 0 deletions

View File

@@ -77,3 +77,19 @@ export function threw(fn: () => any, instance?: new (...args: any[]) => Error) {
return true;
}
}
export async function threwAsync(fn: Promise<any>, instance?: new (...args: any[]) => Error) {
try {
await fn;
return false;
} catch (e) {
if (instance) {
if (e instanceof instance) {
return true;
}
// if instance given but not what expected, throw
throw e;
}
return true;
}
}