createWebStorage.js 804 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = createWebStorage;
  4. var _getStorage = _interopRequireDefault(require("./getStorage"));
  5. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6. function createWebStorage(type) {
  7. var storage = (0, _getStorage.default)(type);
  8. return {
  9. getItem: function getItem(key) {
  10. return new Promise(function (resolve, reject) {
  11. resolve(storage.getItem(key));
  12. });
  13. },
  14. setItem: function setItem(key, item) {
  15. return new Promise(function (resolve, reject) {
  16. resolve(storage.setItem(key, item));
  17. });
  18. },
  19. removeItem: function removeItem(key) {
  20. return new Promise(function (resolve, reject) {
  21. resolve(storage.removeItem(key));
  22. });
  23. }
  24. };
  25. }