mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Optimize _.max and _.min.
Former-commit-id: 8c5dc8606d00e68dee63f06438e83c3bd65f3b29
This commit is contained in:
4
build.js
4
build.js
@@ -118,10 +118,10 @@
|
|||||||
'lastIndexOf': [],
|
'lastIndexOf': [],
|
||||||
'lateBind': ['isFunction'],
|
'lateBind': ['isFunction'],
|
||||||
'map': ['forEach', 'isArray'],
|
'map': ['forEach', 'isArray'],
|
||||||
'max': ['forEach'],
|
'max': ['forEach', 'isArray'],
|
||||||
'memoize': [],
|
'memoize': [],
|
||||||
'merge': ['forOwn', 'isArray', 'isPlainObject'],
|
'merge': ['forOwn', 'isArray', 'isPlainObject'],
|
||||||
'min': ['forEach'],
|
'min': ['forEach', 'isArray'],
|
||||||
'mixin': ['forEach', 'functions'],
|
'mixin': ['forEach', 'functions'],
|
||||||
'noConflict': [],
|
'noConflict': [],
|
||||||
'object': [],
|
'object': [],
|
||||||
|
|||||||
@@ -2105,7 +2105,7 @@
|
|||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collections
|
* @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 {Function} [callback] The function called per iteration.
|
||||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||||
* @returns {Mixed} Returns the maximum value.
|
* @returns {Mixed} Returns the maximum value.
|
||||||
@@ -2126,7 +2126,7 @@
|
|||||||
length = collection ? collection.length : 0,
|
length = collection ? collection.length : 0,
|
||||||
result = computed;
|
result = computed;
|
||||||
|
|
||||||
if (callback || typeof length != 'number') {
|
if (callback || !isArray(collection)) {
|
||||||
callback = createCallback(callback, thisArg);
|
callback = createCallback(callback, thisArg);
|
||||||
forEach(collection, function(value, index, collection) {
|
forEach(collection, function(value, index, collection) {
|
||||||
var current = callback(value, index, collection);
|
var current = callback(value, index, collection);
|
||||||
@@ -2154,7 +2154,7 @@
|
|||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Collections
|
* @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 {Function} [callback] The function called per iteration.
|
||||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||||
* @returns {Mixed} Returns the minimum value.
|
* @returns {Mixed} Returns the minimum value.
|
||||||
@@ -2169,7 +2169,7 @@
|
|||||||
length = collection ? collection.length : 0,
|
length = collection ? collection.length : 0,
|
||||||
result = computed;
|
result = computed;
|
||||||
|
|
||||||
if (callback || typeof length != 'number') {
|
if (callback || !isArray(collection)) {
|
||||||
callback = createCallback(callback, thisArg);
|
callback = createCallback(callback, thisArg);
|
||||||
forEach(collection, function(value, index, collection) {
|
forEach(collection, function(value, index, collection) {
|
||||||
var current = callback(value, index, collection);
|
var current = callback(value, index, collection);
|
||||||
|
|||||||
Reference in New Issue
Block a user