Optimize _.max and _.min.

Former-commit-id: 8c5dc8606d00e68dee63f06438e83c3bd65f3b29
This commit is contained in:
John-David Dalton
2012-11-06 01:46:36 -08:00
parent 537643a4c3
commit 3138523b5b
2 changed files with 6 additions and 6 deletions

View File

@@ -118,10 +118,10 @@
'lastIndexOf': [],
'lateBind': ['isFunction'],
'map': ['forEach', 'isArray'],
'max': ['forEach'],
'max': ['forEach', 'isArray'],
'memoize': [],
'merge': ['forOwn', 'isArray', 'isPlainObject'],
'min': ['forEach'],
'min': ['forEach', 'isArray'],
'mixin': ['forEach', 'functions'],
'noConflict': [],
'object': [],

View File

@@ -2105,7 +2105,7 @@
* @static
* @memberOf _
* @category Collections
* @param {Array|Object} collection The collection to iterate over.
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding of `callback`.
* @returns {Mixed} Returns the maximum value.
@@ -2126,7 +2126,7 @@
length = collection ? collection.length : 0,
result = computed;
if (callback || typeof length != 'number') {
if (callback || !isArray(collection)) {
callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) {
var current = callback(value, index, collection);
@@ -2154,7 +2154,7 @@
* @static
* @memberOf _
* @category Collections
* @param {Array|Object} collection The collection to iterate over.
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding of `callback`.
* @returns {Mixed} Returns the minimum value.
@@ -2169,7 +2169,7 @@
length = collection ? collection.length : 0,
result = computed;
if (callback || typeof length != 'number') {
if (callback || !isArray(collection)) {
callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) {
var current = callback(value, index, collection);