StorageController.browser.js 851 B

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