(target, ...sources)
| 2 | import each from './each' |
| 3 | |
| 4 | export default function deepAssign(target, ...sources) { |
| 5 | if (isObject(target)) { |
| 6 | each(sources, source => { |
| 7 | each(source, (data, key) => { |
| 8 | if (isObject(data)) { |
| 9 | if (!target[key] || !isObject(target[key])) { |
| 10 | target[key] = {} |
| 11 | } |
| 12 | deepAssign(target[key], data) |
| 13 | } else { |
| 14 | target[key] = data |
| 15 | } |
| 16 | }) |
| 17 | }) |
| 18 | return target |
| 19 | } else { |
| 20 | throw new TypeError('Target must be an object literal.') |
| 21 | } |
| 22 | } |
no test coverage detected