How to use the idb-keyval.set function in idb-keyval

To help you get started, we’ve selected a few idb-keyval 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 ipfs-shipyard / service-worker-gateway / src / index.js View on Github external
.then((ipfs) => {
      ipfsNode = ipfs

      // Keep a record of the start date and time of the IPFS Node
      const d = new Date()

      set('fetched-cids', [])
      set('start-date-time', {
        date: getFormattedDate(d),
        time: getFormattedTime(d)
      })
    })
    .catch((err) => console.err(err))
github jpodwys / preact-journal / client / js / app-state / index.js View on Github external
const observe = (obj, prop, next, prev) => {
  switch(prop) {
    case 'view': {
      // obj.entry = undefined;
      obj.dialogMode = '';
      if(prev === '/search' && next === '/entries'){
        fire('clearFilters');
      }
      return;
    }
    case 'entries': {
      obj.entries = sortObjectsByDate(next);
      set('entries', obj.entries);
      return;
    }
    case 'dark':        {
      localStorage.setItem('dark', !!next);
      const func = next ? 'add' : 'remove';
      document.body.classList[func]('dark');
      return;
    }
    case 'timestamp':   localStorage.setItem('timestamp', next);   return;
  }
};
github DestinyItemManager / DIM / src / app / manifest / d1-manifest-service.ts View on Github external
private async saveManifestToIndexedDB(typedArray: object, version: string) {
    try {
      await set(this.idbKey, typedArray);
      console.log(`Sucessfully stored manifest file.`);
      localStorage.setItem(this.localStorageKey, version);
    } catch (e) {
      console.error('Error saving manifest file', e);
      showNotification({
        title: t('Help.NoStorage'),
        body: t('Help.NoStorageMessage'),
        type: 'error'
      });
    }
  }
github DestinyItemManager / DIM / src / app / manifest / manifest-service.ts View on Github external
private async saveManifestToIndexedDB(typedArray: Uint8Array, version: string) {
    try {
      await set(this.idbKey, typedArray);
      console.log(`Sucessfully stored ${typedArray.length} byte manifest file.`);
      localStorage.setItem(this.localStorageKey, version);
    } catch (e) {
      console.error('Error saving manifest file', e);
      showNotification({
        title: t('Help.NoStorage'),
        body: t('Help.NoStorageMessage'),
        type: 'error'
      });
    }
  }
github DestinyItemManager / DIM / src / app / manifest / manifest-service-json.ts View on Github external
private async saveManifestToIndexedDB(
    typedArray: object,
    version: string,
    tableWhitelist: string[]
  ) {
    try {
      await set(this.idbKey, typedArray);
      console.log(`Sucessfully stored manifest file.`);
      localStorage.setItem(this.localStorageKey, version);
      localStorage.setItem(this.localStorageKey + '-whitelist', JSON.stringify(tableWhitelist));
    } catch (e) {
      console.error('Error saving manifest file', e);
      showNotification({
        title: t('Help.NoStorage'),
        body: t('Help.NoStorageMessage'),
        type: 'error'
      });
    }
  }
github jkk / shinkgs / src / model / AppStore.js View on Github external
saveState = (saveKey: string, prepareSavedState?: AppState => AppState) => {
    let saveState = {...this.getState(), savedAt: new Date()};
    if (prepareSavedState) {
      saveState = prepareSavedState(saveState);
    }
    if (this._debug) {
      console.log('Saving app state...', {state: saveState});
    }
    idbKeyval.set(saveKey, saveState);
  }
github PolymerLabs / actor-boilerplate / src / actors / storage.ts View on Github external
async [MessageType.SAVE](msg: SaveMessage) {
    await set("todos", msg.todos);
  }
}
github jgw96 / web-whiteboard / src / components / app-home / app-home.tsx View on Github external
async checkMGT() {
    await import('../../mgt.js');
    this.mgtLoaded = true;

    await set('webboardLoggedIn', true);
  }

idb-keyval

A super-simple-small keyval store built on top of IndexedDB

Apache-2.0
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis