| Total Complexity | 8 |
| Complexity/F | 1.6 |
| Lines of Code | 44 |
| Function Count | 5 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | var Objects = { |
||
| 2 | /** |
||
| 3 | * @param {object|*} v |
||
| 4 | * @return {boolean} |
||
| 5 | */ |
||
| 6 | isObject: function (v) { |
||
| 7 | return v !== null && typeof v === 'object' && !Array.isArray(v) |
||
| 8 | }, |
||
| 9 | /** |
||
| 10 | * @param {Function|*} v |
||
| 11 | * @return {boolean} |
||
| 12 | */ |
||
| 13 | isFunction: function (v) { |
||
| 14 | return typeof v === 'function' |
||
| 15 | }, |
||
| 16 | /** |
||
| 17 | * @param {object} source |
||
| 18 | * @param {boolean} [deep] |
||
| 19 | * @return {object} |
||
| 20 | */ |
||
| 21 | copy: function (source, deep) { |
||
| 22 | return Objects.merge({}, source, deep) |
||
| 23 | }, |
||
| 24 | /** |
||
| 25 | * @param {object|*} target |
||
| 26 | * @param {object|*} source |
||
| 27 | * @param {boolean} [deep] |
||
| 28 | * @return {object} |
||
| 29 | */ |
||
| 30 | merge: function (target, source, deep) { |
||
| 31 | if (!Objects.isObject(source)) { |
||
| 32 | return source |
||
| 33 | } |
||
| 34 | target = Objects.isObject(target) ? target : {} |
||
| 35 | Object.keys(source).forEach(function (key) { |
||
| 36 | target[key] = deep ? Objects.merge(target[key], source[key], true) : source[key] |
||
| 37 | }) |
||
| 38 | return target |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | module.exports = { |
||
| 43 | Objects: Objects |
||
| 44 | } |
||
| 45 |