mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Rebuild dist.
This commit is contained in:
346
dist/lodash.js
vendored
346
dist/lodash.js
vendored
@@ -24,6 +24,10 @@
|
||||
PARTIAL_FLAG = 32,
|
||||
PARTIAL_RIGHT_FLAG = 64;
|
||||
|
||||
/** Used as default options for `_.trunc` */
|
||||
var DEFAULT_TRUNC_LENGTH = 30,
|
||||
DEFAULT_TRUNC_OMISSION = '...';
|
||||
|
||||
/** Used to detect when a function becomes hot */
|
||||
var HOT_COUNT = 150,
|
||||
HOT_SPAN = 16;
|
||||
@@ -81,8 +85,8 @@
|
||||
/** Used to detect host constructors (Safari > 5) */
|
||||
var reHostCtor = /^\[object .+?Constructor\]$/;
|
||||
|
||||
/** Used to match latin-1 supplement letters */
|
||||
var reLatin1 = /[\xC0-\xFF]/g;
|
||||
/** Used to match latin-1 supplement letters (excluding mathematical operators) */
|
||||
var reLatin1 = /[\xC0-\xD6\xD8-\xDE\xDF-\xF6\xF8-\xFF]/g;
|
||||
|
||||
/** Used to ensure capturing order of template delimiters */
|
||||
var reNoMatch = /($^)/;
|
||||
@@ -102,11 +106,10 @@
|
||||
|
||||
/** Used to match words to create compound words */
|
||||
var reWords = (function() {
|
||||
var nums = '[0-9]',
|
||||
upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]',
|
||||
lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+' + nums + '*';
|
||||
var upper = '[A-Z\\xC0-\\xD6\\xD8-\\xDE]',
|
||||
lower = '[a-z\\xDF-\\xF6\\xF8-\\xFF]+';
|
||||
|
||||
return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|' + nums + '+', 'g');
|
||||
return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');
|
||||
}());
|
||||
|
||||
/** Used to detect and test whitespace */
|
||||
@@ -248,7 +251,7 @@
|
||||
'\xDD': 'Y', '\xFD': 'y', '\xFF': 'y',
|
||||
'\xC6': 'Ae', '\xE6': 'ae',
|
||||
'\xDE': 'Th', '\xFE': 'th',
|
||||
'\xDF': 'ss', '\xD7': ' ', '\xF7': ' '
|
||||
'\xDF': 'ss'
|
||||
};
|
||||
|
||||
/** Used to determine if values are of the language type `Object` */
|
||||
@@ -335,7 +338,7 @@
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @returns {Array} Returns `true` if all elements passed the predicate check,
|
||||
* @returns {Array} Returns `true` if all elements pass the predicate check,
|
||||
* else `false`
|
||||
*/
|
||||
function arrayEvery(array, predicate) {
|
||||
@@ -450,7 +453,7 @@
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @returns {boolean} Returns `true` if any element passed the predicate check,
|
||||
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||
* else `false`.
|
||||
*/
|
||||
function arraySome(array, predicate) {
|
||||
@@ -510,7 +513,8 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.indexOf` without support for binary searches.
|
||||
* The base implementation of `_.indexOf` without support for `fromIndex`
|
||||
* bounds checks and binary searches.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
@@ -519,13 +523,14 @@
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
function baseIndexOf(array, value, fromIndex) {
|
||||
if (value !== value) {
|
||||
return indexOfNaN(array, fromIndex);
|
||||
}
|
||||
var index = (fromIndex || 0) - 1,
|
||||
length = array ? array.length : 0,
|
||||
isReflexive = value === value;
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
var other = array[index];
|
||||
if ((isReflexive ? other === value : other !== other)) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
@@ -686,6 +691,46 @@
|
||||
return '\\' + stringEscapes[chr];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index at which the first occurrence of `NaN` is found in `array`.
|
||||
* If `fromRight` is provided elements of `array` are iterated from right to left.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {number} [fromIndex] The index to search from.
|
||||
* @param {boolean} [fromRight=false] Specify iterating from right to left.
|
||||
* @returns {number} Returns the index of the matched `NaN`, else `-1`.
|
||||
*/
|
||||
function indexOfNaN(array, fromIndex, fromRight) {
|
||||
var length = array.length,
|
||||
index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1);
|
||||
|
||||
while ((fromRight ? index-- : ++index < length)) {
|
||||
var other = array[index];
|
||||
if (other !== other) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided arguments are from an iteratee call.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The potential iteratee value argument.
|
||||
* @param {*} index The potential iteratee index or key argument.
|
||||
* @param {*} object The potential iteratee object argument.
|
||||
* @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
|
||||
*/
|
||||
function isIterateeCall(value, index, object) {
|
||||
var indexType = typeof index,
|
||||
objectType = typeof object;
|
||||
|
||||
return (object && (indexType == 'number' || indexType == 'string') &&
|
||||
(objectType == 'function' || objectType == 'object') && object[index] === value) || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by `_.trimmedLeftIndex` and `_.trimmedRightIndex` to determine if a
|
||||
* character code is whitespace.
|
||||
@@ -1375,7 +1420,7 @@
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to inspect.
|
||||
* @param {Array} [values] The values to exclude.
|
||||
* @param {Array} values The values to exclude.
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
*/
|
||||
function baseDifference(array, values) {
|
||||
@@ -1389,7 +1434,7 @@
|
||||
isLarge = prereq && createCache && values && values.length >= 200,
|
||||
isCommon = prereq && !isLarge,
|
||||
result = [],
|
||||
valuesLength = values ? values.length : 0;
|
||||
valuesLength = values.length;
|
||||
|
||||
if (isLarge) {
|
||||
indexOf = cacheIndexOf;
|
||||
@@ -1464,13 +1509,13 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.every` without support for callback shorthands
|
||||
* or `this` binding.
|
||||
* The base implementation of `_.every` without support for callback
|
||||
* shorthands or `this` binding.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @returns {Array} Returns `true` if all elements passed the predicate check,
|
||||
* @returns {Array} Returns `true` if all elements pass the predicate check,
|
||||
* else `false`
|
||||
*/
|
||||
function baseEvery(collection, predicate) {
|
||||
@@ -2087,7 +2132,7 @@
|
||||
* @private
|
||||
* @param {Array|Object|string} collection The collection to iterate over.
|
||||
* @param {Function} predicate The function invoked per iteration.
|
||||
* @returns {boolean} Returns `true` if any element passed the predicate check,
|
||||
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||
* else `false`.
|
||||
*/
|
||||
function baseSome(collection, predicate) {
|
||||
@@ -2355,12 +2400,10 @@
|
||||
var length = arguments.length,
|
||||
object = arguments[0];
|
||||
|
||||
if (object == null || length < 2) {
|
||||
if (length < 2 || object == null) {
|
||||
return object;
|
||||
}
|
||||
// enables use as a callback for functions like `_.reduce`
|
||||
var type = typeof arguments[2];
|
||||
if ((type == 'number' || type == 'string') && arguments[3] && arguments[3][arguments[2]] === arguments[1]) {
|
||||
if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) {
|
||||
length = 2;
|
||||
}
|
||||
// juggle arguments
|
||||
@@ -2844,8 +2887,8 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `_.pick` that picks `object` properties
|
||||
* the predicate returns truthy for.
|
||||
* A specialized version of `_.pick` that picks `object` properties `predicate`
|
||||
* returns truthy for.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The source object.
|
||||
@@ -2995,6 +3038,7 @@
|
||||
* @category Array
|
||||
* @param {Array} array The array to process.
|
||||
* @param {numer} [size=1] The length of each chunk.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {Array} Returns the new array containing chunks.
|
||||
* @example
|
||||
*
|
||||
@@ -3004,13 +3048,13 @@
|
||||
* _.chunk(['a', 'b', 'c', 'd'], 3);
|
||||
* // => [['a', 'b', 'c'], ['d']]
|
||||
*/
|
||||
function chunk(array, size) {
|
||||
function chunk(array, size, guard) {
|
||||
var index = 0,
|
||||
length = array ? array.length : 0,
|
||||
resIndex = -1,
|
||||
result = [];
|
||||
|
||||
size = typeof size == 'undefined' ? 1 : nativeMax(+size || 1, 1);
|
||||
size = (guard || size == null) ? 1 : nativeMax(+size || 1, 1);
|
||||
while (index < length) {
|
||||
result[++resIndex] = slice(array, index, (index += size));
|
||||
}
|
||||
@@ -3104,7 +3148,7 @@
|
||||
* // => [1, 2, 3]
|
||||
*/
|
||||
function drop(array, n, guard) {
|
||||
n = (n == null || guard) ? 1 : n;
|
||||
n = (guard || n == null) ? 1 : n;
|
||||
return slice(array, n < 0 ? 0 : n);
|
||||
}
|
||||
|
||||
@@ -3135,14 +3179,14 @@
|
||||
*/
|
||||
function dropRight(array, n, guard) {
|
||||
var length = array ? array.length : 0;
|
||||
n = (n == null || guard) ? 1 : n;
|
||||
n = (guard || n == null) ? 1 : n;
|
||||
n = length - (n || 0);
|
||||
return slice(array, 0, n < 0 ? 0 : n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` excluding elements dropped from the end.
|
||||
* Elements are dropped until the predicate returns falsey. The predicate is
|
||||
* Elements are dropped until `predicate` returns falsey. The predicate is
|
||||
* bound to `thisArg` and invoked with three arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
@@ -3191,7 +3235,7 @@
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` excluding elements dropped from the beginning.
|
||||
* Elements are dropped until the predicate returns falsey. The predicate is
|
||||
* Elements are dropped until `predicate` returns falsey. The predicate is
|
||||
* bound to `thisArg` and invoked with three arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
@@ -3240,7 +3284,7 @@
|
||||
|
||||
/**
|
||||
* This method is like `_.find` except that it returns the index of the first
|
||||
* element the predicate returns truthy for, instead of the element itself.
|
||||
* element `predicate` returns truthy for, instead of the element itself.
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
* callback returns the property value of the given element.
|
||||
@@ -3388,15 +3432,7 @@
|
||||
*/
|
||||
function flatten(array, isDeep, guard) {
|
||||
var length = array ? array.length : 0;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
// enables use as a callback for functions like `_.map`
|
||||
var type = typeof isDeep;
|
||||
if ((type == 'number' || type == 'string') && guard && guard[isDeep] === array) {
|
||||
isDeep = false;
|
||||
}
|
||||
return baseFlatten(array, isDeep);
|
||||
return length ? baseFlatten(array, guard ? false : isDeep) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3450,12 +3486,14 @@
|
||||
*/
|
||||
function indexOf(array, value, fromIndex) {
|
||||
var length = array ? array.length : 0;
|
||||
|
||||
if (!length) {
|
||||
return -1;
|
||||
}
|
||||
if (typeof fromIndex == 'number') {
|
||||
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
|
||||
} else if (fromIndex) {
|
||||
var index = sortedIndex(array, value);
|
||||
return (length && array[index] === value) ? index : -1;
|
||||
return array[index] === value ? index : -1;
|
||||
}
|
||||
return baseIndexOf(array, value, fromIndex);
|
||||
}
|
||||
@@ -3475,7 +3513,7 @@
|
||||
*/
|
||||
function initial(array) {
|
||||
var length = array ? array.length : 0;
|
||||
return slice(array, 0, length ? length - 1 : 0);
|
||||
return slice(array, 0, (length || 1) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3583,19 +3621,22 @@
|
||||
* // => 3
|
||||
*/
|
||||
function lastIndexOf(array, value, fromIndex) {
|
||||
var length = array ? array.length : 0,
|
||||
index = length;
|
||||
|
||||
var length = array ? array.length : 0;
|
||||
if (!length) {
|
||||
return -1;
|
||||
}
|
||||
var index = length;
|
||||
if (typeof fromIndex == 'number') {
|
||||
index = (fromIndex < 0 ? nativeMax(index + fromIndex, 0) : nativeMin(fromIndex || 0, index - 1)) + 1;
|
||||
index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1;
|
||||
} else if (fromIndex) {
|
||||
index = sortedLastIndex(array, value) - 1;
|
||||
return (length && array[index] === value) ? index : -1;
|
||||
return array[index] === value ? index : -1;
|
||||
}
|
||||
if (value !== value) {
|
||||
return indexOfNaN(array, index, true);
|
||||
}
|
||||
var isReflexive = value === value;
|
||||
while (index--) {
|
||||
var other = array[index];
|
||||
if ((isReflexive ? other === value : other !== other)) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
@@ -3626,8 +3667,11 @@
|
||||
* // => [1, 1]
|
||||
*/
|
||||
function pull() {
|
||||
var array = arguments[0],
|
||||
index = 0,
|
||||
var array = arguments[0];
|
||||
if (!(array && array.length)) {
|
||||
return array;
|
||||
}
|
||||
var index = 0,
|
||||
indexOf = getIndexOf(),
|
||||
length = arguments.length;
|
||||
|
||||
@@ -3672,7 +3716,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all elements from `array` that the predicate returns truthy for
|
||||
* Removes all elements from `array` that `predicate` returns truthy for
|
||||
* and returns an array of the removed elements. The predicate is bound to
|
||||
* `thisArg` and invoked with three arguments; (value, index, array).
|
||||
*
|
||||
@@ -3756,13 +3800,18 @@
|
||||
*/
|
||||
function slice(array, start, end) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0;
|
||||
length = array ? array.length : 0,
|
||||
endType = typeof end;
|
||||
|
||||
if (end && endType != 'number' && isIterateeCall(array, start, end)) {
|
||||
start = 0;
|
||||
end = length;
|
||||
}
|
||||
start = start == null ? 0 : (+start || 0);
|
||||
if (start < 0) {
|
||||
start = -start > length ? 0 : (length + start);
|
||||
}
|
||||
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
||||
end = (endType == 'undefined' || end > length) ? length : (+end || 0);
|
||||
if (end < 0) {
|
||||
end += length;
|
||||
}
|
||||
@@ -3783,7 +3832,7 @@
|
||||
* be inserted into a given sorted array in order to maintain the sort order
|
||||
* of the array. If an iteratee function is provided it is invoked for `value`
|
||||
* and each element of `array` to compute their sort ranking. The iteratee
|
||||
* function is bound to `thisArg` and invoked with one argument; (value).
|
||||
* is bound to `thisArg` and invoked with one argument; (value).
|
||||
*
|
||||
* If a property name is provided for `iteratee` the created "_.pluck" style
|
||||
* callback returns the property value of the given element.
|
||||
@@ -3880,7 +3929,7 @@
|
||||
* // => []
|
||||
*/
|
||||
function take(array, n, guard) {
|
||||
n = (n == null || guard) ? 1 : n;
|
||||
n = (guard || n == null) ? 1 : n;
|
||||
return slice(array, 0, n < 0 ? 0 : n);
|
||||
}
|
||||
|
||||
@@ -3911,14 +3960,14 @@
|
||||
*/
|
||||
function takeRight(array, n, guard) {
|
||||
var length = array ? array.length : 0;
|
||||
n = (n == null || guard) ? 1 : n;
|
||||
n = (guard || n == null) ? 1 : n;
|
||||
n = length - (n || 0);
|
||||
return slice(array, n < 0 ? 0 : n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with elements taken from the end. Elements are
|
||||
* taken until the predicate returns falsey. The predicate is bound to `thisArg`
|
||||
* taken until `predicate` returns falsey. The predicate is bound to `thisArg`
|
||||
* and invoked with three arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
@@ -3967,7 +4016,7 @@
|
||||
|
||||
/**
|
||||
* Creates a slice of `array` with elements taken from the beginning. Elements
|
||||
* are taken until the predicate returns falsey. The predicate is bound to
|
||||
* are taken until `predicate` returns falsey. The predicate is bound to
|
||||
* `thisArg` and invoked with three arguments; (value, index, array).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
@@ -4089,16 +4138,10 @@
|
||||
return [];
|
||||
}
|
||||
// juggle arguments
|
||||
var type = typeof isSorted;
|
||||
if (type != 'boolean' && isSorted != null) {
|
||||
if (typeof isSorted != 'boolean' && isSorted != null) {
|
||||
thisArg = iteratee;
|
||||
iteratee = isSorted;
|
||||
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
|
||||
isSorted = false;
|
||||
|
||||
// enables use as a callback for functions like `_.map`
|
||||
if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) {
|
||||
iteratee = null;
|
||||
}
|
||||
}
|
||||
if (iteratee != null) {
|
||||
iteratee = getCallback(iteratee, thisArg, 3);
|
||||
@@ -4478,6 +4521,9 @@
|
||||
collection = values(collection);
|
||||
length = collection.length;
|
||||
}
|
||||
if (!length) {
|
||||
return false;
|
||||
}
|
||||
if (typeof fromIndex == 'number') {
|
||||
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
|
||||
} else {
|
||||
@@ -4527,7 +4573,7 @@
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if the predicate returns truthy for **all** elements of `collection`.
|
||||
* Checks if `predicate` returns truthy for **all** elements of `collection`.
|
||||
* The predicate is bound to `thisArg` and invoked with three arguments;
|
||||
* (value, index|key, collection).
|
||||
*
|
||||
@@ -4547,7 +4593,7 @@
|
||||
* per iteration. If a property name or object is provided it is used to
|
||||
* create a "_.pluck" or "_.where" style callback respectively.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {boolean} Returns `true` if all elements passed the predicate check,
|
||||
* @returns {boolean} Returns `true` if all elements pass the predicate check,
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
@@ -4577,7 +4623,7 @@
|
||||
|
||||
/**
|
||||
* Iterates over elements of `collection`, returning an array of all elements
|
||||
* the predicate returns truthy for. The predicate is bound to `thisArg` and
|
||||
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
||||
* invoked with three arguments; (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
@@ -4623,8 +4669,8 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over elements of `collection`, returning the first element that
|
||||
* the predicate returns truthy for. The predicate is bound to `thisArg` and
|
||||
* Iterates over elements of `collection`, returning the first element
|
||||
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
||||
* invoked with three arguments; (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
@@ -4982,17 +5028,13 @@
|
||||
* // => { 'user': 'fred', 'age': 40 };
|
||||
*/
|
||||
function max(collection, iteratee, thisArg) {
|
||||
var computed = -Infinity,
|
||||
result = computed,
|
||||
type = typeof iteratee;
|
||||
iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee;
|
||||
|
||||
// enables use as a callback for functions like `_.map`
|
||||
if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) {
|
||||
iteratee = null;
|
||||
}
|
||||
var noIteratee = iteratee == null,
|
||||
var computed = -Infinity,
|
||||
noIteratee = iteratee == null,
|
||||
isArr = noIteratee && isArray(collection),
|
||||
isStr = !isArr && isString(collection);
|
||||
isStr = !isArr && isString(collection),
|
||||
result = computed;
|
||||
|
||||
if (noIteratee && !isStr) {
|
||||
var index = -1,
|
||||
@@ -5065,17 +5107,13 @@
|
||||
* // => { 'user': 'barney', 'age': 36 };
|
||||
*/
|
||||
function min(collection, iteratee, thisArg) {
|
||||
var computed = Infinity,
|
||||
result = computed,
|
||||
type = typeof iteratee;
|
||||
iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee;
|
||||
|
||||
// enables use as a callback for functions like `_.map`
|
||||
if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) {
|
||||
iteratee = null;
|
||||
}
|
||||
var noIteratee = iteratee == null,
|
||||
var computed = Infinity,
|
||||
noIteratee = iteratee == null,
|
||||
isArr = noIteratee && isArray(collection),
|
||||
isStr = !isArr && isString(collection);
|
||||
isStr = !isArr && isString(collection),
|
||||
result = computed;
|
||||
|
||||
if (noIteratee && !isStr) {
|
||||
var index = -1,
|
||||
@@ -5106,8 +5144,8 @@
|
||||
|
||||
/**
|
||||
* Creates an array of elements split into two groups, the first of which
|
||||
* contains elements the predicate returns truthy for, while the second of which
|
||||
* contains elements the predicate returns falsey for. The predicate is bound
|
||||
* contains elements `predicate` returns truthy for, while the second of which
|
||||
* contains elements `predicate` returns falsey for. The predicate is bound
|
||||
* to `thisArg` and invoked with three arguments; (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
@@ -5238,7 +5276,7 @@
|
||||
|
||||
/**
|
||||
* The opposite of `_.filter`; this method returns the elements of `collection`
|
||||
* the predicate does **not** return truthy for.
|
||||
* that `predicate` does **not** return truthy for.
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
* callback returns the property value of the given element.
|
||||
@@ -5302,7 +5340,7 @@
|
||||
* // => [3, 1]
|
||||
*/
|
||||
function sample(collection, n, guard) {
|
||||
if (n == null || guard) {
|
||||
if (guard || n == null) {
|
||||
collection = toIterable(collection);
|
||||
var length = collection.length;
|
||||
return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;
|
||||
@@ -5372,7 +5410,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the predicate returns truthy for **any** element of `collection`.
|
||||
* Checks if `predicate` returns truthy for **any** element of `collection`.
|
||||
* The function returns as soon as it finds a passing value and does not iterate
|
||||
* over the entire collection. The predicate is bound to `thisArg` and invoked
|
||||
* with three arguments; (value, index|key, collection).
|
||||
@@ -5393,7 +5431,7 @@
|
||||
* per iteration. If a property name or object is provided it is used to
|
||||
* create a "_.pluck" or "_.where" style callback respectively.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {boolean} Returns `true` if any element passed the predicate check,
|
||||
* @returns {boolean} Returns `true` if any element passes the predicate check,
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
@@ -5471,6 +5509,8 @@
|
||||
* // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
||||
*/
|
||||
function sortBy(collection, iteratee, thisArg) {
|
||||
iteratee = isIterateeCall(collection, iteratee, thisArg) ? null : iteratee;
|
||||
|
||||
var index = -1,
|
||||
length = collection ? collection.length : 0,
|
||||
multi = iteratee && isArray(iteratee),
|
||||
@@ -5765,6 +5805,7 @@
|
||||
* @category Function
|
||||
* @param {Function} func The function to curry.
|
||||
* @param {number} [arity=func.length] The arity of `func`.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {Function} Returns the new curried function.
|
||||
* @example
|
||||
*
|
||||
@@ -5781,8 +5822,8 @@
|
||||
* curried(1, 2, 3);
|
||||
* // => [1, 2, 3]
|
||||
*/
|
||||
function curry(func, arity) {
|
||||
var result = baseCurry(func, CURRY_FLAG, arity);
|
||||
function curry(func, arity, guard) {
|
||||
var result = baseCurry(func, CURRY_FLAG, guard ? null : arity);
|
||||
result.placeholder = curry.placeholder;
|
||||
return result;
|
||||
}
|
||||
@@ -5798,6 +5839,7 @@
|
||||
* @category Function
|
||||
* @param {Function} func The function to curry.
|
||||
* @param {number} [arity=func.length] The arity of `func`.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {Function} Returns the new curried function.
|
||||
* @example
|
||||
*
|
||||
@@ -5814,8 +5856,8 @@
|
||||
* curried(1, 2, 3);
|
||||
* // => [1, 2, 3]
|
||||
*/
|
||||
function curryRight(func, arity) {
|
||||
var result = baseCurry(func, CURRY_RIGHT_FLAG, arity);
|
||||
function curryRight(func, arity, guard) {
|
||||
var result = baseCurry(func, CURRY_RIGHT_FLAG, guard ? null : arity);
|
||||
result.placeholder = curryRight.placeholder;
|
||||
return result;
|
||||
}
|
||||
@@ -6431,18 +6473,11 @@
|
||||
* // => 0
|
||||
*/
|
||||
function clone(value, isDeep, customizer, thisArg) {
|
||||
var type = typeof isDeep;
|
||||
|
||||
// juggle arguments
|
||||
if (type != 'boolean' && isDeep != null) {
|
||||
if (typeof isDeep != 'boolean' && isDeep != null) {
|
||||
thisArg = customizer;
|
||||
customizer = isDeep;
|
||||
customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep;
|
||||
isDeep = false;
|
||||
|
||||
// enables use as a callback for functions like `_.map`
|
||||
if ((type == 'number' || type == 'string') && thisArg && thisArg[customizer] === value) {
|
||||
customizer = null;
|
||||
}
|
||||
}
|
||||
customizer = typeof customizer == 'function' && baseCallback(customizer, thisArg, 1);
|
||||
return baseClone(value, isDeep, customizer);
|
||||
@@ -6555,8 +6590,8 @@
|
||||
* // => false
|
||||
*/
|
||||
function isBoolean(value) {
|
||||
return (value === true || value === false ||
|
||||
value && typeof value == 'object' && toString.call(value) == boolClass) || false;
|
||||
return (value === true || value === false || value && typeof value == 'object' &&
|
||||
toString.call(value) == boolClass) || false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6602,8 +6637,7 @@
|
||||
// fallback for environments without DOM support
|
||||
if (!support.dom) {
|
||||
isElement = function(value) {
|
||||
return (value && typeof value == 'object' && value.nodeType === 1 &&
|
||||
!isPlainObject(value)) || false;
|
||||
return (value && typeof value == 'object' && value.nodeType === 1 && !isPlainObject(value)) || false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6897,8 +6931,7 @@
|
||||
*/
|
||||
function isNumber(value) {
|
||||
var type = typeof value;
|
||||
return type == 'number' ||
|
||||
(value && type == 'object' && toString.call(value) == numberClass) || false;
|
||||
return type == 'number' || (value && type == 'object' && toString.call(value) == numberClass) || false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6981,8 +7014,8 @@
|
||||
* // => false
|
||||
*/
|
||||
function isString(value) {
|
||||
return typeof value == 'string' ||
|
||||
(value && typeof value == 'object' && toString.call(value) == stringClass) || false;
|
||||
return typeof value == 'string' || (value && typeof value == 'object' &&
|
||||
toString.call(value) == stringClass) || false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7047,6 +7080,7 @@
|
||||
* @category Object
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @param {Object} [properties] The properties to assign to the object.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
@@ -7068,8 +7102,9 @@
|
||||
* circle instanceof Shape;
|
||||
* // => true
|
||||
*/
|
||||
function create(prototype, properties) {
|
||||
function create(prototype, properties, guard) {
|
||||
var result = baseCreate(prototype);
|
||||
properties = guard ? null : properties;
|
||||
return properties ? baseAssign(result, properties) : result;
|
||||
}
|
||||
|
||||
@@ -7103,7 +7138,7 @@
|
||||
|
||||
/**
|
||||
* This method is like `_.findIndex` except that it returns the key of the
|
||||
* first element the predicate returns truthy for, instead of the element itself.
|
||||
* first element `predicate` returns truthy for, instead of the element itself.
|
||||
*
|
||||
* If a property name is provided for `predicate` the created "_.pluck" style
|
||||
* callback returns the property value of the given element.
|
||||
@@ -7356,6 +7391,7 @@
|
||||
* @category Object
|
||||
* @param {Object} object The object to invert.
|
||||
* @param {boolean} [multiValue=false] Allow multiple values per key.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {Object} Returns the new inverted object.
|
||||
* @example
|
||||
*
|
||||
@@ -7370,7 +7406,9 @@
|
||||
* _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true);
|
||||
* // => { 'fred': ['first', 'third'], 'barney': ['second'] }
|
||||
*/
|
||||
function invert(object, multiValue) {
|
||||
function invert(object, multiValue, guard) {
|
||||
multiValue = guard ? null : multiValue;
|
||||
|
||||
var index = -1,
|
||||
props = keys(object),
|
||||
length = props.length,
|
||||
@@ -7455,7 +7493,7 @@
|
||||
}
|
||||
var length = object.length;
|
||||
length = (typeof length == 'number' && length > 0 &&
|
||||
(isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) >>> 0;
|
||||
(isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
|
||||
|
||||
var keyIndex,
|
||||
Ctor = object.constructor,
|
||||
@@ -7573,8 +7611,8 @@
|
||||
/**
|
||||
* Creates a shallow clone of `object` excluding the specified properties.
|
||||
* Property names may be specified as individual arguments or as arrays of
|
||||
* property names. If a predicate is provided it is invoked for each property
|
||||
* of `object` omitting the properties the predicate returns truthy for. The
|
||||
* property names. If `predicate` is provided it is invoked for each property
|
||||
* of `object` omitting the properties `predicate` returns truthy for. The
|
||||
* predicate is bound to `thisArg` and invoked with three arguments;
|
||||
* (value, key, object).
|
||||
*
|
||||
@@ -7641,8 +7679,8 @@
|
||||
/**
|
||||
* Creates a shallow clone of `object` composed of the specified properties.
|
||||
* Property names may be specified as individual arguments or as arrays of
|
||||
* property names. If a predicate is provided it is invoked for each property
|
||||
* of `object` picking the properties the predicate returns truthy for. The
|
||||
* property names. If `predicate` is provided it is invoked for each property
|
||||
* of `object` picking the properties `predicate` returns truthy for. The
|
||||
* predicate is bound to `thisArg` and invoked with three arguments;
|
||||
* (value, key, object).
|
||||
*
|
||||
@@ -8236,8 +8274,12 @@
|
||||
// and Laura Doktorova's doT.js
|
||||
// https://github.com/olado/doT
|
||||
var settings = lodash.templateSettings;
|
||||
options = assign({}, otherOptions || options, settings, assignOwnDefaults);
|
||||
|
||||
if (isIterateeCall(string, options, otherOptions)) {
|
||||
options = otherOptions = null;
|
||||
}
|
||||
string = String(string == null ? '' : string);
|
||||
options = assign({}, otherOptions || options, settings, assignOwnDefaults);
|
||||
|
||||
var imports = assign({}, options.imports, settings.imports, assignOwnDefaults),
|
||||
importsKeys = keys(imports),
|
||||
@@ -8340,6 +8382,7 @@
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to trim.
|
||||
* @param {string} [chars=whitespace] The characters to trim.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {string} Returns the trimmed string.
|
||||
* @example
|
||||
*
|
||||
@@ -8349,12 +8392,12 @@
|
||||
* _.trim('-_-fred-_-', '_-');
|
||||
* // => 'fred'
|
||||
*/
|
||||
function trim(string, chars) {
|
||||
function trim(string, chars, guard) {
|
||||
string = string == null ? '' : String(string);
|
||||
if (!string) {
|
||||
return string;
|
||||
}
|
||||
if (chars == null) {
|
||||
if (guard || chars == null) {
|
||||
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
||||
}
|
||||
chars = String(chars);
|
||||
@@ -8369,6 +8412,7 @@
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to trim.
|
||||
* @param {string} [chars=whitespace] The characters to trim.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {string} Returns the trimmed string.
|
||||
* @example
|
||||
*
|
||||
@@ -8378,12 +8422,12 @@
|
||||
* _.trimLeft('-_-fred-_-', '_-');
|
||||
* // => 'fred-_-'
|
||||
*/
|
||||
function trimLeft(string, chars) {
|
||||
function trimLeft(string, chars, guards) {
|
||||
string = string == null ? '' : String(string);
|
||||
if (!string) {
|
||||
return string;
|
||||
}
|
||||
if (chars == null) {
|
||||
if (guards || chars == null) {
|
||||
return string.slice(trimmedLeftIndex(string))
|
||||
}
|
||||
chars = String(chars);
|
||||
@@ -8398,6 +8442,7 @@
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to trim.
|
||||
* @param {string} [chars=whitespace] The characters to trim.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {string} Returns the trimmed string.
|
||||
* @example
|
||||
*
|
||||
@@ -8407,12 +8452,12 @@
|
||||
* _.trimRight('-_-fred-_-', '_-');
|
||||
* // => '-_-fred'
|
||||
*/
|
||||
function trimRight(string, chars) {
|
||||
function trimRight(string, chars, guard) {
|
||||
string = string == null ? '' : String(string);
|
||||
if (!string) {
|
||||
return string;
|
||||
}
|
||||
if (chars == null) {
|
||||
if (guard || chars == null) {
|
||||
return string.slice(0, trimmedRightIndex(string) + 1)
|
||||
}
|
||||
chars = String(chars);
|
||||
@@ -8432,6 +8477,7 @@
|
||||
* @param {number} [options.length=30] The maximum string length.
|
||||
* @param {string} [options.omission='...'] The string to indicate text is omitted.
|
||||
* @param {RegExp|string} [options.separator] The separator pattern to truncate to.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {string} Returns the truncated string.
|
||||
* @example
|
||||
*
|
||||
@@ -8450,9 +8496,11 @@
|
||||
* _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' });
|
||||
* // => 'hi-diddly-ho there, neig [...]'
|
||||
*/
|
||||
function trunc(string, options) {
|
||||
var length = 30,
|
||||
omission = '...';
|
||||
function trunc(string, options, guard) {
|
||||
options = guard ? null : options;
|
||||
|
||||
var length = DEFAULT_TRUNC_LENGTH,
|
||||
omission = DEFAULT_TRUNC_OMISSION;
|
||||
|
||||
if (isObject(options)) {
|
||||
var separator = 'separator' in options ? options.separator : separator;
|
||||
@@ -8531,6 +8579,7 @@
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to inspect.
|
||||
* @param {RegExp|string} [pattern] The pattern to match words.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {Array} Returns the words of `string`.
|
||||
* @example
|
||||
*
|
||||
@@ -8540,8 +8589,9 @@
|
||||
* _.words('fred, barney, & pebbles', /[^, ]+/g);
|
||||
* // => ['fred', 'barney', '&', 'pebbles']
|
||||
*/
|
||||
function words(string, pattern) {
|
||||
function words(string, pattern, guard) {
|
||||
string = string != null && String(string);
|
||||
pattern = guard ? null : pattern;
|
||||
return (string && string.match(pattern || reWords)) || [];
|
||||
}
|
||||
|
||||
@@ -8587,6 +8637,7 @@
|
||||
* @category Utility
|
||||
* @param {*} [func=identity] The value to convert to a callback.
|
||||
* @param {*} [thisArg] The `this` binding of the created callback.
|
||||
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
@@ -8609,8 +8660,8 @@
|
||||
* _.filter(users, 'age__gt38');
|
||||
* // => [{ 'user': 'fred', 'age': 40 }]
|
||||
*/
|
||||
function callback(func, thisArg) {
|
||||
return baseCallback(func, thisArg);
|
||||
function callback(func, thisArg, guard) {
|
||||
return baseCallback(func, guard ? undefined : thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8944,9 +8995,7 @@
|
||||
* // => a floating-point number between 1.2 and 5.2
|
||||
*/
|
||||
function random(min, max, floating) {
|
||||
// enables use as a callback for functions like `_.map`
|
||||
var type = typeof max;
|
||||
if ((type == 'number' || type == 'string') && floating && floating[max] === min) {
|
||||
if (floating && isIterateeCall(min, max, floating)) {
|
||||
max = floating = null;
|
||||
}
|
||||
var noMin = min == null,
|
||||
@@ -9013,13 +9062,10 @@
|
||||
* // => []
|
||||
*/
|
||||
function range(start, end, step) {
|
||||
start = +start || 0;
|
||||
|
||||
// enables use as a callback for functions like `_.map`
|
||||
var type = typeof end;
|
||||
if ((type == 'number' || type == 'string') && step && step[end] === start) {
|
||||
if (step && isIterateeCall(start, end, step)) {
|
||||
end = step = null;
|
||||
}
|
||||
start = +start || 0;
|
||||
step = step == null ? 1 : (+step || 0);
|
||||
|
||||
if (end == null) {
|
||||
|
||||
Reference in New Issue
Block a user