mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Bump to v4.6.0.
This commit is contained in:
22
assign.js
22
assign.js
@@ -1,7 +1,19 @@
|
||||
import assignValue from './_assignValue';
|
||||
import copyObject from './_copyObject';
|
||||
import createAssigner from './_createAssigner';
|
||||
import isArrayLike from './isArrayLike';
|
||||
import isPrototype from './_isPrototype';
|
||||
import keys from './keys';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf');
|
||||
|
||||
/**
|
||||
* Assigns own enumerable properties of source objects to the destination
|
||||
* object. Source objects are applied from left to right. Subsequent sources
|
||||
@@ -33,7 +45,15 @@ import keys from './keys';
|
||||
* // => { 'a': 1, 'c': 3, 'e': 5 }
|
||||
*/
|
||||
var assign = createAssigner(function(object, source) {
|
||||
copyObject(source, keys(source), object);
|
||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
||||
copyObject(source, keys(source), object);
|
||||
return;
|
||||
}
|
||||
for (var key in source) {
|
||||
if (hasOwnProperty.call(source, key)) {
|
||||
assignValue(object, key, source[key]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default assign;
|
||||
|
||||
Reference in New Issue
Block a user