mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Bump to v4.12.0.
This commit is contained in:
140
core.js
140
core.js
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 4.11.2 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash core -o ./dist/lodash.core.js`
|
||||
* lodash <https://lodash.com/>
|
||||
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||
* Released under MIT license <https://lodash.com/license>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
@@ -13,7 +12,7 @@
|
||||
var undefined;
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '4.11.2';
|
||||
var VERSION = '4.12.0';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -105,18 +104,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates a new array concatenating `array` with `other`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The first array to concatenate.
|
||||
* @param {Array} other The second array to concatenate.
|
||||
* @returns {Array} Returns the new concatenated array.
|
||||
*/
|
||||
function arrayConcat(array, other) {
|
||||
return arrayPush(copyArray(array), values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the elements of `values` to `array`.
|
||||
*
|
||||
@@ -378,10 +365,10 @@
|
||||
* `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
|
||||
* `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`,
|
||||
* `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`,
|
||||
* `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`,
|
||||
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`,
|
||||
* `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`,
|
||||
* `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
|
||||
* `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
|
||||
* `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
|
||||
* `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`,
|
||||
* `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
|
||||
* `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`,
|
||||
* `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
|
||||
* `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
|
||||
@@ -390,9 +377,9 @@
|
||||
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
|
||||
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
|
||||
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
|
||||
* `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toInteger`,
|
||||
* `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, `toString`,
|
||||
* `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`,
|
||||
* `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toFinite`,
|
||||
* `toInteger`, `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`,
|
||||
* `toString`, `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`,
|
||||
* `uniqueId`, `upperCase`, `upperFirst`, `value`, and `words`
|
||||
*
|
||||
* @name _
|
||||
@@ -651,7 +638,7 @@
|
||||
* @private
|
||||
* @param {Object} object The object to inspect.
|
||||
* @param {Array} props The property names to filter.
|
||||
* @returns {Array} Returns the new array of filtered property names.
|
||||
* @returns {Array} Returns the function names.
|
||||
*/
|
||||
function baseFunctions(object, props) {
|
||||
return baseFilter(props, function(key) {
|
||||
@@ -856,7 +843,7 @@
|
||||
*
|
||||
* @private
|
||||
* @param {Object} source The object of property values to match.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @returns {Function} Returns the new spec function.
|
||||
*/
|
||||
function baseMatches(source) {
|
||||
var props = keys(source);
|
||||
@@ -902,7 +889,7 @@
|
||||
*
|
||||
* @private
|
||||
* @param {string} key The key of the property to get.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @returns {Function} Returns the new accessor function.
|
||||
*/
|
||||
function baseProperty(key) {
|
||||
return function(object) {
|
||||
@@ -1067,7 +1054,7 @@
|
||||
length = sources.length,
|
||||
customizer = length > 1 ? sources[length - 1] : undefined;
|
||||
|
||||
customizer = typeof customizer == 'function'
|
||||
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
||||
? (length--, customizer)
|
||||
: undefined;
|
||||
|
||||
@@ -1212,16 +1199,16 @@
|
||||
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
|
||||
*/
|
||||
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
|
||||
var index = -1,
|
||||
isPartial = bitmask & PARTIAL_COMPARE_FLAG,
|
||||
isUnordered = bitmask & UNORDERED_COMPARE_FLAG,
|
||||
var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
|
||||
arrLength = array.length,
|
||||
othLength = other.length;
|
||||
|
||||
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
||||
return false;
|
||||
}
|
||||
var result = true;
|
||||
var index = -1,
|
||||
result = true,
|
||||
seen = (bitmask & UNORDERED_COMPARE_FLAG) ? [] : undefined;
|
||||
|
||||
// Ignore non-index properties.
|
||||
while (++index < arrLength) {
|
||||
@@ -1237,10 +1224,12 @@
|
||||
break;
|
||||
}
|
||||
// Recursively compare arrays (susceptible to call stack limits).
|
||||
if (isUnordered) {
|
||||
if (!baseSome(other, function(othValue) {
|
||||
return arrValue === othValue ||
|
||||
equalFunc(arrValue, othValue, customizer, bitmask, stack);
|
||||
if (seen) {
|
||||
if (!baseSome(other, function(othValue, othIndex) {
|
||||
if (!indexOf(seen, othIndex) &&
|
||||
(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
|
||||
return seen.push(othIndex);
|
||||
}
|
||||
})) {
|
||||
result = false;
|
||||
break;
|
||||
@@ -1405,7 +1394,7 @@
|
||||
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
||||
*/
|
||||
function isFlattenable(value) {
|
||||
return isArrayLikeObject(value) && (isArray(value) || isArguments(value));
|
||||
return isArray(value) || isArguments(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1491,16 +1480,16 @@
|
||||
*/
|
||||
function concat() {
|
||||
var length = arguments.length,
|
||||
array = castArray(arguments[0]);
|
||||
args = Array(length ? length - 1 : 0),
|
||||
array = arguments[0],
|
||||
index = length;
|
||||
|
||||
if (length < 2) {
|
||||
return length ? copyArray(array) : [];
|
||||
while (index--) {
|
||||
args[index - 1] = arguments[index];
|
||||
}
|
||||
var args = Array(length - 1);
|
||||
while (length--) {
|
||||
args[length - 1] = arguments[length];
|
||||
}
|
||||
return arrayConcat(array, baseFlatten(args, 1));
|
||||
return length
|
||||
? arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1))
|
||||
: [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2280,7 +2269,7 @@
|
||||
* @since 3.0.0
|
||||
* @category Function
|
||||
* @param {Function} predicate The predicate to negate.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @returns {Function} Returns the new negated function.
|
||||
* @example
|
||||
*
|
||||
* function isEven(n) {
|
||||
@@ -2372,47 +2361,6 @@
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Casts `value` as an array if it's not one.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.4.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {Array} Returns the cast array.
|
||||
* @example
|
||||
*
|
||||
* _.castArray(1);
|
||||
* // => [1]
|
||||
*
|
||||
* _.castArray({ 'a': 1 });
|
||||
* // => [{ 'a': 1 }]
|
||||
*
|
||||
* _.castArray('abc');
|
||||
* // => ['abc']
|
||||
*
|
||||
* _.castArray(null);
|
||||
* // => [null]
|
||||
*
|
||||
* _.castArray(undefined);
|
||||
* // => [undefined]
|
||||
*
|
||||
* _.castArray();
|
||||
* // => []
|
||||
*
|
||||
* var array = [1, 2, 3];
|
||||
* console.log(_.castArray(array) === array);
|
||||
* // => true
|
||||
*/
|
||||
function castArray() {
|
||||
if (!arguments.length) {
|
||||
return [];
|
||||
}
|
||||
var value = arguments[0];
|
||||
return isArray(value) ? value : [value];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a shallow clone of `value`.
|
||||
*
|
||||
@@ -2729,14 +2677,14 @@
|
||||
* _.isFinite(3);
|
||||
* // => true
|
||||
*
|
||||
* _.isFinite(Number.MAX_VALUE);
|
||||
* // => true
|
||||
*
|
||||
* _.isFinite(3.14);
|
||||
* _.isFinite(Number.MIN_VALUE);
|
||||
* // => true
|
||||
*
|
||||
* _.isFinite(Infinity);
|
||||
* // => false
|
||||
*
|
||||
* _.isFinite('3');
|
||||
* // => false
|
||||
*/
|
||||
function isFinite(value) {
|
||||
return typeof value == 'number' && nativeIsFinite(value);
|
||||
@@ -3056,7 +3004,7 @@
|
||||
* @returns {number} Returns the converted integer.
|
||||
* @example
|
||||
*
|
||||
* _.toInteger(3);
|
||||
* _.toInteger(3.2);
|
||||
* // => 3
|
||||
*
|
||||
* _.toInteger(Number.MIN_VALUE);
|
||||
@@ -3065,7 +3013,7 @@
|
||||
* _.toInteger(Infinity);
|
||||
* // => 1.7976931348623157e+308
|
||||
*
|
||||
* _.toInteger('3');
|
||||
* _.toInteger('3.2');
|
||||
* // => 3
|
||||
*/
|
||||
var toInteger = Number;
|
||||
@@ -3081,8 +3029,8 @@
|
||||
* @returns {number} Returns the number.
|
||||
* @example
|
||||
*
|
||||
* _.toNumber(3);
|
||||
* // => 3
|
||||
* _.toNumber(3.2);
|
||||
* // => 3.2
|
||||
*
|
||||
* _.toNumber(Number.MIN_VALUE);
|
||||
* // => 5e-324
|
||||
@@ -3090,8 +3038,8 @@
|
||||
* _.toNumber(Infinity);
|
||||
* // => Infinity
|
||||
*
|
||||
* _.toNumber('3');
|
||||
* // => 3
|
||||
* _.toNumber('3.2');
|
||||
* // => 3.2
|
||||
*/
|
||||
var toNumber = Number;
|
||||
|
||||
@@ -3626,7 +3574,7 @@
|
||||
* @since 3.0.0
|
||||
* @category Util
|
||||
* @param {Object} source The object of property values to match.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @returns {Function} Returns the new spec function.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
|
||||
Reference in New Issue
Block a user