StorageController.default.js 557 B

123456789101112131415161718192021222324252627
  1. var memMap = {};
  2. var StorageController = {
  3. async: 0,
  4. getItem: function (path) {
  5. if (memMap.hasOwnProperty(path)) {
  6. return memMap[path];
  7. }
  8. return null;
  9. },
  10. setItem: function (path, value) {
  11. memMap[path] = String(value);
  12. },
  13. removeItem: function (path) {
  14. delete memMap[path];
  15. },
  16. getAllKeys: function () {
  17. return Object.keys(memMap);
  18. },
  19. clear: function () {
  20. for (var key in memMap) {
  21. if (memMap.hasOwnProperty(key)) {
  22. delete memMap[key];
  23. }
  24. }
  25. }
  26. };
  27. module.exports = StorageController;