StorageController.browser.js 866 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. /**
  3. * Copyright (c) 2015-present, Parse, LLC.
  4. * All rights reserved.
  5. *
  6. * This source code is licensed under the BSD-style license found in the
  7. * LICENSE file in the root directory of this source tree. An additional grant
  8. * of patent rights can be found in the PATENTS file in the same directory.
  9. *
  10. * @flow
  11. */
  12. /* global localStorage */
  13. const StorageController = {
  14. async: 0,
  15. getItem(path
  16. /*: string*/
  17. )
  18. /*: ?string*/
  19. {
  20. return localStorage.getItem(path);
  21. },
  22. setItem(path
  23. /*: string*/
  24. , value
  25. /*: string*/
  26. ) {
  27. try {
  28. localStorage.setItem(path, value);
  29. } catch (e) {// Quota exceeded, possibly due to Safari Private Browsing mode
  30. }
  31. },
  32. removeItem(path
  33. /*: string*/
  34. ) {
  35. localStorage.removeItem(path);
  36. },
  37. clear() {
  38. localStorage.clear();
  39. }
  40. };
  41. module.exports = StorageController;