mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Move assignIn and assignInWith closer to assign.
This commit is contained in:
120
lodash.js
120
lodash.js
@@ -9804,6 +9804,68 @@
|
||||
copyObject(source, keys(source), object);
|
||||
});
|
||||
|
||||
/**
|
||||
* This method is like `_.assign` except that it iterates over own and
|
||||
* inherited source properties.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias extend
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* function Bar() {
|
||||
* this.d = 4;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
* Bar.prototype.e = 5;
|
||||
*
|
||||
* _.assignIn({ 'a': 1 }, new Foo, new Bar);
|
||||
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
|
||||
*/
|
||||
var assignIn = createAssigner(function(object, source) {
|
||||
copyObject(source, keysIn(source), object);
|
||||
});
|
||||
|
||||
/**
|
||||
* This method is like `_.assignIn` except that it accepts `customizer` which
|
||||
* is invoked to produce the assigned values. If `customizer` returns `undefined`
|
||||
* assignment is handled by the method instead. The `customizer` is invoked
|
||||
* with five arguments: (objValue, srcValue, key, object, source).
|
||||
*
|
||||
* **Note:** This method mutates `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias extendWith
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} sources The source objects.
|
||||
* @param {Function} [customizer] The function to customize assigned values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* function customizer(objValue, srcValue) {
|
||||
* return _.isUndefined(objValue) ? srcValue : objValue;
|
||||
* }
|
||||
*
|
||||
* var defaults = _.partialRight(_.assignInWith, customizer);
|
||||
*
|
||||
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
*/
|
||||
var assignInWith = createAssigner(function(object, source, customizer) {
|
||||
copyObjectWith(source, keysIn(source), object, customizer);
|
||||
});
|
||||
|
||||
/**
|
||||
* This method is like `_.assign` except that it accepts `customizer` which
|
||||
* is invoked to produce the assigned values. If `customizer` returns `undefined`
|
||||
@@ -9943,64 +10005,6 @@
|
||||
return mergeWith.apply(undefined, args);
|
||||
});
|
||||
|
||||
/**
|
||||
* This method is like `_.assign` except that it iterates over own and
|
||||
* inherited source properties.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias extend
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
* this.b = 2;
|
||||
* }
|
||||
*
|
||||
* function Bar() {
|
||||
* this.d = 4;
|
||||
* }
|
||||
*
|
||||
* Foo.prototype.c = 3;
|
||||
* Bar.prototype.e = 5;
|
||||
*
|
||||
* _.assignIn({ 'a': 1 }, new Foo, new Bar);
|
||||
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
|
||||
*/
|
||||
var assignIn = createAssigner(function(object, source) {
|
||||
copyObject(source, keysIn(source), object);
|
||||
});
|
||||
|
||||
/**
|
||||
* This method is like `_.assignWith` except that it iterates over own and
|
||||
* inherited source properties.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias extendWith
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} sources The source objects.
|
||||
* @param {Function} [customizer] The function to customize assigned values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* function customizer(objValue, srcValue) {
|
||||
* return _.isUndefined(objValue) ? srcValue : objValue;
|
||||
* }
|
||||
*
|
||||
* var defaults = _.partialRight(_.assignInWith, customizer);
|
||||
*
|
||||
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
||||
* // => { 'a': 1, 'b': 2 }
|
||||
*/
|
||||
var assignInWith = createAssigner(function(object, source, customizer) {
|
||||
copyObjectWith(source, keysIn(source), object, customizer);
|
||||
});
|
||||
|
||||
/**
|
||||
* This method is like `_.find` except that it returns the key of the first
|
||||
* element `predicate` returns truthy for instead of the element itself.
|
||||
|
||||
Reference in New Issue
Block a user