StorageController.weapp.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3. var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  4. /**
  5. * Copyright (c) 2015-present, Parse, LLC.
  6. * All rights reserved.
  7. *
  8. * This source code is licensed under the BSD-style license found in the
  9. * LICENSE file in the root directory of this source tree. An additional grant
  10. * of patent rights can be found in the PATENTS file in the same directory.
  11. *
  12. * @flow
  13. * @private
  14. */
  15. var StorageController = {
  16. async: 0,
  17. getItem: function (path
  18. /*: string*/
  19. )
  20. /*: ?string*/
  21. {
  22. return wx.getStorageSync(path);
  23. },
  24. setItem: function (path
  25. /*: string*/
  26. , value
  27. /*: string*/
  28. ) {
  29. try {
  30. wx.setStorageSync(path, value);
  31. } catch (e) {// Quota exceeded
  32. }
  33. },
  34. removeItem: function (path
  35. /*: string*/
  36. ) {
  37. wx.removeStorageSync(path);
  38. },
  39. getAllKeys: function () {
  40. var res = wx.getStorageInfoSync();
  41. return (0, _keys.default)(res);
  42. },
  43. clear: function () {
  44. wx.clearStorageSync();
  45. }
  46. };
  47. module.exports = StorageController;