mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Avoid variable assignments in return statements.
This commit is contained in:
47
dist/lodash.underscore.js
vendored
47
dist/lodash.underscore.js
vendored
@@ -925,7 +925,8 @@
|
|||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
while (size--) {
|
while (size--) {
|
||||||
if (!(result = baseIsEqual(value[size], other[size], stackA, stackB))) {
|
result = baseIsEqual(value[size], other[size], stackA, stackB);
|
||||||
|
if (!result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -935,14 +936,16 @@
|
|||||||
baseForIn(other, function(othValue, key, other) {
|
baseForIn(other, function(othValue, key, other) {
|
||||||
if (hasOwnProperty.call(other, key)) {
|
if (hasOwnProperty.call(other, key)) {
|
||||||
size++;
|
size++;
|
||||||
return !(result = hasOwnProperty.call(value, key) && baseIsEqual(value[key], othValue, stackA, stackB)) && breakIndicator;
|
result = hasOwnProperty.call(value, key) && baseIsEqual(value[key], othValue, stackA, stackB);
|
||||||
|
return result || breakIndicator;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
baseForIn(value, function(valValue, key, value) {
|
baseForIn(value, function(valValue, key, value) {
|
||||||
if (hasOwnProperty.call(value, key)) {
|
if (hasOwnProperty.call(value, key)) {
|
||||||
return !(result = --size > -1) && breakIndicator;
|
result = --size > -1;
|
||||||
|
return result || breakIndicator;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -2150,8 +2153,10 @@
|
|||||||
*/
|
*/
|
||||||
function every(collection, predicate, thisArg) {
|
function every(collection, predicate, thisArg) {
|
||||||
var result = true;
|
var result = true;
|
||||||
predicate = createCallback(predicate, thisArg, 3);
|
|
||||||
|
|
||||||
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||||
|
predicate = createCallback(predicate, thisArg, 3);
|
||||||
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = collection ? collection.length : 0;
|
length = collection ? collection.length : 0;
|
||||||
|
|
||||||
@@ -2163,7 +2168,8 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseEach(collection, function(value, index, collection) {
|
baseEach(collection, function(value, index, collection) {
|
||||||
return !(result = !!predicate(value, index, collection)) && breakIndicator;
|
result = !!predicate(value, index, collection);
|
||||||
|
return result || breakIndicator;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -2343,8 +2349,10 @@
|
|||||||
*/
|
*/
|
||||||
function forEach(collection, callback, thisArg) {
|
function forEach(collection, callback, thisArg) {
|
||||||
var length = collection ? collection.length : 0;
|
var length = collection ? collection.length : 0;
|
||||||
callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3);
|
|
||||||
|
|
||||||
|
if (typeof callback != 'function' || typeof thisArg != 'undefined') {
|
||||||
|
callback = baseCreateCallback(callback, thisArg, 3);
|
||||||
|
}
|
||||||
return (typeof length == 'number' && length > -1 && length <= maxSafeInteger)
|
return (typeof length == 'number' && length > -1 && length <= maxSafeInteger)
|
||||||
? arrayEach(collection, callback)
|
? arrayEach(collection, callback)
|
||||||
: baseEach(collection, callback);
|
: baseEach(collection, callback);
|
||||||
@@ -3008,8 +3016,10 @@
|
|||||||
*/
|
*/
|
||||||
function some(collection, predicate, thisArg) {
|
function some(collection, predicate, thisArg) {
|
||||||
var result;
|
var result;
|
||||||
predicate = createCallback(predicate, thisArg, 3);
|
|
||||||
|
|
||||||
|
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
|
||||||
|
predicate = createCallback(predicate, thisArg, 3);
|
||||||
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = collection ? collection.length : 0;
|
length = collection ? collection.length : 0;
|
||||||
|
|
||||||
@@ -3021,7 +3031,8 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseEach(collection, function(value, index, collection) {
|
baseEach(collection, function(value, index, collection) {
|
||||||
return (result = predicate(value, index, collection)) && breakIndicator;
|
result = predicate(value, index, collection);
|
||||||
|
return result && breakIndicator;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return !!result;
|
return !!result;
|
||||||
@@ -4818,10 +4829,14 @@
|
|||||||
* // => [{ 'name': 'fred', 'age': 40 }]
|
* // => [{ 'name': 'fred', 'age': 40 }]
|
||||||
*/
|
*/
|
||||||
function createCallback(func, thisArg, argCount) {
|
function createCallback(func, thisArg, argCount) {
|
||||||
var type = typeof func;
|
var type = typeof func,
|
||||||
if (type == 'function' || func == null) {
|
isFunc = type == 'function';
|
||||||
return (typeof thisArg == 'undefined' || !(func && 'prototype' in func)) &&
|
|
||||||
func || baseCreateCallback(func, thisArg, argCount);
|
if (isFunc && (typeof thisArg == 'undefined' || !('prototype' in func))) {
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
if (isFunc || func == null) {
|
||||||
|
return baseCreateCallback(func, thisArg, argCount);
|
||||||
}
|
}
|
||||||
// handle "_.pluck" and "_.where" style callback shorthands
|
// handle "_.pluck" and "_.where" style callback shorthands
|
||||||
return type == 'object' ? matches(func) : property(func);
|
return type == 'object' ? matches(func) : property(func);
|
||||||
@@ -4879,15 +4894,13 @@
|
|||||||
if (length && !object) {
|
if (length && !object) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var result = true;
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
var key = props[length];
|
var key = props[length];
|
||||||
if (!(result = hasOwnProperty.call(object, key) &&
|
if (!(hasOwnProperty.call(object, key) && object[key] === source[key])) {
|
||||||
object[key] === source[key])) {
|
return false
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
lodash.js
24
lodash.js
@@ -1818,7 +1818,8 @@
|
|||||||
|
|
||||||
if (isWhere) {
|
if (isWhere) {
|
||||||
while (index--) {
|
while (index--) {
|
||||||
if ((result = baseIsEqual(value[index], othValue, callback, isWhere, stackA, stackB))) {
|
result = baseIsEqual(value[index], othValue, callback, isWhere, stackA, stackB);
|
||||||
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1858,7 +1859,8 @@
|
|||||||
baseForIn(value, function(valValue, key, value) {
|
baseForIn(value, function(valValue, key, value) {
|
||||||
if (hasOwnProperty.call(value, key)) {
|
if (hasOwnProperty.call(value, key)) {
|
||||||
// `size` will be `-1` if `value` has more properties than `other`
|
// `size` will be `-1` if `value` has more properties than `other`
|
||||||
return (result = --size > -1);
|
result = --size > -1;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -4049,7 +4051,8 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseEach(collection, function(value, index, collection) {
|
baseEach(collection, function(value, index, collection) {
|
||||||
return (result = !!predicate(value, index, collection));
|
result = !!predicate(value, index, collection);
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -4947,7 +4950,8 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
baseEach(collection, function(value, index, collection) {
|
baseEach(collection, function(value, index, collection) {
|
||||||
return !(result = predicate(value, index, collection));
|
result = predicate(value, index, collection);
|
||||||
|
return !result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return !!result;
|
return !!result;
|
||||||
@@ -6449,7 +6453,8 @@
|
|||||||
return !length;
|
return !length;
|
||||||
}
|
}
|
||||||
baseForOwn(value, function() {
|
baseForOwn(value, function() {
|
||||||
return (result = false);
|
result = false;
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -8059,15 +8064,14 @@
|
|||||||
if (length && !object) {
|
if (length && !object) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var result = true;
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
var key = props[length];
|
var key = props[length];
|
||||||
if (!(result = hasOwnProperty.call(object, key) &&
|
if (!(hasOwnProperty.call(object, key) &&
|
||||||
baseIsEqual(object[key], source[key], null, true))) {
|
baseIsEqual(object[key], source[key], null, true))) {
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user