You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
906 B
JavaScript
41 lines
906 B
JavaScript
12 months ago
|
var copyObject = require('./_copyObject'),
|
||
|
createAssigner = require('./_createAssigner'),
|
||
|
keysIn = require('./keysIn');
|
||
|
|
||
|
/**
|
||
|
* This method is like `_.assign` except that it iterates over own and
|
||
|
* inherited source properties.
|
||
|
*
|
||
|
* **Note:** This method mutates `object`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @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 }
|
||
|
*/
|
||
|
var assignIn = createAssigner(function(object, source) {
|
||
|
copyObject(source, keysIn(source), object);
|
||
|
});
|
||
|
|
||
|
module.exports = assignIn;
|