source: imaps-frontend/node_modules/lodash-es/_baseMerge.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import Stack from './_Stack.js';
2import assignMergeValue from './_assignMergeValue.js';
3import baseFor from './_baseFor.js';
4import baseMergeDeep from './_baseMergeDeep.js';
5import isObject from './isObject.js';
6import keysIn from './keysIn.js';
7import safeGet from './_safeGet.js';
8
9/**
10 * The base implementation of `_.merge` without support for multiple sources.
11 *
12 * @private
13 * @param {Object} object The destination object.
14 * @param {Object} source The source object.
15 * @param {number} srcIndex The index of `source`.
16 * @param {Function} [customizer] The function to customize merged values.
17 * @param {Object} [stack] Tracks traversed source values and their merged
18 * counterparts.
19 */
20function baseMerge(object, source, srcIndex, customizer, stack) {
21 if (object === source) {
22 return;
23 }
24 baseFor(source, function(srcValue, key) {
25 stack || (stack = new Stack);
26 if (isObject(srcValue)) {
27 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
28 }
29 else {
30 var newValue = customizer
31 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
32 : undefined;
33
34 if (newValue === undefined) {
35 newValue = srcValue;
36 }
37 assignMergeValue(object, key, newValue);
38 }
39 }, keysIn);
40}
41
42export default baseMerge;
Note: See TracBrowser for help on using the repository browser.