Skip to content

Commit

Permalink
fix(Cache): handle the value read from the db correctly according to …
Browse files Browse the repository at this point in the history
…its type (#620)
  • Loading branch information
WhiteMinds authored Mar 25, 2024
1 parent e6f1f07 commit 3170659
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/platform/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ class Cache implements ICache {
const request = db.transaction('kv-store', 'readonly').objectStore('kv-store').get(key);
request.onerror = reject;
request.onsuccess = function () {
const result: Uint8Array | undefined = this.result?.v;
resolve(result ? result.buffer : undefined);
const result: unknown = this.result?.v;
if (result instanceof ArrayBuffer) {
resolve(result);
} else if (ArrayBuffer.isView(result)) {
resolve(result.buffer);
} else {
resolve(undefined);
}
};
});
}
Expand Down

0 comments on commit 3170659

Please sign in to comment.