store.ts 374 B

123456789101112131415
  1. import Store from "electron-store"
  2. import { SETTINGS_STORE } from "./constants"
  3. const cache = new Map<string, Store>()
  4. export function getStore(name = SETTINGS_STORE) {
  5. const cached = cache.get(name)
  6. if (cached) return cached
  7. const next = new Store({ name, fileExtension: "" })
  8. cache.set(name, next)
  9. return next
  10. }
  11. export const store = getStore(SETTINGS_STORE)