Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | var baseMerge = require('./_baseMerge'),
|
---|
2 | createAssigner = require('./_createAssigner');
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * This method is like `_.assign` except that it recursively merges own and
|
---|
6 | * inherited enumerable string keyed properties of source objects into the
|
---|
7 | * destination object. Source properties that resolve to `undefined` are
|
---|
8 | * skipped if a destination value exists. Array and plain object properties
|
---|
9 | * are merged recursively. Other objects and value types are overridden by
|
---|
10 | * assignment. Source objects are applied from left to right. Subsequent
|
---|
11 | * sources overwrite property assignments of previous sources.
|
---|
12 | *
|
---|
13 | * **Note:** This method mutates `object`.
|
---|
14 | *
|
---|
15 | * @static
|
---|
16 | * @memberOf _
|
---|
17 | * @since 0.5.0
|
---|
18 | * @category Object
|
---|
19 | * @param {Object} object The destination object.
|
---|
20 | * @param {...Object} [sources] The source objects.
|
---|
21 | * @returns {Object} Returns `object`.
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * var object = {
|
---|
25 | * 'a': [{ 'b': 2 }, { 'd': 4 }]
|
---|
26 | * };
|
---|
27 | *
|
---|
28 | * var other = {
|
---|
29 | * 'a': [{ 'c': 3 }, { 'e': 5 }]
|
---|
30 | * };
|
---|
31 | *
|
---|
32 | * _.merge(object, other);
|
---|
33 | * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
|
---|
34 | */
|
---|
35 | var merge = createAssigner(function(object, source, srcIndex) {
|
---|
36 | baseMerge(object, source, srcIndex);
|
---|
37 | });
|
---|
38 |
|
---|
39 | module.exports = merge;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.