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:
118
dist/lodash.js
vendored
118
dist/lodash.js
vendored
@@ -12,7 +12,7 @@
|
||||
var undefined;
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '4.16.3';
|
||||
var VERSION = '4.16.4';
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
@@ -2387,18 +2387,26 @@
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function arrayLikeKeys(value, inherited) {
|
||||
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
||||
// Safari 9 makes `arguments.length` enumerable in strict mode.
|
||||
var result = (isArray(value) || isArguments(value))
|
||||
? baseTimes(value.length, String)
|
||||
: [];
|
||||
|
||||
var length = result.length,
|
||||
skipIndexes = !!length;
|
||||
var isArr = isArray(value),
|
||||
isArg = !isArr && isArguments(value),
|
||||
isBuff = !isArr && !isArg && isBuffer(value),
|
||||
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
|
||||
skipIndexes = isArr || isArg || isBuff || isType,
|
||||
result = skipIndexes ? baseTimes(value.length, String) : [],
|
||||
length = result.length;
|
||||
|
||||
for (var key in value) {
|
||||
if ((inherited || hasOwnProperty.call(value, key)) &&
|
||||
!(skipIndexes && (key == 'length' || isIndex(key, length)))) {
|
||||
!(skipIndexes && (
|
||||
// Safari 9 has enumerable `arguments.length` in strict mode.
|
||||
key == 'length' ||
|
||||
// Node.js 0.10 has enumerable non-index properties on buffers.
|
||||
(isBuff && (key == 'offset' || key == 'parent')) ||
|
||||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
||||
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
||||
// Skip index properties.
|
||||
isIndex(key, length)
|
||||
))) {
|
||||
result.push(key);
|
||||
}
|
||||
}
|
||||
@@ -2426,7 +2434,7 @@
|
||||
* @returns {Array} Returns the random elements.
|
||||
*/
|
||||
function arraySampleSize(array, n) {
|
||||
return shuffleSelf(copyArray(array), n);
|
||||
return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2662,9 +2670,7 @@
|
||||
}
|
||||
stack.set(value, result);
|
||||
|
||||
if (!isArr) {
|
||||
var props = isFull ? getAllKeys(value) : keys(value);
|
||||
}
|
||||
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value);
|
||||
arrayEach(props || value, function(subValue, key) {
|
||||
if (props) {
|
||||
key = subValue;
|
||||
@@ -3198,6 +3204,17 @@
|
||||
return func == null ? undefined : apply(func, object, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isArguments`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
||||
*/
|
||||
function baseIsArguments(value) {
|
||||
return isObjectLike(value) && objectToString.call(value) == argsTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isArrayBuffer` without Node.js optimizations.
|
||||
*
|
||||
@@ -3574,14 +3591,7 @@
|
||||
if (object === source) {
|
||||
return;
|
||||
}
|
||||
if (!(isArray(source) || isTypedArray(source))) {
|
||||
var props = baseKeysIn(source);
|
||||
}
|
||||
arrayEach(props || source, function(srcValue, key) {
|
||||
if (props) {
|
||||
key = srcValue;
|
||||
srcValue = source[key];
|
||||
}
|
||||
baseFor(source, function(srcValue, key) {
|
||||
if (isObject(srcValue)) {
|
||||
stack || (stack = new Stack);
|
||||
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
||||
@@ -3596,7 +3606,7 @@
|
||||
}
|
||||
assignMergeValue(object, key, newValue);
|
||||
}
|
||||
});
|
||||
}, keysIn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3631,16 +3641,21 @@
|
||||
|
||||
if (isCommon) {
|
||||
var isArr = isArray(srcValue),
|
||||
isTyped = !isArr && isTypedArray(srcValue);
|
||||
isBuff = !isArr && isBuffer(srcValue),
|
||||
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
|
||||
|
||||
newValue = srcValue;
|
||||
if (isArr || isTyped) {
|
||||
if (isArr || isBuff || isTyped) {
|
||||
if (isArray(objValue)) {
|
||||
newValue = objValue;
|
||||
}
|
||||
else if (isArrayLikeObject(objValue)) {
|
||||
newValue = copyArray(objValue);
|
||||
}
|
||||
else if (isBuff) {
|
||||
isCommon = false;
|
||||
newValue = cloneBuffer(srcValue, true);
|
||||
}
|
||||
else if (isTyped) {
|
||||
isCommon = false;
|
||||
newValue = cloneTypedArray(srcValue, true);
|
||||
@@ -3937,7 +3952,8 @@
|
||||
* @returns {Array} Returns the random elements.
|
||||
*/
|
||||
function baseSampleSize(collection, n) {
|
||||
return shuffleSelf(values(collection), n);
|
||||
var array = values(collection);
|
||||
return shuffleSelf(array, baseClamp(n, 0, array.length));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4214,6 +4230,10 @@
|
||||
if (typeof value == 'string') {
|
||||
return value;
|
||||
}
|
||||
if (isArray(value)) {
|
||||
// Recursively convert values (susceptible to call stack limits).
|
||||
return arrayMap(value, baseToString) + '';
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return symbolToString ? symbolToString.call(value) : '';
|
||||
}
|
||||
@@ -6609,7 +6629,7 @@
|
||||
length = array.length,
|
||||
lastIndex = length - 1;
|
||||
|
||||
size = size === undefined ? length : baseClamp(size, 0, length);
|
||||
size = size === undefined ? length : size;
|
||||
while (++index < size) {
|
||||
var rand = baseRandom(index, lastIndex),
|
||||
value = array[rand];
|
||||
@@ -11182,11 +11202,10 @@
|
||||
* _.isArguments([1, 2, 3]);
|
||||
* // => false
|
||||
*/
|
||||
function isArguments(value) {
|
||||
// Safari 8.1 makes `arguments.callee` enumerable in strict mode.
|
||||
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
|
||||
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
|
||||
}
|
||||
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
||||
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
|
||||
!propertyIsEnumerable.call(value, 'callee');
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as an `Array` object.
|
||||
@@ -11406,8 +11425,8 @@
|
||||
*/
|
||||
function isEmpty(value) {
|
||||
if (isArrayLike(value) &&
|
||||
(isArray(value) || typeof value == 'string' ||
|
||||
typeof value.splice == 'function' || isBuffer(value) || isArguments(value))) {
|
||||
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
||||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
||||
return !value.length;
|
||||
}
|
||||
var tag = getTag(value);
|
||||
@@ -11415,7 +11434,7 @@
|
||||
return !value.size;
|
||||
}
|
||||
if (isPrototype(value)) {
|
||||
return !nativeKeys(value).length;
|
||||
return !baseKeys(value).length;
|
||||
}
|
||||
for (var key in value) {
|
||||
if (hasOwnProperty.call(value, key)) {
|
||||
@@ -11570,7 +11589,7 @@
|
||||
*/
|
||||
function isFunction(value) {
|
||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
||||
// in Safari 9 which returns 'object' for typed array and other constructors.
|
||||
var tag = isObject(value) ? objectToString.call(value) : '';
|
||||
return tag == funcTag || tag == genTag || tag == proxyTag;
|
||||
}
|
||||
@@ -12460,8 +12479,8 @@
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to process.
|
||||
* @returns {string} Returns the string.
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {string} Returns the converted string.
|
||||
* @example
|
||||
*
|
||||
* _.toString(null);
|
||||
@@ -13645,22 +13664,23 @@
|
||||
* // => { '1': ['a', 'c'], '2': ['b'] }
|
||||
*/
|
||||
function transform(object, iteratee, accumulator) {
|
||||
var isArr = isArray(object) || isTypedArray(object);
|
||||
iteratee = getIteratee(iteratee, 4);
|
||||
var isArr = isArray(object),
|
||||
isArrLike = isArr || isBuffer(object) || isTypedArray(object);
|
||||
|
||||
iteratee = getIteratee(iteratee, 4);
|
||||
if (accumulator == null) {
|
||||
if (isArr || isObject(object)) {
|
||||
var Ctor = object.constructor;
|
||||
if (isArr) {
|
||||
accumulator = isArray(object) ? new Ctor : [];
|
||||
} else {
|
||||
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
|
||||
}
|
||||
} else {
|
||||
var Ctor = object && object.constructor;
|
||||
if (isArrLike) {
|
||||
accumulator = isArr ? new Ctor : [];
|
||||
}
|
||||
else if (isObject(object)) {
|
||||
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
|
||||
}
|
||||
else {
|
||||
accumulator = {};
|
||||
}
|
||||
}
|
||||
(isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
|
||||
(isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
|
||||
return iteratee(accumulator, value, index, object);
|
||||
});
|
||||
return accumulator;
|
||||
|
||||
Reference in New Issue
Block a user