mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Rebuild lodash and docs.
This commit is contained in:
280
dist/lodash.core.js
vendored
280
dist/lodash.core.js
vendored
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 4.11.1 (Custom Build) <https://lodash.com/>
|
||||
* lodash 4.11.2 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash core -o ./dist/lodash.core.js`
|
||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||
* Released under MIT license <https://lodash.com/license>
|
||||
@@ -13,7 +13,7 @@
|
||||
var undefined;
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '4.11.1';
|
||||
var VERSION = '4.11.2';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -130,35 +130,6 @@
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `_.max` and `_.min` which accepts a
|
||||
* `comparator` to determine the extremum value.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} iteratee The iteratee invoked per iteration.
|
||||
* @param {Function} comparator The comparator used to compare values.
|
||||
* @returns {*} Returns the extremum value.
|
||||
*/
|
||||
function baseExtremum(array, iteratee, comparator) {
|
||||
var index = -1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index],
|
||||
current = iteratee(value);
|
||||
|
||||
if (current != null && (computed === undefined
|
||||
? current === current
|
||||
: comparator(current, computed)
|
||||
)) {
|
||||
var computed = current,
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `_.find` and `_.findKey`, without
|
||||
* support for iteratee shorthands, which iterates over `collection` using
|
||||
@@ -251,38 +222,6 @@
|
||||
return (value && value.Object === Object) ? value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares values to sort them in ascending order.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {number} Returns the sort order indicator for `value`.
|
||||
*/
|
||||
function compareAscending(value, other) {
|
||||
if (value !== other) {
|
||||
var valIsNull = value === null,
|
||||
valIsUndef = value === undefined,
|
||||
valIsReflexive = value === value;
|
||||
|
||||
var othIsNull = other === null,
|
||||
othIsUndef = other === undefined,
|
||||
othIsReflexive = other === other;
|
||||
|
||||
if ((value > other && !othIsNull) || !valIsReflexive ||
|
||||
(valIsNull && !othIsUndef && othIsReflexive) ||
|
||||
(valIsUndef && othIsReflexive)) {
|
||||
return 1;
|
||||
}
|
||||
if ((value < other && !valIsNull) || !othIsReflexive ||
|
||||
(othIsNull && !valIsUndef && valIsReflexive) ||
|
||||
(othIsUndef && valIsReflexive)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by `_.escape` to convert characters to HTML entities.
|
||||
*
|
||||
@@ -313,20 +252,6 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a valid array-like index.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||
*/
|
||||
function isIndex(value, length) {
|
||||
value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
|
||||
length = length == null ? MAX_SAFE_INTEGER : length;
|
||||
return value > -1 && value % 1 == 0 && value < length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `iterator` to an array.
|
||||
*
|
||||
@@ -379,9 +304,6 @@
|
||||
nativeKeys = Object.keys,
|
||||
nativeMax = Math.max;
|
||||
|
||||
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
|
||||
var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -616,6 +538,35 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of methods like `_.max` and `_.min` which accepts a
|
||||
* `comparator` to determine the extremum value.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function} iteratee The iteratee invoked per iteration.
|
||||
* @param {Function} comparator The comparator used to compare values.
|
||||
* @returns {*} Returns the extremum value.
|
||||
*/
|
||||
function baseExtremum(array, iteratee, comparator) {
|
||||
var index = -1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index],
|
||||
current = iteratee(value);
|
||||
|
||||
if (current != null && (computed === undefined
|
||||
? (current === current && !false)
|
||||
: comparator(current, computed)
|
||||
)) {
|
||||
var computed = current,
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.filter` without support for iteratee shorthands.
|
||||
*
|
||||
@@ -708,6 +659,19 @@
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.gt` which doesn't coerce arguments to numbers.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {boolean} Returns `true` if `value` is greater than `other`,
|
||||
* else `false`.
|
||||
*/
|
||||
function baseGt(value, other) {
|
||||
return value > other;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isEqual` which supports partial comparisons
|
||||
* and tracks traversed objects.
|
||||
@@ -856,6 +820,19 @@
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.lt` which doesn't coerce arguments to numbers.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {boolean} Returns `true` if `value` is less than `other`,
|
||||
* else `false`.
|
||||
*/
|
||||
function baseLt(value, other) {
|
||||
return value < other;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.map` without support for iteratee shorthands.
|
||||
*
|
||||
@@ -1011,6 +988,44 @@
|
||||
}, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares values to sort them in ascending order.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {number} Returns the sort order indicator for `value`.
|
||||
*/
|
||||
function compareAscending(value, other) {
|
||||
if (value !== other) {
|
||||
var valIsDefined = value !== undefined,
|
||||
valIsNull = value === null,
|
||||
valIsReflexive = value === value,
|
||||
valIsSymbol = false;
|
||||
|
||||
var othIsDefined = other !== undefined,
|
||||
othIsNull = other === null,
|
||||
othIsReflexive = other === other,
|
||||
othIsSymbol = false;
|
||||
|
||||
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
|
||||
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
|
||||
(valIsNull && othIsDefined && othIsReflexive) ||
|
||||
(!valIsDefined && othIsReflexive) ||
|
||||
!valIsReflexive) {
|
||||
return 1;
|
||||
}
|
||||
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
|
||||
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
|
||||
(othIsNull && valIsDefined && valIsReflexive) ||
|
||||
(!othIsDefined && valIsReflexive) ||
|
||||
!othIsReflexive) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies properties of `source` to `object`.
|
||||
*
|
||||
@@ -1393,6 +1408,21 @@
|
||||
return isArrayLikeObject(value) && (isArray(value) || isArguments(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a valid array-like index.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
||||
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
||||
*/
|
||||
function isIndex(value, length) {
|
||||
length = length == null ? MAX_SAFE_INTEGER : length;
|
||||
return !!length &&
|
||||
(typeof value == 'number' || reIsUint.test(value)) &&
|
||||
(value > -1 && value % 1 == 0 && value < length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is likely a prototype object.
|
||||
*
|
||||
@@ -1407,6 +1437,15 @@
|
||||
return value === proto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `value` to a string key if it's not a string or symbol.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {string|symbol} Returns the key.
|
||||
*/
|
||||
var toKey = String;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -1806,6 +1845,7 @@
|
||||
* @param {Array|Function|Object|string} [predicate=_.identity]
|
||||
* The function invoked per iteration.
|
||||
* @returns {Array} Returns the new filtered array.
|
||||
* @see _.reject
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
@@ -1889,6 +1929,7 @@
|
||||
* @param {Array|Object} collection The collection to iterate over.
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @returns {Array|Object} Returns `collection`.
|
||||
* @see _.forEachRight
|
||||
* @example
|
||||
*
|
||||
* _([1, 2]).forEach(function(value) {
|
||||
@@ -1975,6 +2016,7 @@
|
||||
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
||||
* @param {*} [accumulator] The initial value.
|
||||
* @returns {*} Returns the accumulated value.
|
||||
* @see _.reduceRight
|
||||
* @example
|
||||
*
|
||||
* _.reduce([1, 2], function(sum, n) {
|
||||
@@ -2388,6 +2430,7 @@
|
||||
* @category Lang
|
||||
* @param {*} value The value to clone.
|
||||
* @returns {*} Returns the cloned value.
|
||||
* @see _.cloneDeep
|
||||
* @example
|
||||
*
|
||||
* var objects = [{ 'a': 1 }, { 'b': 2 }];
|
||||
@@ -2439,32 +2482,6 @@
|
||||
return value === other || (value !== value && other !== other);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is greater than `other`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.9.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {boolean} Returns `true` if `value` is greater than `other`,
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.gt(3, 1);
|
||||
* // => true
|
||||
*
|
||||
* _.gt(3, 3);
|
||||
* // => false
|
||||
*
|
||||
* _.gt(1, 3);
|
||||
* // => false
|
||||
*/
|
||||
function gt(value, other) {
|
||||
return value > other;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is likely an `arguments` object.
|
||||
*
|
||||
@@ -2658,12 +2675,7 @@
|
||||
isFunction(value.splice) || isArguments(value))) {
|
||||
return !value.length;
|
||||
}
|
||||
for (var key in value) {
|
||||
if (hasOwnProperty.call(value, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !(nonEnumShadows && keys(value).length);
|
||||
return !keys(value).length;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3000,32 +3012,6 @@
|
||||
return value === undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is less than `other`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.9.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {boolean} Returns `true` if `value` is less than `other`,
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.lt(1, 3);
|
||||
* // => true
|
||||
*
|
||||
* _.lt(3, 3);
|
||||
* // => false
|
||||
*
|
||||
* _.lt(3, 1);
|
||||
* // => false
|
||||
*/
|
||||
function lt(value, other) {
|
||||
return value < other;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts `value` to an array.
|
||||
*
|
||||
@@ -3154,6 +3140,7 @@
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.assignIn
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
@@ -3188,6 +3175,7 @@
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.assign
|
||||
* @example
|
||||
*
|
||||
* function Foo() {
|
||||
@@ -3225,6 +3213,7 @@
|
||||
* @param {...Object} sources The source objects.
|
||||
* @param {Function} [customizer] The function to customize assigned values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.assignWith
|
||||
* @example
|
||||
*
|
||||
* function customizer(objValue, srcValue) {
|
||||
@@ -3294,6 +3283,7 @@
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} [sources] The source objects.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @see _.defaultsDeep
|
||||
* @example
|
||||
*
|
||||
* _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
|
||||
@@ -3444,7 +3434,7 @@
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
*/
|
||||
var pick = rest(function(object, props) {
|
||||
return object == null ? {} : basePick(object, baseFlatten(props, 1));
|
||||
return object == null ? {} : basePick(object, baseMap(baseFlatten(props, 1), toKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -3806,7 +3796,7 @@
|
||||
*/
|
||||
function max(array) {
|
||||
return (array && array.length)
|
||||
? baseExtremum(array, identity, gt)
|
||||
? baseExtremum(array, identity, baseGt)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
@@ -3830,7 +3820,7 @@
|
||||
*/
|
||||
function min(array) {
|
||||
return (array && array.length)
|
||||
? baseExtremum(array, identity, lt)
|
||||
? baseExtremum(array, identity, baseLt)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
@@ -3957,9 +3947,11 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// Expose lodash on the free variable `window` or `self` when available. This
|
||||
// prevents errors in cases where lodash is loaded by a script tag in the presence
|
||||
// of an AMD loader. See http://requirejs.org/docs/errors.html#mismatch for more details.
|
||||
// Expose Lodash on the free variable `window` or `self` when available so it's
|
||||
// globally accessible, even when bundled with Browserify, Webpack, etc. This
|
||||
// also prevents errors in cases where Lodash is loaded by a script tag in the
|
||||
// presence of an AMD loader. See http://requirejs.org/docs/errors.html#mismatch
|
||||
// for more details. Use `_.noConflict` to remove Lodash from the global object.
|
||||
(freeWindow || freeSelf || {})._ = lodash;
|
||||
|
||||
// Some AMD build optimizers like r.js check for condition patterns like the following:
|
||||
|
||||
Reference in New Issue
Block a user