MCPcopy
hub / github.com/jlmakes/scrollreveal / deepAssign

Function deepAssign

src/utils/deep-assign.js:4–22  ·  view source on GitHub ↗
(target, ...sources)

Source from the content-addressed store, hash-verified

2import each from './each'
3
4export 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}

Callers 3

ScrollRevealFunction · 0.85
revealFunction · 0.85

Calls 2

isObjectFunction · 0.85
eachFunction · 0.85

Tested by

no test coverage detected