Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (42 sloc)
1.6 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var assignWith = require('../internal/assignWith'), | |
| baseAssign = require('../internal/baseAssign'), | |
| createAssigner = require('../internal/createAssigner'); | |
| /** | |
| * Assigns own enumerable properties of source object(s) to the destination | |
| * object. Subsequent sources overwrite property assignments of previous sources. | |
| * If `customizer` is provided it is invoked to produce the assigned values. | |
| * The `customizer` is bound to `thisArg` and invoked with five arguments: | |
| * (objectValue, sourceValue, key, object, source). | |
| * | |
| * **Note:** This method mutates `object` and is based on | |
| * [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign). | |
| * | |
| * | |
| * @static | |
| * @memberOf _ | |
| * @alias extend | |
| * @category Object | |
| * @param {Object} object The destination object. | |
| * @param {...Object} [sources] The source objects. | |
| * @param {Function} [customizer] The function to customize assigned values. | |
| * @param {*} [thisArg] The `this` binding of `customizer`. | |
| * @returns {Object} Returns `object`. | |
| * @example | |
| * | |
| * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); | |
| * // => { 'user': 'fred', 'age': 40 } | |
| * | |
| * // using a customizer callback | |
| * var defaults = _.partialRight(_.assign, function(value, other) { | |
| * return _.isUndefined(value) ? other : value; | |
| * }); | |
| * | |
| * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); | |
| * // => { 'user': 'barney', 'age': 36 } | |
| */ | |
| var assign = createAssigner(function(object, source, customizer) { | |
| return customizer | |
| ? assignWith(object, source, customizer) | |
| : baseAssign(object, source); | |
| }); | |
| module.exports = assign; |