Dependency upgrade + lib_um_crypto_rust (#78)

Co-authored-by: 鲁树人 <lu.shuren@um-react.app>
Co-committed-by: 鲁树人 <lu.shuren@um-react.app>
This commit is contained in:
鲁树人
2024-09-24 22:19:30 +00:00
committed by 鲁树人
parent c5bc436ab2
commit 58c96f264b
65 changed files with 4160 additions and 4025 deletions

View File

@@ -0,0 +1,17 @@
import { isPromise } from 'radash';
export function withWasmClass<T extends { free: () => void }, R>(instance: T, cb: (inst: T) => R): R {
let isAsync = false;
try {
const resp = cb(instance);
if (resp && isPromise(resp)) {
isAsync = true;
resp.finally(() => instance.free());
}
return resp;
} finally {
if (!isAsync) {
instance.free();
}
}
}