How to use the localforage.clear function in localforage

To help you get started, we’ve selected a few localforage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devinit / datahub / src / utils / index.ts View on Github external
export async function getLocalStorageInstance(): Promise {
  if (!process.browser) {
    return Promise.resolve(null);
  }
  try {
    const shouldPurge = await shouldPurgeCache();
    if (!shouldPurge) {
      return localforage;
    }
    await localforage.clear();
    await localforage.setItem('version', APP_VERSION);

    return localforage;
  } catch (error) {
    console.error(error, 'localforage: ');
    await localforage.clear(); // cache is possibly full so lets clear it

    return localforage;
  }
}
github sourcegraph / sourcegraph / extensions / enterprise / sandbox / src / util.ts View on Github external
import localforage from 'localforage'
import { from, Observable } from 'rxjs'
import { first } from 'rxjs/operators'
import * as sourcegraph from 'sourcegraph'

const USE_PERSISTENT_MEMOIZATION_CACHE = true

if (!USE_PERSISTENT_MEMOIZATION_CACHE) {
    // eslint-disable-next-line @typescript-eslint/no-floating-promises
    localforage.clear()
}

interface Cache {
    get(key: string): Promise
    set(key: string, value: T | Promise): Promise
    delete(key: string): Promise
}

const createMemoizationCache = (): Cache => {
    const map = new Map>()
    const cache: Cache = {
        get: (key): Promise => {
            const localValue = map.get(key)
            if (localValue !== undefined) {
                return localValue
            }
github tdlib / td / example / web / tdweb / src / worker.js View on Github external
localforage.INDEXEDDB,
      'memoryDriver',
      localforage.LOCALSTORAGE,
      localforage.WEBSQL,
      localForageDrivers
    ];
    for (const driverName of DRIVERS) {
      console.log('Test ', driverName);
      try {
        await localforage.setDriver(driverName);
        console.log('A');
        await localforage.setItem('hello', 'world');
        console.log('B');
        const x = await localforage.getItem('hello');
        console.log('got ', x);
        await localforage.clear();
        console.log('C');
      } catch (error) {
        console.log('Error', error);
      }
    }
  }
github CreativeBuilds / creative-bot / src / renderer / helpers / db / db.ts View on Github external
export const clearDatabase = async () => {
  return localforage.clear();
};
github mpigsley / sectors-without-number / src / store / api / local.js View on Github external
export const clearLocalDatabase = () => localForage.clear();
github mangalam-research / wed / build / standalone / lib / wed / files.js View on Github external
"associated with wed?", function (result) {
        if (!result)
            return;

        localforage.clear().then(function () {
            me._controller.scope().$apply('refresh()');
        });
    });
});
github webiny / Webiny / Js / Core / Lib / Core / IndexedDB.js View on Github external
IndexedDB.clear = function () {
    return localforage.clear();
};