3c6770e9406024ded36c319996ea32dce7158291
[platform/framework/web/crosswalk-tizen.git] /
1 var assignWith = require('../internal/assignWith'),
2     baseAssign = require('../internal/baseAssign'),
3     createAssigner = require('../internal/createAssigner');
4
5 /**
6  * Assigns own enumerable properties of source object(s) to the destination
7  * object. Subsequent sources overwrite property assignments of previous sources.
8  * If `customizer` is provided it is invoked to produce the assigned values.
9  * The `customizer` is bound to `thisArg` and invoked with five arguments:
10  * (objectValue, sourceValue, key, object, source).
11  *
12  * **Note:** This method mutates `object` and is based on
13  * [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign).
14  *
15  *
16  * @static
17  * @memberOf _
18  * @alias extend
19  * @category Object
20  * @param {Object} object The destination object.
21  * @param {...Object} [sources] The source objects.
22  * @param {Function} [customizer] The function to customize assigned values.
23  * @param {*} [thisArg] The `this` binding of `customizer`.
24  * @returns {Object} Returns `object`.
25  * @example
26  *
27  * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
28  * // => { 'user': 'fred', 'age': 40 }
29  *
30  * // using a customizer callback
31  * var defaults = _.partialRight(_.assign, function(value, other) {
32  *   return _.isUndefined(value) ? other : value;
33  * });
34  *
35  * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
36  * // => { 'user': 'barney', 'age': 36 }
37  */
38 var assign = createAssigner(function(object, source, customizer) {
39   return customizer
40     ? assignWith(object, source, customizer)
41     : baseAssign(object, source);
42 });
43
44 module.exports = assign;