source: node_modules/es-toolkit/dist/object/toMerged.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const clone = require('./clone.js');
6const mergeWith = require('./mergeWith.js');
7const isPlainObject = require('../predicate/isPlainObject.js');
8
9function toMerged(target, source) {
10 return mergeWith.mergeWith(clone.clone(target), source, function mergeRecursively(targetValue, sourceValue) {
11 if (Array.isArray(sourceValue)) {
12 if (Array.isArray(targetValue)) {
13 return mergeWith.mergeWith(clone.clone(targetValue), sourceValue, mergeRecursively);
14 }
15 else {
16 return mergeWith.mergeWith([], sourceValue, mergeRecursively);
17 }
18 }
19 else if (isPlainObject.isPlainObject(sourceValue)) {
20 if (isPlainObject.isPlainObject(targetValue)) {
21 return mergeWith.mergeWith(clone.clone(targetValue), sourceValue, mergeRecursively);
22 }
23 else {
24 return mergeWith.mergeWith({}, sourceValue, mergeRecursively);
25 }
26 }
27 });
28}
29
30exports.toMerged = toMerged;
Note: See TracBrowser for help on using the repository browser.