1 |
|
2 | var LocalStorage =
|
3 | (function(modules) {
|
4 |
|
5 | var installedModules = {};
|
6 |
|
7 |
|
8 | function __webpack_require__(moduleId) {
|
9 |
|
10 |
|
11 | if(installedModules[moduleId]) {
|
12 | return installedModules[moduleId].exports;
|
13 | }
|
14 |
|
15 | var module = installedModules[moduleId] = {
|
16 | i: moduleId,
|
17 | l: false,
|
18 | exports: {}
|
19 | };
|
20 |
|
21 |
|
22 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
23 |
|
24 |
|
25 | module.l = true;
|
26 |
|
27 |
|
28 | return module.exports;
|
29 | }
|
30 |
|
31 |
|
32 |
|
33 | __webpack_require__.m = modules;
|
34 |
|
35 |
|
36 | __webpack_require__.c = installedModules;
|
37 |
|
38 |
|
39 | __webpack_require__.d = function(exports, name, getter) {
|
40 | if(!__webpack_require__.o(exports, name)) {
|
41 | Object.defineProperty(exports, name, {
|
42 | configurable: false,
|
43 | enumerable: true,
|
44 | get: getter
|
45 | /******/ });
|
46 | /******/ }
|
47 | /******/ };
|
48 | /******/
|
49 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
50 | /******/ __webpack_require__.n = function(module) {
|
51 | var getter = module && module.__esModule ?
|
52 | function getDefault() { return module['default']; } :
|
53 | function getModuleExports() { return module; };
|
54 | __webpack_require__.d(getter, 'a', getter);
|
55 | return getter;
|
56 | };
|
57 |
|
58 |
|
59 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
60 |
|
61 |
|
62 | __webpack_require__.p = "";
|
63 |
|
64 |
|
65 | return __webpack_require__(__webpack_require__.s = 3);
|
66 | })
|
67 |
|
68 | ([
|
69 | ,
|
70 | ,
|
71 | ,
|
72 |
|
73 | (function(module, exports, __webpack_require__) {
|
74 |
|
75 | "use strict";
|
76 |
|
77 |
|
78 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
79 |
|
80 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
81 |
|
82 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
83 |
|
84 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
85 |
|
86 |
|
87 | var Base = __webpack_require__(4);
|
88 |
|
89 | var LocalStorage = function (_Base) {
|
90 | _inherits(LocalStorage, _Base);
|
91 |
|
92 | function LocalStorage() {
|
93 | _classCallCheck(this, LocalStorage);
|
94 |
|
95 | return _possibleConstructorReturn(this, (LocalStorage.__proto__ || Object.getPrototypeOf(LocalStorage)).apply(this, arguments));
|
96 | }
|
97 |
|
98 | _createClass(LocalStorage, [{
|
99 | key: 'read',
|
100 | value: function read() {
|
101 | var data = localStorage.getItem(this.source);
|
102 | if (data) {
|
103 | return this.deserialize(data);
|
104 | } else {
|
105 | localStorage.setItem(this.source, this.serialize(this.defaultValue));
|
106 | return this.defaultValue;
|
107 | }
|
108 | }
|
109 | }, {
|
110 | key: 'write',
|
111 | value: function write(data) {
|
112 | localStorage.setItem(this.source, this.serialize(data));
|
113 | }
|
114 | }]);
|
115 |
|
116 | return LocalStorage;
|
117 | }(Base);
|
118 |
|
119 | module.exports = LocalStorage;
|
120 |
|
121 | }),
|
122 |
|
123 | (function(module, exports, __webpack_require__) {
|
124 |
|
125 | "use strict";
|
126 |
|
127 |
|
128 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
129 |
|
130 | var stringify = __webpack_require__(5);
|
131 |
|
132 | var Base = function Base(source) {
|
133 | var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
134 | _ref$defaultValue = _ref.defaultValue,
|
135 | defaultValue = _ref$defaultValue === undefined ? {} : _ref$defaultValue,
|
136 | _ref$serialize = _ref.serialize,
|
137 | serialize = _ref$serialize === undefined ? stringify : _ref$serialize,
|
138 | _ref$deserialize = _ref.deserialize,
|
139 | deserialize = _ref$deserialize === undefined ? JSON.parse : _ref$deserialize;
|
140 |
|
141 | _classCallCheck(this, Base);
|
142 |
|
143 | this.source = source;
|
144 | this.defaultValue = defaultValue;
|
145 | this.serialize = serialize;
|
146 | this.deserialize = deserialize;
|
147 | };
|
148 |
|
149 | module.exports = Base;
|
150 |
|
151 | }),
|
152 |
|
153 | (function(module, exports, __webpack_require__) {
|
154 |
|
155 | "use strict";
|
156 |
|
157 |
|
158 |
|
159 | module.exports = function stringify(obj) {
|
160 | return JSON.stringify(obj, null, 2);
|
161 | };
|
162 |
|
163 | })
|
164 | ]); |
\ | No newline at end of file |