mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Bump to v3.10.0.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import baseToString from '../internal/baseToString';
|
||||
import escapeRegExpChar from '../internal/escapeRegExpChar';
|
||||
|
||||
/**
|
||||
* Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).
|
||||
* In addition to special characters the forward slash is escaped to allow for
|
||||
* easier `eval` use and `Function` compilation.
|
||||
* Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns)
|
||||
* and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern).
|
||||
*/
|
||||
var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
|
||||
var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,
|
||||
reHasRegExpChars = RegExp(reRegExpChars.source);
|
||||
|
||||
/**
|
||||
@@ -25,8 +25,8 @@ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
|
||||
function escapeRegExp(string) {
|
||||
string = baseToString(string);
|
||||
return (string && reHasRegExpChars.test(string))
|
||||
? string.replace(reRegExpChars, '\\$&')
|
||||
: string;
|
||||
? string.replace(reRegExpChars, escapeRegExpChar)
|
||||
: (string || '(?:)');
|
||||
}
|
||||
|
||||
export default escapeRegExp;
|
||||
|
||||
@@ -2,12 +2,10 @@ import baseToString from '../internal/baseToString';
|
||||
import createPadding from '../internal/createPadding';
|
||||
import root from '../internal/root';
|
||||
|
||||
/** Native method references. */
|
||||
var ceil = Math.ceil,
|
||||
floor = Math.floor;
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeIsFinite = root.isFinite;
|
||||
var nativeCeil = Math.ceil,
|
||||
nativeFloor = Math.floor,
|
||||
nativeIsFinite = root.isFinite;
|
||||
|
||||
/**
|
||||
* Pads `string` on the left and right sides if it's shorter than `length`.
|
||||
@@ -40,8 +38,8 @@ function pad(string, length, chars) {
|
||||
return string;
|
||||
}
|
||||
var mid = (length - strLength) / 2,
|
||||
leftLength = floor(mid),
|
||||
rightLength = ceil(mid);
|
||||
leftLength = nativeFloor(mid),
|
||||
rightLength = nativeCeil(mid);
|
||||
|
||||
chars = createPadding('', rightLength, chars);
|
||||
return chars.slice(0, leftLength) + string + chars;
|
||||
|
||||
@@ -5,18 +5,6 @@ import trim from './trim';
|
||||
/** Used to detect hexadecimal string values. */
|
||||
var reHasHexPrefix = /^0[xX]/;
|
||||
|
||||
/** Used to detect and test for whitespace. */
|
||||
var whitespace = (
|
||||
// Basic whitespace characters.
|
||||
' \t\x0b\f\xa0\ufeff' +
|
||||
|
||||
// Line terminators.
|
||||
'\n\r\u2028\u2029' +
|
||||
|
||||
// Unicode category "Zs" space separators.
|
||||
'\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'
|
||||
);
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeParseInt = root.parseInt;
|
||||
|
||||
@@ -44,25 +32,16 @@ var nativeParseInt = root.parseInt;
|
||||
* // => [6, 8, 10]
|
||||
*/
|
||||
function parseInt(string, radix, guard) {
|
||||
if (guard && isIterateeCall(string, radix, guard)) {
|
||||
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt`.
|
||||
// Chrome fails to trim leading <BOM> whitespace characters.
|
||||
// See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
|
||||
if (guard ? isIterateeCall(string, radix, guard) : radix == null) {
|
||||
radix = 0;
|
||||
} else if (radix) {
|
||||
radix = +radix;
|
||||
}
|
||||
return nativeParseInt(string, radix);
|
||||
}
|
||||
// Fallback for environments with pre-ES5 implementations.
|
||||
if (nativeParseInt(whitespace + '08') != 8) {
|
||||
parseInt = function(string, radix, guard) {
|
||||
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt`.
|
||||
// Chrome fails to trim leading <BOM> whitespace characters.
|
||||
// See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
|
||||
if (guard ? isIterateeCall(string, radix, guard) : radix == null) {
|
||||
radix = 0;
|
||||
} else if (radix) {
|
||||
radix = +radix;
|
||||
}
|
||||
string = trim(string);
|
||||
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
|
||||
};
|
||||
string = trim(string);
|
||||
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
|
||||
}
|
||||
|
||||
export default parseInt;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import baseToString from '../internal/baseToString';
|
||||
import root from '../internal/root';
|
||||
|
||||
/** Native method references. */
|
||||
var floor = Math.floor;
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeIsFinite = root.isFinite;
|
||||
var nativeFloor = Math.floor,
|
||||
nativeIsFinite = root.isFinite;
|
||||
|
||||
/**
|
||||
* Repeats the given string `n` times.
|
||||
@@ -40,7 +38,7 @@ function repeat(string, n) {
|
||||
if (n % 2) {
|
||||
result += string;
|
||||
}
|
||||
n = floor(n / 2);
|
||||
n = nativeFloor(n / 2);
|
||||
string += string;
|
||||
} while (n);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ var reEmptyStringLeading = /\b__p \+= '';/g,
|
||||
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
||||
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
||||
|
||||
/** Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components). */
|
||||
/** Used to match [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). */
|
||||
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
||||
|
||||
/** Used to ensure capturing order of template delimiters. */
|
||||
@@ -127,7 +127,7 @@ function template(string, options, otherOptions) {
|
||||
var settings = templateSettings.imports._.templateSettings || templateSettings;
|
||||
|
||||
if (otherOptions && isIterateeCall(string, options, otherOptions)) {
|
||||
options = otherOptions = null;
|
||||
options = otherOptions = undefined;
|
||||
}
|
||||
string = baseToString(string);
|
||||
options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults);
|
||||
|
||||
@@ -52,7 +52,7 @@ var reFlags = /\w*$/;
|
||||
*/
|
||||
function trunc(string, options, guard) {
|
||||
if (guard && isIterateeCall(string, options, guard)) {
|
||||
options = null;
|
||||
options = undefined;
|
||||
}
|
||||
var length = DEFAULT_TRUNC_LENGTH,
|
||||
omission = DEFAULT_TRUNC_OMISSION;
|
||||
|
||||
@@ -29,7 +29,7 @@ var reWords = (function() {
|
||||
*/
|
||||
function words(string, pattern, guard) {
|
||||
if (guard && isIterateeCall(string, pattern, guard)) {
|
||||
pattern = null;
|
||||
pattern = undefined;
|
||||
}
|
||||
string = baseToString(string);
|
||||
return string.match(pattern || reWords) || [];
|
||||
|
||||
Reference in New Issue
Block a user