preloadstore.js 744 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* global MisagoData */
  2. export default function() {
  3. var initData = {};
  4. if (typeof MisagoData !== "undefined") {
  5. initData = MisagoData;
  6. }
  7. return {
  8. data: initData,
  9. has: function(key) {
  10. return this.data.hasOwnProperty(key);
  11. },
  12. get: function(key, value) {
  13. if (this.has(key)) {
  14. return this.data[key];
  15. } else if (value !== undefined) {
  16. return value;
  17. } else {
  18. return undefined;
  19. }
  20. },
  21. set: function(key, value) {
  22. this.data[key] = value;
  23. return value;
  24. },
  25. pop: function(key, value) {
  26. var returnValue = this.get(key, value);
  27. if (this.has(key)) {
  28. delete this.data[key];
  29. }
  30. return returnValue;
  31. }
  32. };
  33. }()