store.js 558 B

1234567891011121314151617181920212223242526
  1. define([], function() {
  2. 'use strict';
  3. return {
  4. get: function(key) {
  5. return window.localStorage[key];
  6. },
  7. set: function(key, value) {
  8. window.localStorage[key] = value;
  9. },
  10. getBool: function(key, def) {
  11. if (def !== void 0 && !this.exists(key)) {
  12. return def;
  13. }
  14. return window.localStorage[key] === 'true' ? true : false;
  15. },
  16. exists: function(key) {
  17. return window.localStorage[key] !== void 0;
  18. },
  19. delete: function(key) {
  20. window.localStorage.removeItem(key);
  21. }
  22. };
  23. });