Files
lodash/assignIn.js
2017-01-10 01:09:46 -08:00

39 lines
887 B
JavaScript

import copyObject from './.internal/copyObject.js';
import createAssigner from './.internal/createAssigner.js';
import keysIn from './keysIn.js';
/**
* This method is like `assign` except that it iterates over own and
* inherited source properties.
*
* **Note:** This method mutates `object`.
*
* @since 4.0.0
* @alias extend
* @category Object
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @see assign
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* function Bar() {
* this.c = 3;
* }
*
* Foo.prototype.b = 2;
* Bar.prototype.d = 4;
*
* assignIn({ 'a': 0 }, new Foo, new Bar);
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
*/
const assignIn = createAssigner((object, source) => {
copyObject(source, keysIn(source), object);
});
export default assignIn;