mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Cleanup _.max and _.min.
Former-commit-id: 9688a11db3d90f6b0f4a7d6d13b4e1c6c0709870
This commit is contained in:
32
lodash.js
32
lodash.js
@@ -481,6 +481,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by `_.max` and `_.min` as the default `callback` when a given
|
||||
* `collection` is a string value.
|
||||
*
|
||||
* @private
|
||||
* @param {String} value The character to inspect.
|
||||
* @returns {Number} Returns the code unit of given character.
|
||||
*/
|
||||
function charAtCallback(value) {
|
||||
return value.charCodeAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by `sortBy` to compare transformed `collection` values, stable sorting
|
||||
* them in ascending order.
|
||||
@@ -2127,12 +2139,10 @@
|
||||
result = computed;
|
||||
|
||||
if (callback || !isArray(collection)) {
|
||||
if (!callback && isString(collection)) {
|
||||
callback = function(value) {
|
||||
return value.charCodeAt(0);
|
||||
};
|
||||
}
|
||||
callback = createCallback(callback, thisArg);
|
||||
callback = !callback && isString(collection)
|
||||
? charAtCallback
|
||||
: createCallback(callback, thisArg);
|
||||
|
||||
forEach(collection, function(value, index, collection) {
|
||||
var current = callback(value, index, collection);
|
||||
if (current > computed) {
|
||||
@@ -2175,12 +2185,10 @@
|
||||
result = computed;
|
||||
|
||||
if (callback || !isArray(collection)) {
|
||||
if (!callback && isString(collection)) {
|
||||
callback = function(value) {
|
||||
return value.charCodeAt(0);
|
||||
};
|
||||
}
|
||||
callback = createCallback(callback, thisArg);
|
||||
callback = !callback && isString(collection)
|
||||
? charAtCallback
|
||||
: createCallback(callback, thisArg);
|
||||
|
||||
forEach(collection, function(value, index, collection) {
|
||||
var current = callback(value, index, collection);
|
||||
if (current < computed) {
|
||||
|
||||
Reference in New Issue
Block a user