Projekt

Obecné

Profil

Stáhnout (899 Bajtů) Statistiky
| Větev: | Revize:
1
var baseAssignValue = require('./_baseAssignValue'),
2
    eq = require('./eq');
3

    
4
/** Used for built-in method references. */
5
var objectProto = Object.prototype;
6

    
7
/** Used to check objects for own properties. */
8
var hasOwnProperty = objectProto.hasOwnProperty;
9

    
10
/**
11
 * Assigns `value` to `key` of `object` if the existing value is not equivalent
12
 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
13
 * for equality comparisons.
14
 *
15
 * @private
16
 * @param {Object} object The object to modify.
17
 * @param {string} key The key of the property to assign.
18
 * @param {*} value The value to assign.
19
 */
20
function assignValue(object, key, value) {
21
  var objValue = object[key];
22
  if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
23
      (value === undefined && !(key in object))) {
24
    baseAssignValue(object, key, value);
25
  }
26
}
27

    
28
module.exports = assignValue;
(31-31/571)