* Recursively merges own enumerable properties of the source object(s), that * don't resolve to `undefined` into the destination object. Subsequent sources * will overwrite property assignments of previous sources. If a callback is * provided it will be executed to produce the merged
(object)
| 37810 | * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] } |
| 37811 | */ |
| 37812 | function merge(object) { |
| 37813 | var args = arguments, |
| 37814 | length = 2; |
| 37815 | |
| 37816 | if (!isObject(object)) { |
| 37817 | return object; |
| 37818 | } |
| 37819 | // allows working with `_.reduce` and `_.reduceRight` without using |
| 37820 | // their `index` and `collection` arguments |
| 37821 | if (typeof args[2] != 'number') { |
| 37822 | length = args.length; |
| 37823 | } |
| 37824 | if (length > 3 && typeof args[length - 2] == 'function') { |
| 37825 | var callback = baseCreateCallback(args[--length - 1], args[length--], 2); |
| 37826 | } else if (length > 2 && typeof args[length - 1] == 'function') { |
| 37827 | callback = args[--length]; |
| 37828 | } |
| 37829 | var sources = slice(arguments, 1, length), |
| 37830 | index = -1, |
| 37831 | stackA = getArray(), |
| 37832 | stackB = getArray(); |
| 37833 | |
| 37834 | while (++index < length) { |
| 37835 | baseMerge(object, sources[index], callback, stackA, stackB); |
| 37836 | } |
| 37837 | releaseArray(stackA); |
| 37838 | releaseArray(stackB); |
| 37839 | return object; |
| 37840 | } |
| 37841 | |
| 37842 | /** |
| 37843 | * Creates a shallow clone of `object` excluding the specified properties. |
no test coverage detected