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:
155
dist/lodash.core.js
vendored
155
dist/lodash.core.js
vendored
@@ -13,7 +13,7 @@
|
||||
var undefined;
|
||||
|
||||
/** Used as the semantic version number. */
|
||||
var VERSION = '4.15.0';
|
||||
var VERSION = '4.16.0';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -53,8 +53,7 @@
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'`': '`'
|
||||
"'": '''
|
||||
};
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
@@ -183,17 +182,6 @@
|
||||
*/
|
||||
var escapeHtmlChar = basePropertyOf(htmlEscapes);
|
||||
|
||||
/**
|
||||
* Checks if `value` is a host object in IE < 9.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
||||
*/
|
||||
function isHostObject() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a unary function that invokes `func` with its argument transformed.
|
||||
*
|
||||
@@ -414,10 +402,23 @@
|
||||
var objValue = object[key];
|
||||
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
|
||||
(value === undefined && !(key in object))) {
|
||||
object[key] = value;
|
||||
baseAssignValue(object, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `assignValue` and `assignMergeValue` without
|
||||
* value checks.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to modify.
|
||||
* @param {string} key The key of the property to assign.
|
||||
* @param {*} value The value to assign.
|
||||
*/
|
||||
function baseAssignValue(object, key, value) {
|
||||
object[key] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.create` without support for assigning
|
||||
* properties to the created object.
|
||||
@@ -674,8 +675,8 @@
|
||||
othTag = objectToString.call(other);
|
||||
othTag = othTag == argsTag ? objectTag : othTag;
|
||||
}
|
||||
var objIsObj = objTag == objectTag && !isHostObject(object),
|
||||
othIsObj = othTag == objectTag && !isHostObject(other),
|
||||
var objIsObj = objTag == objectTag,
|
||||
othIsObj = othTag == objectTag,
|
||||
isSameTag = objTag == othTag;
|
||||
|
||||
stack || (stack = []);
|
||||
@@ -832,24 +833,7 @@
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function baseRest(func, start) {
|
||||
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
||||
return function() {
|
||||
var args = arguments,
|
||||
index = -1,
|
||||
length = nativeMax(args.length - start, 0),
|
||||
array = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
array[index] = args[start + index];
|
||||
}
|
||||
index = -1;
|
||||
var otherArgs = Array(start + 1);
|
||||
while (++index < start) {
|
||||
otherArgs[index] = args[index];
|
||||
}
|
||||
otherArgs[start] = array;
|
||||
return func.apply(this, otherArgs);
|
||||
};
|
||||
return setToString(overRest(func, start, identity), func + '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -979,6 +963,7 @@
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function copyObject(source, props, object, customizer) {
|
||||
var isNew = !object;
|
||||
object || (object = {});
|
||||
|
||||
var index = -1,
|
||||
@@ -991,7 +976,14 @@
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: undefined;
|
||||
|
||||
assignValue(object, key, newValue === undefined ? source[key] : newValue);
|
||||
if (newValue === undefined) {
|
||||
newValue = source[key];
|
||||
}
|
||||
if (isNew) {
|
||||
baseAssignValue(object, key, newValue);
|
||||
} else {
|
||||
assignValue(object, key, newValue);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
@@ -1326,6 +1318,17 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `baseRest` which flattens the rest array.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to apply a rest parameter to.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function flatRest(func) {
|
||||
return setToString(overRest(func, undefined, flatten), func + '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a flattenable `arguments` object or array.
|
||||
*
|
||||
@@ -1356,6 +1359,46 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized version of `baseRest` which transforms the rest array.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to apply a rest parameter to.
|
||||
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
||||
* @param {Function} transform The rest array transform.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function overRest(func, start, transform) {
|
||||
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
||||
return function() {
|
||||
var args = arguments,
|
||||
index = -1,
|
||||
length = nativeMax(args.length - start, 0),
|
||||
array = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
array[index] = args[start + index];
|
||||
}
|
||||
index = -1;
|
||||
var otherArgs = Array(start + 1);
|
||||
while (++index < start) {
|
||||
otherArgs[index] = args[index];
|
||||
}
|
||||
otherArgs[start] = transform(array);
|
||||
return func.apply(this, otherArgs);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the `toString` method of `func` to return `string`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to modify.
|
||||
* @param {Function} string The `toString` result.
|
||||
* @returns {Function} Returns `func`.
|
||||
*/
|
||||
var setToString = identity;
|
||||
|
||||
/**
|
||||
* Converts `value` to a string key if it's not a string or symbol.
|
||||
*
|
||||
@@ -1409,17 +1452,18 @@
|
||||
* // => [1]
|
||||
*/
|
||||
function concat() {
|
||||
var length = arguments.length,
|
||||
args = Array(length ? length - 1 : 0),
|
||||
var length = arguments.length;
|
||||
if (!length) {
|
||||
return [];
|
||||
}
|
||||
var args = Array(length - 1),
|
||||
array = arguments[0],
|
||||
index = length;
|
||||
|
||||
while (index--) {
|
||||
args[index - 1] = arguments[index];
|
||||
}
|
||||
return length
|
||||
? arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1))
|
||||
: [];
|
||||
return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1905,7 +1949,7 @@
|
||||
* @see _.forEachRight
|
||||
* @example
|
||||
*
|
||||
* _([1, 2]).forEach(function(value) {
|
||||
* _.forEach([1, 2], function(value) {
|
||||
* console.log(value);
|
||||
* });
|
||||
* // => Logs `1` then `2`.
|
||||
@@ -2099,16 +2143,11 @@
|
||||
* { 'user': 'barney', 'age': 34 }
|
||||
* ];
|
||||
*
|
||||
* _.sortBy(users, function(o) { return o.user; });
|
||||
* _.sortBy(users, [function(o) { return o.user; }]);
|
||||
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
|
||||
*
|
||||
* _.sortBy(users, ['user', 'age']);
|
||||
* // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
|
||||
*
|
||||
* _.sortBy(users, 'user', function(o) {
|
||||
* return Math.floor(o.age / 10);
|
||||
* });
|
||||
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
|
||||
*/
|
||||
function sortBy(collection, iteratee) {
|
||||
var index = 0;
|
||||
@@ -2212,7 +2251,7 @@
|
||||
* _.defer(function(text) {
|
||||
* console.log(text);
|
||||
* }, 'deferred');
|
||||
* // => Logs 'deferred' after one or more milliseconds.
|
||||
* // => Logs 'deferred' after one millisecond.
|
||||
*/
|
||||
var defer = baseRest(function(func, args) {
|
||||
return baseDelay(func, 1, args);
|
||||
@@ -2698,7 +2737,7 @@
|
||||
*/
|
||||
function isObject(value) {
|
||||
var type = typeof value;
|
||||
return !!value && (type == 'object' || type == 'function');
|
||||
return value != null && (type == 'object' || type == 'function');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2726,7 +2765,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function isObjectLike(value) {
|
||||
return !!value && typeof value == 'object';
|
||||
return value != null && typeof value == 'object';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3263,8 +3302,8 @@
|
||||
* _.pick(object, ['a', 'c']);
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
*/
|
||||
var pick = baseRest(function(object, props) {
|
||||
return object == null ? {} : basePick(object, baseMap(baseFlatten(props, 1), toKey));
|
||||
var pick = flatRest(function(object, props) {
|
||||
return object == null ? {} : basePick(object, baseMap(props, toKey));
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -3337,8 +3376,8 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to
|
||||
* their corresponding HTML entities.
|
||||
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
||||
* corresponding HTML entities.
|
||||
*
|
||||
* **Note:** No other characters are escaped. To escape additional
|
||||
* characters use a third-party library like [_he_](https://mths.be/he).
|
||||
@@ -3349,12 +3388,6 @@
|
||||
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
|
||||
* (under "semi-related fun fact") for more details.
|
||||
*
|
||||
* Backticks are escaped because in IE < 9, they can break out of
|
||||
* attribute values or HTML comments. See [#59](https://html5sec.org/#59),
|
||||
* [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and
|
||||
* [#133](https://html5sec.org/#133) of the
|
||||
* [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
|
||||
*
|
||||
* When working with HTML you should always
|
||||
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
|
||||
* XSS vectors.
|
||||
|
||||
Reference in New Issue
Block a user