_assignMergeValue.js 582 B

123456789101112131415161718192021
  1. var baseAssignValue = require('./_baseAssignValue'),
  2. eq = require('./eq');
  3. /**
  4. * This function is like `assignValue` except that it doesn't assign
  5. * `undefined` values.
  6. *
  7. * @private
  8. * @param {Object} object The object to modify.
  9. * @param {string} key The key of the property to assign.
  10. * @param {*} value The value to assign.
  11. */
  12. function assignMergeValue(object, key, value) {
  13. if ((value !== undefined && !eq(object[key], value)) ||
  14. (value === undefined && !(key in object))) {
  15. baseAssignValue(object, key, value);
  16. }
  17. }
  18. module.exports = assignMergeValue;