You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_assignValue.js 899B

12345678910111213141516171819202122232425262728
  1. var baseAssignValue = require('./_baseAssignValue'),
  2. eq = require('./eq');
  3. /** Used for built-in method references. */
  4. var objectProto = Object.prototype;
  5. /** Used to check objects for own properties. */
  6. var hasOwnProperty = objectProto.hasOwnProperty;
  7. /**
  8. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  9. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10. * for equality comparisons.
  11. *
  12. * @private
  13. * @param {Object} object The object to modify.
  14. * @param {string} key The key of the property to assign.
  15. * @param {*} value The value to assign.
  16. */
  17. function assignValue(object, key, value) {
  18. var objValue = object[key];
  19. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  20. (value === undefined && !(key in object))) {
  21. baseAssignValue(object, key, value);
  22. }
  23. }
  24. module.exports = assignValue;