mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Bump to v4.16.2.
This commit is contained in:
114
main.js
114
main.js
@@ -13,13 +13,14 @@
|
||||
var undefined;
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '4.16.1';
|
||||
var VERSION = '4.16.2';
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
/** Error message constants. */
|
||||
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://github.com/es-shims.',
|
||||
FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/** Used to stand-in for `undefined` hash values. */
|
||||
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
||||
@@ -1468,6 +1469,7 @@
|
||||
var Buffer = moduleExports ? context.Buffer : undefined,
|
||||
Symbol = context.Symbol,
|
||||
Uint8Array = context.Uint8Array,
|
||||
allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
|
||||
defineProperty = Object.defineProperty,
|
||||
getPrototype = overArg(Object.getPrototypeOf, Object),
|
||||
iteratorSymbol = Symbol ? Symbol.iterator : undefined,
|
||||
@@ -1654,6 +1656,30 @@
|
||||
return new LodashWrapper(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.create` without support for assigning
|
||||
* properties to the created object.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} proto The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
var baseCreate = (function() {
|
||||
function object() {}
|
||||
return function(proto) {
|
||||
if (!isObject(proto)) {
|
||||
return {};
|
||||
}
|
||||
if (objectCreate) {
|
||||
return objectCreate(proto);
|
||||
}
|
||||
object.prototype = prototype;
|
||||
var result = new object;
|
||||
object.prototype = undefined;
|
||||
return result;
|
||||
};
|
||||
}());
|
||||
|
||||
/**
|
||||
* The function whose prototype chain sequence wrappers inherit from.
|
||||
*
|
||||
@@ -2374,8 +2400,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `_.sample` for arrays without support for iteratee
|
||||
* shorthands.
|
||||
* A specialized version of `_.sample` for arrays.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to sample.
|
||||
@@ -2395,9 +2420,7 @@
|
||||
* @returns {Array} Returns the random elements.
|
||||
*/
|
||||
function arraySampleSize(array, n) {
|
||||
var result = arrayShuffle(array);
|
||||
result.length = baseClamp(n, 0, result.length);
|
||||
return result;
|
||||
return shuffleSelf(copyArray(array), n);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2687,18 +2710,6 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.create` without support for assigning
|
||||
* properties to the created object.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} prototype The object to inherit from.
|
||||
* @returns {Object} Returns the new object.
|
||||
*/
|
||||
function baseCreate(proto) {
|
||||
return isObject(proto) ? objectCreate(proto) : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.delay` and `_.defer` which accepts `args`
|
||||
* to provide to `func`.
|
||||
@@ -3890,6 +3901,29 @@
|
||||
return setToString(overRest(func, start, identity), func + '');
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.sample`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to sample.
|
||||
* @returns {*} Returns the random element.
|
||||
*/
|
||||
function baseSample(collection) {
|
||||
return arraySample(values(collection));
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.sampleSize` without param guards.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to sample.
|
||||
* @param {number} n The number of elements to sample.
|
||||
* @returns {Array} Returns the random elements.
|
||||
*/
|
||||
function baseSampleSize(collection, n) {
|
||||
return shuffleSelf(values(collection), n);
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.set`.
|
||||
*
|
||||
@@ -3960,6 +3994,17 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* The base implementation of `_.shuffle`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array|Object} collection The collection to shuffle.
|
||||
* @returns {Array} Returns the new shuffled array.
|
||||
*/
|
||||
function baseShuffle(collection) {
|
||||
return shuffleSelf(values(collection));
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.slice` without an iteratee call guard.
|
||||
*
|
||||
@@ -4422,7 +4467,9 @@
|
||||
if (isDeep) {
|
||||
return buffer.slice();
|
||||
}
|
||||
var result = new buffer.constructor(buffer.length);
|
||||
var length = buffer.length,
|
||||
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
||||
|
||||
buffer.copy(result);
|
||||
return result;
|
||||
}
|
||||
@@ -6534,24 +6581,27 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `arrayShuffle` which mutates `array`.
|
||||
* A specialized version of `_.shuffle` which mutates and sets the size of `array`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to shuffle.
|
||||
* @param {number} [size=array.length] The size of `array`.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function shuffleSelf(array) {
|
||||
function shuffleSelf(array, size) {
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
lastIndex = length - 1;
|
||||
|
||||
while (++index < length) {
|
||||
size = size === undefined ? length : baseClamp(size, 0, length);
|
||||
while (++index < size) {
|
||||
var rand = baseRandom(index, lastIndex),
|
||||
value = array[rand];
|
||||
|
||||
array[rand] = array[index];
|
||||
array[index] = value;
|
||||
}
|
||||
array.length = size;
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -9629,7 +9679,8 @@
|
||||
* // => 2
|
||||
*/
|
||||
function sample(collection) {
|
||||
return arraySample(isArrayLike(collection) ? collection : values(collection));
|
||||
var func = isArray(collection) ? arraySample : baseSample;
|
||||
return func(collection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -9658,7 +9709,8 @@
|
||||
} else {
|
||||
n = toInteger(n);
|
||||
}
|
||||
return arraySampleSize(isArrayLike(collection) ? collection : values(collection), n);
|
||||
var func = isArray(collection) ? arraySampleSize : baseSampleSize;
|
||||
return func(collection, n);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -9677,10 +9729,8 @@
|
||||
* // => [4, 1, 3, 2]
|
||||
*/
|
||||
function shuffle(collection) {
|
||||
return shuffleSelf(isArrayLike(collection)
|
||||
? copyArray(collection)
|
||||
: values(collection)
|
||||
);
|
||||
var func = isArray(collection) ? arrayShuffle : baseShuffle;
|
||||
return func(collection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -11779,7 +11829,7 @@
|
||||
*/
|
||||
function isNative(value) {
|
||||
if (isMaskable(value)) {
|
||||
throw new Error('This method is not supported with core-js. Try https://github.com/es-shims.');
|
||||
throw new Error(CORE_ERROR_TEXT);
|
||||
}
|
||||
return baseIsNative(value);
|
||||
}
|
||||
@@ -14272,7 +14322,7 @@
|
||||
} else if (radix) {
|
||||
radix = +radix;
|
||||
}
|
||||
return nativeParseInt(toString(string), radix || 0);
|
||||
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user