IndexedDBStorageController.js 801 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. var _idbKeyval = require("idb-keyval");
  3. /**
  4. * @flow
  5. */
  6. /* global window */
  7. if (typeof window !== 'undefined' && window.indexedDB) {
  8. const ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
  9. module.exports = {
  10. async: 1,
  11. getItemAsync(path /*: string*/) {
  12. return (0, _idbKeyval.get)(path, ParseStore);
  13. },
  14. setItemAsync(path /*: string*/, value /*: string*/) {
  15. return (0, _idbKeyval.set)(path, value, ParseStore);
  16. },
  17. removeItemAsync(path /*: string*/) {
  18. return (0, _idbKeyval.del)(path, ParseStore);
  19. },
  20. getAllKeysAsync() {
  21. return (0, _idbKeyval.keys)(ParseStore);
  22. },
  23. clear() {
  24. return (0, _idbKeyval.clear)(ParseStore);
  25. }
  26. };
  27. } else {
  28. // IndexedDB not supported
  29. module.exports = undefined;
  30. }