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