mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Bump to v4.1.0.
This commit is contained in:
27
_assignInDefaults.js
Normal file
27
_assignInDefaults.js
Normal file
@@ -0,0 +1,27 @@
|
||||
var eq = require('./eq');
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = global.Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used by `_.defaults` to customize its `_.assignIn` use.
|
||||
*
|
||||
* @private
|
||||
* @param {*} objValue The destination value.
|
||||
* @param {*} srcValue The source value.
|
||||
* @param {string} key The key of the property to assign.
|
||||
* @param {Object} object The parent object of `objValue`.
|
||||
* @returns {*} Returns the value to assign.
|
||||
*/
|
||||
function assignInDefaults(objValue, srcValue, key, object) {
|
||||
if (objValue === undefined ||
|
||||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
|
||||
return srcValue;
|
||||
}
|
||||
return objValue;
|
||||
}
|
||||
|
||||
module.exports = assignInDefaults;
|
||||
Reference in New Issue
Block a user