Total Complexity | 4 |
Complexity/F | 1.33 |
Lines of Code | 36 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | /* **************************************************************************************************************** |
||
19 | function ParameterBag() { |
||
20 | 4 | this.store = []; |
|
21 | } |
||
22 | |||
23 | /** |
||
24 | * @public |
||
25 | * @param {string} key |
||
26 | * @param {mixed} data |
||
27 | */ |
||
28 | 1 | ParameterBag.prototype.set = function(key, data) { |
|
29 | 3 | this.store[key] = data; |
|
30 | }; |
||
31 | /** |
||
32 | * @public |
||
33 | * @param {string} key |
||
34 | * @param {mixed} defaultValue If value is undefined for the key, defaultValue will be returned |
||
35 | * |
||
36 | * @returns {mixed} |
||
37 | */ |
||
38 | 1 | ParameterBag.prototype.get = function(key, defaultValue) { |
|
39 | 4 | var value = this.store[key]; |
|
40 | 4 | if (typeof value === 'undefined') { |
|
41 | 2 | return defaultValue; |
|
42 | } |
||
43 | |||
44 | 2 | return value; |
|
45 | }; |
||
46 | |||
47 | /** |
||
48 | * @private |
||
49 | * @type {Array} |
||
50 | */ |
||
51 | 1 | ParameterBag.prototype.store = null; |
|
52 | |||
53 | /* Export class */ |
||
54 | module.exports = ParameterBag; |
||
55 |