Avoid ternary operations that aren't part of an assignment.

This commit is contained in:
John-David Dalton
2014-01-03 11:46:45 -06:00
parent 0b4029f7a1
commit 4850a033fa
7 changed files with 44 additions and 12 deletions

View File

@@ -287,7 +287,12 @@
typeCache = cache[type] || (cache[type] = {});
if (type == 'object') {
(typeCache[key] || (typeCache[key] = [])).push(value);
var array = typeCache[key];
if (array) {
array.push(value);
} else {
typeCache[key] = [value];
}
} else {
typeCache[key] = true;
}
@@ -3652,7 +3657,11 @@
* // => { '3': ['one', 'two'], '5': ['three'] }
*/
var groupBy = createAggregator(function(result, value, key) {
(hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
if (hasOwnProperty.call(result, key)) {
result[key].push(value);
} else {
result[key] = [value];
}
});
/**