mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
When chaining, _.max and _.min should resolve the correct value when passed an array containing only one value. [closes #292]
Former-commit-id: 79c71c1851a73c23919a28aadd56490ded91166c
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -217,7 +217,7 @@
|
||||
typeCache = cache[type] || (cache[type] = {});
|
||||
|
||||
if (type == 'object') {
|
||||
if ((typeCache[key] || (typeCache[key] = [])).push(value) === this.array.length) {
|
||||
if ((typeCache[key] || (typeCache[key] = [])).push(value) == this.array.length) {
|
||||
cache[type] = false;
|
||||
}
|
||||
} else {
|
||||
@@ -3661,7 +3661,7 @@
|
||||
seen = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),
|
||||
result = [];
|
||||
|
||||
var isLarge = length >= largeArraySize && indexOf == basicIndexOf;
|
||||
var isLarge = length >= largeArraySize && indexOf === basicIndexOf;
|
||||
|
||||
if (isLarge) {
|
||||
var cache = createCache(seen);
|
||||
@@ -3994,7 +3994,7 @@
|
||||
|
||||
while (++argsIndex < argsLength) {
|
||||
var value = argsIndex ? args[argsIndex] : seen;
|
||||
caches[argsIndex] = indexOf == basicIndexOf && (value && value.length) >= largeArraySize && createCache(value);
|
||||
caches[argsIndex] = indexOf === basicIndexOf && (value && value.length) >= largeArraySize && createCache(value);
|
||||
}
|
||||
outer:
|
||||
while (++index < length) {
|
||||
@@ -4394,7 +4394,7 @@
|
||||
length = array ? array.length : 0,
|
||||
result = [];
|
||||
|
||||
var isLarge = !isSorted && length >= largeArraySize && indexOf == basicIndexOf,
|
||||
var isLarge = !isSorted && length >= largeArraySize && indexOf === basicIndexOf,
|
||||
seen = (callback || isLarge) ? getArray() : result;
|
||||
|
||||
if (isLarge) {
|
||||
@@ -5196,7 +5196,7 @@
|
||||
|
||||
push.apply(args, arguments);
|
||||
var result = func.apply(lodash, args);
|
||||
return (value && typeof value == 'object' && value == result)
|
||||
return (value && typeof value == 'object' && value === result)
|
||||
? this
|
||||
: new lodashWrapper(result);
|
||||
};
|
||||
|
||||
11
test/test.js
11
test/test.js
@@ -2004,6 +2004,17 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.max and lodash.min chaining');
|
||||
|
||||
_.each(['max', 'min'], function(methodName) {
|
||||
test('lodash.' + methodName + ' should resolve the correct value when passed an array containing only one value', function() {
|
||||
var actual = _([40])[methodName]().value();
|
||||
strictEqual(actual, 40);
|
||||
});
|
||||
});
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.memoize');
|
||||
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user