MCPcopy Create free account
hub / github.com/Cicada000/VV / init

Function init

Web/script.js:6–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4 dbName: "vvSearchCache",
5 dbVersion: 1,
6 async init() {
7 if (this._dbPromise) return this._dbPromise;
8 this._dbPromise = new Promise((resolve, reject) => {
9 const request = indexedDB.open(this.dbName, this.dbVersion);
10 request.onerror = (event) => {
11 reject(event.target.error);
12 };
13 request.onsuccess = (event) => {
14 this.db = event.target.result;
15 resolve(this.db);
16 };
17 request.onupgradeneeded = (event) => {
18 const db = event.target.result;
19 if (!db.objectStoreNames.contains("indices"))
20 db.createObjectStore("indices", { keyPath: "key" });
21 if (!db.objectStoreNames.contains("mappings"))
22 db.createObjectStore("mappings", { keyPath: "key" });
23 if (!db.objectStoreNames.contains("databases"))
24 db.createObjectStore("databases", { keyPath: "key" });
25 };
26 });
27 return this._dbPromise;
28 },
29 async getItem(storeName, key) {
30 try {
31 await this.init();

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected