UNPKG

1.46 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4
5var _map = require("babel-runtime/core-js/map");
6
7var _map2 = _interopRequireDefault(_map);
8
9var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
10
11var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
12
13var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn");
14
15var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
16
17var _inherits2 = require("babel-runtime/helpers/inherits");
18
19var _inherits3 = _interopRequireDefault(_inherits2);
20
21function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
23var Store = function (_Map) {
24 (0, _inherits3.default)(Store, _Map);
25
26 function Store() {
27 (0, _classCallCheck3.default)(this, Store);
28
29 var _this = (0, _possibleConstructorReturn3.default)(this, _Map.call(this));
30
31 _this.dynamicData = {};
32 return _this;
33 }
34
35 Store.prototype.setDynamic = function setDynamic(key, fn) {
36 this.dynamicData[key] = fn;
37 };
38
39 Store.prototype.get = function get(key) {
40 if (this.has(key)) {
41 return _Map.prototype.get.call(this, key);
42 } else {
43 if (Object.prototype.hasOwnProperty.call(this.dynamicData, key)) {
44 var val = this.dynamicData[key]();
45 this.set(key, val);
46 return val;
47 }
48 }
49 };
50
51 return Store;
52}(_map2.default);
53
54exports.default = Store;
55module.exports = exports["default"];
\No newline at end of file