mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Add more isIterateeCall guards.
This commit is contained in:
21
lodash.js
21
lodash.js
@@ -5475,12 +5475,11 @@
|
|||||||
* // => { 'user': 'fred', 'age': 40 };
|
* // => { 'user': 'fred', 'age': 40 };
|
||||||
*/
|
*/
|
||||||
function max(collection, iteratee, thisArg) {
|
function max(collection, iteratee, thisArg) {
|
||||||
var noIteratee = iteratee == null;
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
if (!noIteratee && isIterateeCall(collection, iteratee, thisArg)) {
|
|
||||||
iteratee = null;
|
iteratee = null;
|
||||||
noIteratee = true;
|
|
||||||
}
|
}
|
||||||
var isArr = noIteratee && isArray(collection),
|
var noIteratee = iteratee == null,
|
||||||
|
isArr = noIteratee && isArray(collection),
|
||||||
isStr = !isArr && isString(collection);
|
isStr = !isArr && isString(collection);
|
||||||
|
|
||||||
if (noIteratee && !isStr) {
|
if (noIteratee && !isStr) {
|
||||||
@@ -5547,12 +5546,11 @@
|
|||||||
* // => { 'user': 'barney', 'age': 36 };
|
* // => { 'user': 'barney', 'age': 36 };
|
||||||
*/
|
*/
|
||||||
function min(collection, iteratee, thisArg) {
|
function min(collection, iteratee, thisArg) {
|
||||||
var noIteratee = iteratee == null;
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
if (!noIteratee && isIterateeCall(collection, iteratee, thisArg)) {
|
|
||||||
iteratee = null;
|
iteratee = null;
|
||||||
noIteratee = true;
|
|
||||||
}
|
}
|
||||||
var isArr = noIteratee && isArray(collection),
|
var noIteratee = iteratee == null,
|
||||||
|
isArr = noIteratee && isArray(collection),
|
||||||
isStr = !isArr && isString(collection);
|
isStr = !isArr && isString(collection);
|
||||||
|
|
||||||
if (noIteratee && !isStr) {
|
if (noIteratee && !isStr) {
|
||||||
@@ -5942,8 +5940,9 @@
|
|||||||
* // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
* // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
||||||
*/
|
*/
|
||||||
function sortBy(collection, iteratee, thisArg) {
|
function sortBy(collection, iteratee, thisArg) {
|
||||||
iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee;
|
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
|
||||||
|
iteratee = null;
|
||||||
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = collection ? collection.length : 0,
|
length = collection ? collection.length : 0,
|
||||||
multi = iteratee && isArray(iteratee),
|
multi = iteratee && isArray(iteratee),
|
||||||
@@ -8819,7 +8818,7 @@
|
|||||||
// https://github.com/olado/doT
|
// https://github.com/olado/doT
|
||||||
var settings = lodash.templateSettings;
|
var settings = lodash.templateSettings;
|
||||||
|
|
||||||
if (isIterateeCall(string, options, otherOptions)) {
|
if (otherOptions && isIterateeCall(string, options, otherOptions)) {
|
||||||
options = otherOptions = null;
|
options = otherOptions = null;
|
||||||
}
|
}
|
||||||
string = String(string == null ? '' : string);
|
string = String(string == null ? '' : string);
|
||||||
|
|||||||
Reference in New Issue
Block a user