|
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 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const clone = require('./clone.js');
|
|---|
| 6 | const mergeWith = require('./mergeWith.js');
|
|---|
| 7 | const isPlainObject = require('../predicate/isPlainObject.js');
|
|---|
| 8 |
|
|---|
| 9 | function 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 |
|
|---|
| 30 | exports.toMerged = toMerged;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.