Skip to content

Commit

Permalink
chore(web): typo
Browse files Browse the repository at this point in the history
  • Loading branch information
lainio24 authored May 10, 2024
1 parent 43b94e4 commit 9913c85
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const DB_NAME = 'banciyuan-archive';
const DB_INDEX_CACHE = 'index';

async function database() {
return new Promise((reslove: (db: IDBDatabase) => void, reject) => {
return new Promise((resolve: (db: IDBDatabase) => void, reject) => {
const req = window.indexedDB.open(DB_NAME, DATA_VERSION);
req.onerror = reject;
req.onupgradeneeded = (ev) => {
Expand All @@ -24,7 +24,7 @@ async function database() {
db.createObjectStore(type, { keyPath: 'id' });
}
};
req.onsuccess = (_) => reslove(req.result);
req.onsuccess = (_) => resolve(req.result);
});
}

Expand All @@ -34,30 +34,30 @@ async function objectStore(name: string, mode?: IDBTransactionMode) {
(db) =>
new Promise(
(
reslove: (db: IDBObjectStore) => void,
resolve: (db: IDBObjectStore) => void,
reject //
) => {
const tr = db.transaction(name, mode);
reslove(tr.objectStore(name));
resolve(tr.objectStore(name));
tr.onerror = reject;
}
)
);
}

async function dbGet(store: IDBObjectStore, key: IDBValidKey | IDBKeyRange) {
return new Promise((reslove: (db: any) => void, reject) => {
return new Promise((resolve: (db: any) => void, reject) => {
const res = store.get(key);
res.onerror = reject;
res.onsuccess = (_) => reslove(res.result);
res.onsuccess = (_) => resolve(res.result);
});
}

async function dbPut(store: IDBObjectStore, value: any, key?: IDBValidKey) {
return new Promise((reslove: (db: IDBValidKey) => void, reject) => {
return new Promise((resolve: (db: IDBValidKey) => void, reject) => {
const res = store.put(value, key);
res.onerror = reject;
res.onsuccess = (_) => reslove(res.result);
res.onsuccess = (_) => resolve(res.result);
});
}

Expand Down

0 comments on commit 9913c85

Please sign in to comment.