Total Complexity | 15 |
Complexity/F | 3 |
Lines of Code | 38 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | var Objects = { |
||
2 | merge: function (a, b) { |
||
3 | if (typeof b === 'undefined' || b === null) { |
||
4 | return a |
||
5 | } |
||
6 | if (typeof b !== 'object' || typeof a !== 'object' || a === null) { |
||
7 | return b |
||
8 | } |
||
9 | if (Array.isArray(a) || Array.isArray(b)) { |
||
10 | return b |
||
11 | } |
||
12 | var target = {} |
||
13 | Object.keys(a).forEach(function (key) { |
||
14 | target[key] = a[key] |
||
15 | }) |
||
16 | Object.keys(b).forEach(function (key) { |
||
17 | target[key] = Objects.merge(target[key], b[key]) |
||
18 | }) |
||
19 | return target |
||
20 | }, |
||
21 | copy: function (value) { |
||
22 | if (typeof value !== 'object' || value === null) { |
||
23 | return value |
||
24 | } |
||
25 | if (Array.isArray(value)) { |
||
26 | return value.map(Objects.copy) |
||
27 | } |
||
28 | var target = {} |
||
29 | Object.keys(value).forEach(function (key) { |
||
30 | target[key] = Objects.copy(value[key]) |
||
31 | }) |
||
32 | return target |
||
33 | } |
||
34 | } |
||
35 | |||
36 | module.exports = { |
||
37 | Objects: Objects |
||
38 | } |
||
39 |