inline database destructure

This commit is contained in:
Sriram Hariharan
2023-09-17 14:28:45 -05:00
parent fcfda3a447
commit e2c9955b41

View File

@@ -24,11 +24,14 @@ export async function initializeDB(): Promise<Database> {
if (db) { if (db) {
return db; return db;
} }
const { Database } = await initSqlJs({
locateFile: file => WASM_FILE_URL,
});
const dbBuffer = await fetch(DB_FILE_URL).then(res => res.arrayBuffer()); const [{ Database }, dbBuffer] = await Promise.all([
initSqlJs({
locateFile: file => WASM_FILE_URL,
}),
fetch(DB_FILE_URL).then(res => res.arrayBuffer()),
]);
db = new Database(new Uint8Array(dbBuffer)); db = new Database(new Uint8Array(dbBuffer));
return db; return db;