mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Make eq comparisons new value vs. old value.
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -2028,7 +2028,7 @@
|
|||||||
* @param {*} value The value to assign.
|
* @param {*} value The value to assign.
|
||||||
*/
|
*/
|
||||||
function assignMergeValue(object, key, value) {
|
function assignMergeValue(object, key, value) {
|
||||||
if ((value !== undefined && !eq(value, object[key])) ||
|
if ((value !== undefined && !eq(object[key], value)) ||
|
||||||
(typeof key == 'number' && value === undefined && !(key in object))) {
|
(typeof key == 'number' && value === undefined && !(key in object))) {
|
||||||
object[key] = value;
|
object[key] = value;
|
||||||
}
|
}
|
||||||
@@ -2065,9 +2065,9 @@
|
|||||||
* @param {*} value The value to assign.
|
* @param {*} value The value to assign.
|
||||||
*/
|
*/
|
||||||
function assignValue(object, key, value) {
|
function assignValue(object, key, value) {
|
||||||
var oldValue = object[key];
|
var objValue = object[key];
|
||||||
if ((!eq(value, oldValue) ||
|
if ((!eq(objValue, value) ||
|
||||||
(eq(oldValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
|
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
|
||||||
(value === undefined && !(key in object))) {
|
(value === undefined && !(key in object))) {
|
||||||
object[key] = value;
|
object[key] = value;
|
||||||
}
|
}
|
||||||
@@ -3501,7 +3501,7 @@
|
|||||||
value = array[index],
|
value = array[index],
|
||||||
computed = iteratee ? iteratee(value) : value;
|
computed = iteratee ? iteratee(value) : value;
|
||||||
|
|
||||||
if (!eq(seen, computed)) {
|
if (!eq(computed, seen)) {
|
||||||
seen = computed;
|
seen = computed;
|
||||||
result[++resIndex] = value;
|
result[++resIndex] = value;
|
||||||
}
|
}
|
||||||
@@ -4933,7 +4933,7 @@
|
|||||||
if (type == 'number'
|
if (type == 'number'
|
||||||
? (isArrayLike(object) && isIndex(index, object.length))
|
? (isArrayLike(object) && isIndex(index, object.length))
|
||||||
: (type == 'string' && index in object)) {
|
: (type == 'string' && index in object)) {
|
||||||
return eq(value, object[index]);
|
return eq(object[index], value);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -6268,7 +6268,7 @@
|
|||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
if (length) {
|
if (length) {
|
||||||
var index = baseSortedIndex(array, value);
|
var index = baseSortedIndex(array, value);
|
||||||
if (index < length && eq(value, array[index])) {
|
if (index < length && eq(array[index], value)) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6336,7 +6336,7 @@
|
|||||||
var length = array ? array.length : 0;
|
var length = array ? array.length : 0;
|
||||||
if (length) {
|
if (length) {
|
||||||
var index = baseSortedIndex(array, value, true) - 1;
|
var index = baseSortedIndex(array, value, true) - 1;
|
||||||
if (eq(value, array[index])) {
|
if (eq(array[index], value)) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user