_assignMergeValue.js 580 B

1234567891011121314151617181920
  1. import baseAssignValue from './_baseAssignValue.js';
  2. import eq from './eq.js';
  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. export default assignMergeValue;