Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
899 bytes
|
Line | |
---|
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;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.