IndexedDBStorageController.js 845 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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
  12. /*: string*/
  13. ) {
  14. return (0, _idbKeyval.get)(path, ParseStore);
  15. },
  16. setItemAsync(path
  17. /*: string*/
  18. , value
  19. /*: string*/
  20. ) {
  21. return (0, _idbKeyval.set)(path, value, ParseStore);
  22. },
  23. removeItemAsync(path
  24. /*: string*/
  25. ) {
  26. return (0, _idbKeyval.del)(path, ParseStore);
  27. },
  28. getAllKeysAsync() {
  29. return (0, _idbKeyval.keys)(ParseStore);
  30. },
  31. clear() {
  32. return (0, _idbKeyval.clear)(ParseStore);
  33. }
  34. };
  35. } else {
  36. // IndexedDB not supported
  37. module.exports = undefined;
  38. }