1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | 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; }; }();
|
8 |
|
9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var Bucket = function () {
|
18 | function Bucket() {
|
19 | _classCallCheck(this, Bucket);
|
20 |
|
21 | this._data = {};
|
22 | }
|
23 |
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 | _createClass(Bucket, [{
|
35 | key: 'has',
|
36 | value: function has(key) {
|
37 | return this._data.hasOwnProperty(key);
|
38 | }
|
39 |
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | }, {
|
47 | key: 'getAll',
|
48 | value: function getAll() {
|
49 | return this._data;
|
50 | }
|
51 |
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 | }, {
|
58 | key: 'get',
|
59 | value: function get(key) {
|
60 | return this._data[key];
|
61 | }
|
62 |
|
63 | |
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | }, {
|
71 | key: 'set',
|
72 | value: function set(key, value) {
|
73 | this._data[key] = value;
|
74 | }
|
75 |
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 | }, {
|
82 | key: 'add',
|
83 | value: function add(key, value) {
|
84 | if (!this._data.hasOwnProperty(key)) {
|
85 | this._data[key] = value;
|
86 | return;
|
87 | }
|
88 |
|
89 | if (Object.prototype.toString.call(this._data[key]) != '[object Array]') {
|
90 | this._data[key] = [this._data[key]];
|
91 | }
|
92 |
|
93 | this._data[key] = this._data[key].concat(value);
|
94 | }
|
95 | }, {
|
96 | key: 'remove',
|
97 | value: function remove(key) {
|
98 | delete this._data[key];
|
99 | }
|
100 | }]);
|
101 |
|
102 | return Bucket;
|
103 | }();
|
104 |
|
105 | exports.default = Bucket;
|
106 |
|
\ | No newline at end of file |