How to use the localforage.keys 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 nscozzaro / physics-is-beautiful / courses / static / courses / js / containers / StudioViews / EditorsViews / containers / LessonWorkSpace / Codesandbox / sandbox-exe / eval / cache.ts View on Github external
const host = process.env.CODESANDBOX_HOST;

const MAX_CACHE_SIZE = 1024 * 1024 * 7;
let APICacheUsed = false;

try {
  localforage.config({
    name: 'CodeSandboxApp',
    storeName: 'sandboxes', // Should be alphanumeric, with underscores.
    description:
      'Cached transpilations of the sandboxes, for faster initialization time.',
  });

  // Prewarm store
  localforage.keys();
} catch (e) {
  console.warn('Problems initializing IndexedDB store.');
  console.warn(e);
}

function shouldSaveOnlineCache(firstRun: boolean, changes: number) {
  if (!firstRun || changes > 0) {
    return false;
  }

  if (!(window as any).__SANDBOX_DATA__) {
    return true;
  }

  return false;
}
github linnarsson-lab / loom-viewer / client / actions / request-projects.js View on Github external
export function uncacheDataset(dataset) {
	localforage.keys().then((keys) => {
		let matchingKeys = [];
		for (let i = 0; i < keys.length; i++) {
			let key = keys[i];
			// this covers both `${key}` and `${key}/genes` case
			if (key.startsWith(dataset.path)) {
				matchingKeys.push(key);
			}
		}
		return localforage.removeItems(matchingKeys);
	});

}
github morkro / happy-plants / src / main.js View on Github external
const isProduction = process.env.NODE_ENV === 'production'

/**
 * This is required as Webpack seems to do some static analysis
 * and breaking the module.
 * @see https://github.com/localForage/localForage-startsWith/issues/5
 */
extendPrototype(localforage)

localforage.config({
  name: 'happy-plants',
  driver: [localforage.INDEXEDDB, localforage.LOCALSTORAGE]
})

// Temporary fix to clean up DB.
localforage.keys()
  .then(keys => {
    if (keys.includes('undefined')) {
      localforage.removeItem('undefined')
    }
  })

/**
 * Vue configuration.
 */
Vue.config.productionTip = isProduction
Vue.config.devtools = true
Vue.config.errorHandler = errorHandler

VueTouch.registerCustomEvent('doubletap', {
  type: 'tap',
  taps: 2
github alfg / somafm / app / core / Storage.js View on Github external
exists(key, cb) {
    localforage.keys().then((keys) => {
      if (_.includes(keys, key)) {
        return cb(true);
      }
      return cb(false);
    })
    .catch((err) => {
      console.log(err);
      cb(false);
    });
  },
github 1j01 / mopaint / src / index.js View on Github external
const updateDocumentsList = () =>
	localforage.keys().then((keys) => {
		documentIDs = keys
			.map((key) => key.match(/document:([a-zA-Z0-9\-_]+):state/))
			.filter((key) => key)
			.map((key) => key[1]);
		render();
	});
github kaitai-io / kaitai_struct_webide / src / FileSystem / BrowserFileSystem.ts View on Github external
async list(uri: string): Promise {
        let keys = await localforage.keys();
        var fsKeys = keys.filter(x => x.startsWith("fs_file[")).map(x => "/" + x.substr(8, x.length - 9));
        return FsUri.getChildUris(fsKeys, new FsUri(uri)).map(childUri => new FsItem(childUri));
    }
}
github morkro / happy-plants / src / api / localforage.js View on Github external
export const getAllEntries = (loadEach = true) => {
  if (loadEach === false) {
    return localforage.keys()
  }

  return localforage.keys()
    .then(keys => Promise.all(keys.map(k => localforage.getItem(k))))
}
github brucou / cycle-state-machine-demo / src / index.js View on Github external
  .then(() => localForage.keys())
  .then(keys => Promise.all(keys.map(key => {