0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Remove obsolete file

This commit is contained in:
G.Ambatte
2024-10-10 08:57:41 +13:00
parent d5cda45d4d
commit 0deb9073cd

View File

@@ -1,80 +0,0 @@
import {
get as iGet,
getMany as iGetMany,
set as iSet,
setMany as iSetMany,
update as iUpdate,
del as iDel,
keys,
createStore,
Store
} from 'idb-keyval/dist/index.js'; // EcmaScript Module
const HOMEBREWERY_DB = 'HOMEBREWERY-DB';
const HOMEBREWERY_STORE = 'HOMEBREWERY-STORE';
let hbStore;
function init(){
if(hbStore) return true;
if(!hbStore && typeof window != 'undefined' && typeof window.indexedDB != 'undefined'){
hbStore = createStore(HOMEBREWERY_DB, HOMEBREWERY_STORE);
return true;
}
return false;
}
function checkFn(fn){
return init() && fn();
};
const get = checkFn(async (key)=>{
console.log('get:', key);
return iGet(key, hbStore);
});
const getMany = checkFn(async (keys)=>{
checkFn(async ()=>{
console.log('getMany:', keys);
return await iGetMany(keys, hbStore);
});
});
const set = checkFn(async (key, val)=>{
console.log('set:', key, val);
init();
return iSet(key, val, hbStore);
});
const setMany = checkFn(async (keyValArray)=>{
console.log('set:', keyValArray);
init();
return iSetMany(keyValArray, hbStore);
});
const update = checkFn(async (key, updateFn)=>{
init();
return iUpdate(key, updateFn, hbStore);
});
const remove = checkFn(async (key)=>{
console.log('remove:', key);
init();
return iDel(key, hbStore);
});
const list = checkFn(async ()=>{
init();
return await keys(hbStore);
});
module.exports = {
get,
getMany,
set,
setMany,
update,
remove,
list
};