PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / utils / merge / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/utils/merge/index.js

41 lines 822 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Simple object check.
3 *
4 * @param item
5 * @return {boolean}
6 */
7 function isObject(item) {
8 return item && typeof item === 'object' && !Array.isArray(item);
9 }
10
11 /**
12 * Deep merge two objects.
13 *
14 * @link https://stackoverflow.com/a/34749873
15 *
16 * @param {...any} sources
17 * @param target
18 * @param ...sources
19 */
20 export default function mergeDeep(target, ...sources) {
21 if (!sources.length) {
22 return target;
23 }
24 const source = sources.shift();
25
26 if (isObject(target) && isObject(source)) {
27 Object.keys(source).forEach((key) => {
28 if (isObject(source[key])) {
29 if (!target[key]) {
30 Object.assign(target, { [key]: {} });
31 }
32 mergeDeep(target[key], source[key]);
33 } else {
34 Object.assign(target, { [key]: source[key] });
35 }
36 });
37 }
38
39 return mergeDeep(target, ...sources);
40 }
41