1 | /***************************************************************************************************************** |
||
2 | * @summary Simple parameter bag module, inspired by Symfony ParameterBag |
||
3 | * @description ParameterBag provide Object oriented way to store key value pair |
||
4 | * |
||
5 | * @example <caption>Instantiation</caption> |
||
6 | * const ParameterBag = require('parameterBag'); |
||
7 | * var bag = new ParameterBag(); |
||
8 | * |
||
9 | * @example <caption>Setter</caption> |
||
10 | * bag.set('key', value); |
||
11 | * |
||
12 | * @example <caption>Getter</caption |
||
13 | * var myValue = bag.get('key'); |
||
14 | *****************************************************************************************************************/ |
||
15 | |||
16 | /** |
||
17 | * @constructor |
||
18 | */ |
||
19 | function ParameterBag() { |
||
20 | this.store = new Array(); |
||
0 ignored issues
–
show
Coding Style
Best Practice
introduced
by
![]() |
|||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @public |
||
25 | * @param {string} key |
||
26 | * @param {mixed} data |
||
27 | */ |
||
28 | ParameterBag.prototype.set = function(key, data) { |
||
29 | this.store[key] = data; |
||
30 | }; |
||
31 | /** |
||
32 | * @public |
||
33 | * @param {string} key |
||
34 | * |
||
35 | * @returns {mixed} |
||
36 | */ |
||
37 | ParameterBag.prototype.get = function (key) { |
||
38 | return this.store[key]; |
||
39 | }; |
||
40 | |||
41 | /** |
||
42 | * @private |
||
43 | * @type {Array} |
||
44 | */ |
||
45 | ParameterBag.prototype.store = null; |
||
46 | |||
47 | /* Export class */ |
||
48 | module.exports = ParameterBag; |
||
49 |