"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lodash.js" between
lodash-4.17.20.tar.gz and lodash-4.17.21.tar.gz

About: lodash is a modern JavaScript utility library delivering modularity, performance, & extras. Tagged version.

lodash.js  (lodash-4.17.20):lodash.js  (lodash-4.17.21)
skipping to change at line 15 skipping to change at line 15
* Released under MIT license <https://lodash.com/license> * Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editor s * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editor s
*/ */
;(function() { ;(function() {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
/** Used as the semantic version number. */ /** Used as the semantic version number. */
var VERSION = '4.17.20'; var VERSION = '4.17.21';
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
/** Error message constants. */ /** Error message constants. */
var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=p onyfill.', var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=p onyfill.',
FUNC_ERROR_TEXT = 'Expected a function'; FUNC_ERROR_TEXT = 'Expected a function',
INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.t
emplate`';
/** Used to stand-in for `undefined` hash values. */ /** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__'; var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used as the maximum memoize cache size. */ /** Used as the maximum memoize cache size. */
var MAX_MEMOIZE_SIZE = 500; var MAX_MEMOIZE_SIZE = 500;
/** Used as the internal argument placeholder. */ /** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__'; var PLACEHOLDER = '__lodash_placeholder__';
skipping to change at line 155 skipping to change at line 156
reIsPlainProp = /^\w*$/, reIsPlainProp = /^\w*$/,
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*? )\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*? )\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/** /**
* Used to match `RegExp` * Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-pattern s). * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-pattern s).
*/ */
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
reHasRegExpChar = RegExp(reRegExpChar.source); reHasRegExpChar = RegExp(reRegExpChar.source);
/** Used to match leading and trailing whitespace. */ /** Used to match leading whitespace. */
var reTrim = /^\s+|\s+$/g, var reTrimStart = /^\s+/;
reTrimStart = /^\s+/,
reTrimEnd = /\s+$/; /** Used to match a single whitespace character. */
var reWhitespace = /\s/;
/** Used to match wrap detail comments. */ /** Used to match wrap detail comments. */
var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
reSplitDetails = /,? & /; reSplitDetails = /,? & /;
/** Used to match words composed of alphanumeric characters. */ /** Used to match words composed of alphanumeric characters. */
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
/**
* Used to validate the `validate` option in `_.template` variable.
*
* Forbids characters which could potentially change the meaning of the functi
on argument definition:
* - "()," (modification of function parameters)
* - "=" (default value)
* - "[]{}" (destructuring of function parameters)
* - "/" (beginning of a comment)
* - whitespace
*/
var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
/** Used to match backslashes in property paths. */ /** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g; var reEscapeChar = /\\(\\)?/g;
/** /**
* Used to match * Used to match
* [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-te mplate-literal-lexical-components). * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-te mplate-literal-lexical-components).
*/ */
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
/** Used to match `RegExp` flags from their coerced string values. */ /** Used to match `RegExp` flags from their coerced string values. */
skipping to change at line 997 skipping to change at line 1011
* @param {Array} props The property names to get values for. * @param {Array} props The property names to get values for.
* @returns {Object} Returns the key-value pairs. * @returns {Object} Returns the key-value pairs.
*/ */
function baseToPairs(object, props) { function baseToPairs(object, props) {
return arrayMap(props, function(key) { return arrayMap(props, function(key) {
return [key, object[key]]; return [key, object[key]];
}); });
} }
/** /**
* The base implementation of `_.trim`.
*
* @private
* @param {string} string The string to trim.
* @returns {string} Returns the trimmed string.
*/
function baseTrim(string) {
return string
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
: string;
}
/**
* The base implementation of `_.unary` without support for storing metadata. * The base implementation of `_.unary` without support for storing metadata.
* *
* @private * @private
* @param {Function} func The function to cap arguments for. * @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new capped function. * @returns {Function} Returns the new capped function.
*/ */
function baseUnary(func) { function baseUnary(func) {
return function(value) { return function(value) {
return func(value); return func(value);
}; };
skipping to change at line 1330 skipping to change at line 1357
* @param {string} string The string to convert. * @param {string} string The string to convert.
* @returns {Array} Returns the converted array. * @returns {Array} Returns the converted array.
*/ */
function stringToArray(string) { function stringToArray(string) {
return hasUnicode(string) return hasUnicode(string)
? unicodeToArray(string) ? unicodeToArray(string)
: asciiToArray(string); : asciiToArray(string);
} }
/** /**
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespac
e
* character of `string`.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the index of the last non-whitespace character.
*/
function trimmedEndIndex(string) {
var index = string.length;
while (index-- && reWhitespace.test(string.charAt(index))) {}
return index;
}
/**
* Used by `_.unescape` to convert HTML entities to characters. * Used by `_.unescape` to convert HTML entities to characters.
* *
* @private * @private
* @param {string} chr The matched character to unescape. * @param {string} chr The matched character to unescape.
* @returns {string} Returns the unescaped character. * @returns {string} Returns the unescaped character.
*/ */
var unescapeHtmlChar = basePropertyOf(htmlUnescapes); var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
/** /**
* Gets the size of a Unicode `string`. * Gets the size of a Unicode `string`.
skipping to change at line 12497 skipping to change at line 12539
if (isSymbol(value)) { if (isSymbol(value)) {
return NAN; return NAN;
} }
if (isObject(value)) { if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value ; var other = typeof value.valueOf == 'function' ? value.valueOf() : value ;
value = isObject(other) ? (other + '') : other; value = isObject(other) ? (other + '') : other;
} }
if (typeof value != 'string') { if (typeof value != 'string') {
return value === 0 ? value : +value; return value === 0 ? value : +value;
} }
value = value.replace(reTrim, ''); value = baseTrim(value);
var isBinary = reIsBinary.test(value); var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value)) return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8) ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value); : (reIsBadHex.test(value) ? NAN : +value);
} }
/** /**
* Converts `value` to a plain object flattening inherited enumerable string * Converts `value` to a plain object flattening inherited enumerable string
* keyed properties of `value` to own properties of the plain object. * keyed properties of `value` to own properties of the plain object.
* *
skipping to change at line 14869 skipping to change at line 14911
}); });
source += "';\n"; source += "';\n";
// If `variable` is not specified wrap a with-statement around the generat ed // If `variable` is not specified wrap a with-statement around the generat ed
// code to add the data object to the top of the scope chain. // code to add the data object to the top of the scope chain.
var variable = hasOwnProperty.call(options, 'variable') && options.variabl e; var variable = hasOwnProperty.call(options, 'variable') && options.variabl e;
if (!variable) { if (!variable) {
source = 'with (obj) {\n' + source + '\n}\n'; source = 'with (obj) {\n' + source + '\n}\n';
} }
// Throw an error if a forbidden character was found in `variable`, to pre
vent
// potential command injection attacks.
else if (reForbiddenIdentifierChars.test(variable)) {
throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
}
// Cleanup code by stripping empty strings. // Cleanup code by stripping empty strings.
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source ) source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source )
.replace(reEmptyStringMiddle, '$1') .replace(reEmptyStringMiddle, '$1')
.replace(reEmptyStringTrailing, '$1;'); .replace(reEmptyStringTrailing, '$1;');
// Frame code as the function body. // Frame code as the function body.
source = 'function(' + (variable || 'obj') + ') {\n' + source = 'function(' + (variable || 'obj') + ') {\n' +
(variable (variable
? '' ? ''
: 'obj || (obj = {});\n' : 'obj || (obj = {});\n'
skipping to change at line 14982 skipping to change at line 15030
* *
* _.trim('-_-abc-_-', '_-'); * _.trim('-_-abc-_-', '_-');
* // => 'abc' * // => 'abc'
* *
* _.map([' foo ', ' bar '], _.trim); * _.map([' foo ', ' bar '], _.trim);
* // => ['foo', 'bar'] * // => ['foo', 'bar']
*/ */
function trim(string, chars, guard) { function trim(string, chars, guard) {
string = toString(string); string = toString(string);
if (string && (guard || chars === undefined)) { if (string && (guard || chars === undefined)) {
return string.replace(reTrim, ''); return baseTrim(string);
} }
if (!string || !(chars = baseToString(chars))) { if (!string || !(chars = baseToString(chars))) {
return string; return string;
} }
var strSymbols = stringToArray(string), var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars), chrSymbols = stringToArray(chars),
start = charsStartIndex(strSymbols, chrSymbols), start = charsStartIndex(strSymbols, chrSymbols),
end = charsEndIndex(strSymbols, chrSymbols) + 1; end = charsEndIndex(strSymbols, chrSymbols) + 1;
return castSlice(strSymbols, start, end).join(''); return castSlice(strSymbols, start, end).join('');
skipping to change at line 15017 skipping to change at line 15065
* *
* _.trimEnd(' abc '); * _.trimEnd(' abc ');
* // => ' abc' * // => ' abc'
* *
* _.trimEnd('-_-abc-_-', '_-'); * _.trimEnd('-_-abc-_-', '_-');
* // => '-_-abc' * // => '-_-abc'
*/ */
function trimEnd(string, chars, guard) { function trimEnd(string, chars, guard) {
string = toString(string); string = toString(string);
if (string && (guard || chars === undefined)) { if (string && (guard || chars === undefined)) {
return string.replace(reTrimEnd, ''); return string.slice(0, trimmedEndIndex(string) + 1);
} }
if (!string || !(chars = baseToString(chars))) { if (!string || !(chars = baseToString(chars))) {
return string; return string;
} }
var strSymbols = stringToArray(string), var strSymbols = stringToArray(string),
end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
return castSlice(strSymbols, 0, end).join(''); return castSlice(strSymbols, 0, end).join('');
} }
 End of changes. 10 change blocks. 
9 lines changed or deleted 61 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)