1 var assignValue = require('./_assignValue'),
2 copyObject = require('./_copyObject'),
3 createAssigner = require('./_createAssigner'),
4 isArrayLike = require('./isArrayLike'),
5 isPrototype = require('./_isPrototype'),
6 keys = require('./keys');
8 /** Used for built-in method references. */
9 var objectProto = Object.prototype;
11 /** Used to check objects for own properties. */
12 var hasOwnProperty = objectProto.hasOwnProperty;
15 * Assigns own enumerable string keyed properties of source objects to the
16 * destination object. Source objects are applied from left to right.
17 * Subsequent sources overwrite property assignments of previous sources.
19 * **Note:** This method mutates `object` and is loosely based on
20 * [`Object.assign`](https://mdn.io/Object/assign).
26 * @param {Object} object The destination object.
27 * @param {...Object} [sources] The source objects.
28 * @returns {Object} Returns `object`.
40 * Foo.prototype.b = 2;
41 * Bar.prototype.d = 4;
43 * _.assign({ 'a': 0 }, new Foo, new Bar);
44 * // => { 'a': 1, 'c': 3 }
46 var assign = createAssigner(function(object, source) {
47 if (isPrototype(source) || isArrayLike(source)) {
48 copyObject(source, keys(source), object);
51 for (var key in source) {
52 if (hasOwnProperty.call(source, key)) {
53 assignValue(object, key, source[key]);
58 module.exports = assign;