createWebStorage.js 600 B

123456789101112131415161718192021
  1. import getStorage from './getStorage';
  2. export default function createWebStorage(type) {
  3. var storage = getStorage(type);
  4. return {
  5. getItem: function getItem(key) {
  6. return new Promise(function (resolve, reject) {
  7. resolve(storage.getItem(key));
  8. });
  9. },
  10. setItem: function setItem(key, item) {
  11. return new Promise(function (resolve, reject) {
  12. resolve(storage.setItem(key, item));
  13. });
  14. },
  15. removeItem: function removeItem(key) {
  16. return new Promise(function (resolve, reject) {
  17. resolve(storage.removeItem(key));
  18. });
  19. }
  20. };
  21. }