1 | import eq from './eq';
|
2 |
|
3 | /** Used for built-in method references. */
|
4 | var objectProto = Object.prototype;
|
5 |
|
6 | /** Used to check objects for own properties. */
|
7 | var hasOwnProperty = objectProto.hasOwnProperty;
|
8 |
|
9 | /**
|
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.
|
13 | *
|
14 | * @private
|
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.
|
18 | */
|
19 | function assignValue(object, key, value) {
|
20 | var objValue = object[key];
|
21 | if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
22 | (value === undefined && !(key in object))) {
|
23 | object[key] = value;
|
24 | }
|
25 | }
|
26 |
|
27 | export default assignValue;
|