mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Apply template string transform.
This commit is contained in:
@@ -23,10 +23,11 @@ const funcToString = funcProto.toString;
|
||||
const hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/** Used to detect if a method is native. */
|
||||
const reIsNative = RegExp('^' +
|
||||
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
||||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
||||
);
|
||||
const reIsNative = RegExp(`^${
|
||||
funcToString.call(hasOwnProperty)
|
||||
.replace(reRegExpChar, '\\$&')
|
||||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?')
|
||||
}$`);
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isNative` without bad shim checks.
|
||||
|
||||
@@ -27,7 +27,7 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
|
||||
}
|
||||
else {
|
||||
const newValue = customizer
|
||||
? customizer(object[key], srcValue, (key + ''), object, source, stack)
|
||||
? customizer(object[key], srcValue, `${ key }`, object, source, stack)
|
||||
: undefined;
|
||||
|
||||
if (newValue === undefined) {
|
||||
|
||||
@@ -38,7 +38,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
|
||||
return;
|
||||
}
|
||||
var newValue = customizer
|
||||
? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
||||
? customizer(objValue, srcValue, `${ key }`, object, source, stack)
|
||||
: undefined;
|
||||
|
||||
var isCommon = newValue === undefined;
|
||||
|
||||
@@ -11,7 +11,7 @@ import setToString from './_setToString.js';
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function baseRest(func, start) {
|
||||
return setToString(overRest(func, start, identity), func + '');
|
||||
return setToString(overRest(func, start, identity), `${ func }`);
|
||||
}
|
||||
|
||||
export default baseRest;
|
||||
|
||||
@@ -4,11 +4,11 @@ import isArray from './isArray.js';
|
||||
import isSymbol from './isSymbol.js';
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0;
|
||||
const INFINITY = 1 / 0;
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = Symbol ? Symbol.prototype : undefined,
|
||||
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
||||
const symbolProto = Symbol ? Symbol.prototype : undefined;
|
||||
const symbolToString = symbolProto ? symbolProto.toString : undefined;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.toString` which doesn't convert nullish
|
||||
@@ -25,12 +25,12 @@ function baseToString(value) {
|
||||
}
|
||||
if (isArray(value)) {
|
||||
// Recursively convert values (susceptible to call stack limits).
|
||||
return arrayMap(value, baseToString) + '';
|
||||
return `${ arrayMap(value, baseToString) }`;
|
||||
}
|
||||
if (isSymbol(value)) {
|
||||
return symbolToString ? symbolToString.call(value) : '';
|
||||
}
|
||||
var result = (value + '');
|
||||
const result = `${ value }`;
|
||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ function createRound(methodName) {
|
||||
if (precision) {
|
||||
// Shift with exponential notation to avoid floating-point issues.
|
||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||
var pair = (toString(number) + 'e').split('e'),
|
||||
value = func(pair[0] + 'e' + (+pair[1] + precision));
|
||||
var pair = `${ toString(number) }e`.split('e'),
|
||||
value = func(`${ pair[0] }e${ +pair[1] + precision }`);
|
||||
|
||||
pair = (toString(value) + 'e').split('e');
|
||||
return +(pair[0] + 'e' + (+pair[1] - precision));
|
||||
pair = `${ toString(value) }e`.split('e');
|
||||
return +`${ pair[0] }e${ +pair[1] - precision }`;
|
||||
}
|
||||
return func(number);
|
||||
};
|
||||
|
||||
@@ -76,7 +76,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
||||
// Coerce regexes to strings and treat strings, primitives and objects,
|
||||
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
|
||||
// for more details.
|
||||
return object == (other + '');
|
||||
return object == `${ other }`;
|
||||
|
||||
case mapTag:
|
||||
var convert = mapToArray;
|
||||
|
||||
@@ -16,7 +16,7 @@ var stringEscapes = {
|
||||
* @returns {string} Returns the escaped character.
|
||||
*/
|
||||
function escapeStringChar(chr) {
|
||||
return '\\' + stringEscapes[chr];
|
||||
return `\\${ stringEscapes[chr] }`;
|
||||
}
|
||||
|
||||
export default escapeStringChar;
|
||||
|
||||
@@ -10,7 +10,7 @@ import setToString from './_setToString.js';
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function flatRest(func) {
|
||||
return setToString(overRest(func, undefined, flatten), func + '');
|
||||
return setToString(overRest(func, undefined, flatten), `${ func }`);
|
||||
}
|
||||
|
||||
export default flatRest;
|
||||
|
||||
@@ -14,7 +14,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
* @returns {string} Returns the function name.
|
||||
*/
|
||||
function getFuncName(func) {
|
||||
var result = (func.name + ''),
|
||||
var result = `${ func.name }`,
|
||||
array = realNames[result],
|
||||
length = hasOwnProperty.call(realNames, result) ? array.length : 0;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ var rsAstralRange = '\\ud800-\\udfff',
|
||||
var rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
||||
var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
|
||||
var reHasUnicode = RegExp(`[${ rsZWJ + rsAstralRange + rsComboRange + rsVarRange }]`;
|
||||
|
||||
/**
|
||||
* Checks if `string` contains Unicode symbols.
|
||||
|
||||
@@ -10,14 +10,14 @@ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
|
||||
* @returns {string} Returns the modified source.
|
||||
*/
|
||||
function insertWrapDetails(source, details) {
|
||||
var length = details.length;
|
||||
const length = details.length;
|
||||
if (!length) {
|
||||
return source;
|
||||
}
|
||||
var lastIndex = length - 1;
|
||||
const lastIndex = length - 1;
|
||||
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
|
||||
details = details.join(length > 2 ? ', ' : ' ');
|
||||
return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
|
||||
return source.replace(reWrapComment, `{\n/* [wrapped with ${ details }] */\n`);
|
||||
}
|
||||
|
||||
export default insertWrapDetails;
|
||||
|
||||
@@ -2,8 +2,8 @@ import coreJsData from './_coreJsData.js';
|
||||
|
||||
/** Used to detect methods masquerading as native. */
|
||||
var maskSrcKey = ((() => {
|
||||
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
||||
return uid ? ('Symbol(src)_1.' + uid) : '';
|
||||
const uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
||||
return uid ? `Symbol(src)_1.${ uid }` : '';
|
||||
})());
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ import updateWrapDetails from './_updateWrapDetails.js';
|
||||
* @returns {Function} Returns `wrapper`.
|
||||
*/
|
||||
function setWrapToString(wrapper, reference, bitmask) {
|
||||
var source = (reference + '');
|
||||
const source = `${ reference }`;
|
||||
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ function toKey(value) {
|
||||
if (typeof value == 'string' || isSymbol(value)) {
|
||||
return value;
|
||||
}
|
||||
var result = (value + '');
|
||||
const result = `${ value }`;
|
||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ function toSource(func) {
|
||||
return funcToString.call(func);
|
||||
} catch (e) {}
|
||||
try {
|
||||
return (func + '');
|
||||
return `${ func }`;
|
||||
} catch (e) {}
|
||||
}
|
||||
return '';
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f',
|
||||
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||||
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
const rsAstralRange = '\\ud800-\\udfff';
|
||||
const rsComboMarksRange = '\\u0300-\\u036f';
|
||||
const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
|
||||
const rsComboSymbolsRange = '\\u20d0-\\u20ff';
|
||||
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
||||
const rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsAstral = '[' + rsAstralRange + ']',
|
||||
rsCombo = '[' + rsComboRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsZWJ = '\\u200d';
|
||||
const rsAstral = `[${ rsAstralRange }]`;
|
||||
const rsCombo = `[${ rsComboRange }]`;
|
||||
const rsFitz = '\\ud83c[\\udffb-\\udfff]';
|
||||
const rsModifier = `(?:${ rsCombo }|${ rsFitz })`;
|
||||
const rsNonAstral = `[^${ rsAstralRange }]`;
|
||||
const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
|
||||
const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
|
||||
const rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||
const reOptMod = `${ rsModifier }?`;
|
||||
const rsOptVar = `[${ rsVarRange }]?`;
|
||||
const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`;
|
||||
const rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
||||
const rsSymbol = `(?:${ [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') })`;
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
const reUnicode = RegExp(`${ rsFitz }(?=${ rsFitz })|${ rsSymbol + rsSeq }`, 'g');
|
||||
|
||||
/**
|
||||
* Gets the size of a Unicode `string`.
|
||||
@@ -34,7 +34,7 @@ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
* @returns {number} Returns the string size.
|
||||
*/
|
||||
function unicodeSize(string) {
|
||||
var result = reUnicode.lastIndex = 0;
|
||||
let result = reUnicode.lastIndex = 0;
|
||||
while (reUnicode.test(string)) {
|
||||
++result;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f',
|
||||
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||||
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
||||
rsVarRange = '\\ufe0e\\ufe0f';
|
||||
const rsAstralRange = '\\ud800-\\udfff';
|
||||
const rsComboMarksRange = '\\u0300-\\u036f';
|
||||
const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
|
||||
const rsComboSymbolsRange = '\\u20d0-\\u20ff';
|
||||
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
||||
const rsVarRange = '\\ufe0e\\ufe0f';
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsAstral = '[' + rsAstralRange + ']',
|
||||
rsCombo = '[' + rsComboRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsZWJ = '\\u200d';
|
||||
const rsAstral = `[${ rsAstralRange }]`;
|
||||
const rsCombo = `[${ rsComboRange }]`;
|
||||
const rsFitz = '\\ud83c[\\udffb-\\udfff]';
|
||||
const rsModifier = `(?:${ rsCombo }|${ rsFitz })`;
|
||||
const rsNonAstral = `[^${ rsAstralRange }]`;
|
||||
const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
|
||||
const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
|
||||
const rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
||||
const reOptMod = `${ rsModifier }?`;
|
||||
const rsOptVar = `[${ rsVarRange }]?`;
|
||||
const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`;
|
||||
const rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
||||
const rsSymbol = `(?:${ [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') })`;
|
||||
|
||||
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
||||
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
||||
const reUnicode = RegExp(`${ rsFitz }(?=${ rsFitz })|${ rsSymbol + rsSeq }`, 'g');
|
||||
|
||||
/**
|
||||
* Converts a Unicode `string` to an array.
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsAstralRange = '\\ud800-\\udfff',
|
||||
rsComboMarksRange = '\\u0300-\\u036f',
|
||||
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||||
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
||||
rsDingbatRange = '\\u2700-\\u27bf',
|
||||
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
|
||||
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
|
||||
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
|
||||
rsPunctuationRange = '\\u2000-\\u206f',
|
||||
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
|
||||
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
|
||||
rsVarRange = '\\ufe0e\\ufe0f',
|
||||
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
||||
const rsAstralRange = '\\ud800-\\udfff';
|
||||
const rsComboMarksRange = '\\u0300-\\u036f';
|
||||
const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
|
||||
const rsComboSymbolsRange = '\\u20d0-\\u20ff';
|
||||
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
||||
const rsDingbatRange = '\\u2700-\\u27bf';
|
||||
const rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff';
|
||||
const rsMathOpRange = '\\xac\\xb1\\xd7\\xf7';
|
||||
const rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf';
|
||||
const rsPunctuationRange = '\\u2000-\\u206f';
|
||||
const rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000';
|
||||
const rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde';
|
||||
const rsVarRange = '\\ufe0e\\ufe0f';
|
||||
const rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsApos = "['\u2019]",
|
||||
rsBreak = '[' + rsBreakRange + ']',
|
||||
rsCombo = '[' + rsComboRange + ']',
|
||||
rsDigits = '\\d+',
|
||||
rsDingbat = '[' + rsDingbatRange + ']',
|
||||
rsLower = '[' + rsLowerRange + ']',
|
||||
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
|
||||
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
||||
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
||||
rsNonAstral = '[^' + rsAstralRange + ']',
|
||||
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
||||
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
||||
rsUpper = '[' + rsUpperRange + ']',
|
||||
rsZWJ = '\\u200d';
|
||||
const rsApos = "['\u2019]";
|
||||
const rsBreak = `[${ rsBreakRange }]`;
|
||||
const rsCombo = `[${ rsComboRange }]`;
|
||||
const rsDigits = '\\d+';
|
||||
const rsDingbat = `[${ rsDingbatRange }]`;
|
||||
const rsLower = `[${ rsLowerRange }]`;
|
||||
const rsMisc = `[^${ rsAstralRange }${ rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange }]`;
|
||||
const rsFitz = '\\ud83c[\\udffb-\\udfff]';
|
||||
const rsModifier = `(?:${ rsCombo }|${ rsFitz })`;
|
||||
const rsNonAstral = `[^${ rsAstralRange }]`;
|
||||
const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
|
||||
const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
|
||||
const rsUpper = `[${ rsUpperRange }]`;
|
||||
const rsZWJ = '\\u200d';
|
||||
|
||||
/** Used to compose unicode regexes. */
|
||||
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
|
||||
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
|
||||
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
|
||||
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
|
||||
reOptMod = rsModifier + '?',
|
||||
rsOptVar = '[' + rsVarRange + ']?',
|
||||
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
||||
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
|
||||
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
|
||||
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
||||
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
|
||||
const rsMiscLower = `(?:${ rsLower }|${ rsMisc })`;
|
||||
const rsMiscUpper = `(?:${ rsUpper }|${ rsMisc })`;
|
||||
const rsOptContrLower = `(?:${ rsApos }(?:d|ll|m|re|s|t|ve))?`;
|
||||
const rsOptContrUpper = `(?:${ rsApos }(?:D|LL|M|RE|S|T|VE))?`;
|
||||
const reOptMod = `${ rsModifier }?`;
|
||||
const rsOptVar = `[${ rsVarRange }]?`;
|
||||
const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`;
|
||||
const rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)';
|
||||
const rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)';
|
||||
const rsSeq = rsOptVar + reOptMod + rsOptJoin;
|
||||
const rsEmoji = `(?:${ [rsDingbat, rsRegional, rsSurrPair].join('|') })${ rsSeq }`;
|
||||
|
||||
/** Used to match complex or compound words. */
|
||||
var reUnicodeWord = RegExp([
|
||||
rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
|
||||
rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
|
||||
rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
|
||||
rsUpper + '+' + rsOptContrUpper,
|
||||
const reUnicodeWord = RegExp([
|
||||
`${ rsUpper }?${ rsLower }+${ rsOptContrLower }(?=${ [rsBreak, rsUpper, '$'].join('|') })`,
|
||||
`${ rsMiscUpper }+${ rsOptContrUpper }(?=${ [rsBreak, rsUpper + rsMiscLower, '$'].join('|') })`,
|
||||
`${ rsUpper }?${ rsMiscLower}+${ rsOptContrLower }`,
|
||||
`${ rsUpper }+${ rsOptContrUpper }`,
|
||||
rsOrdUpper,
|
||||
rsOrdLower,
|
||||
rsDigits,
|
||||
|
||||
@@ -35,7 +35,7 @@ var wrapFlags = [
|
||||
*/
|
||||
function updateWrapDetails(details, bitmask) {
|
||||
arrayEach(wrapFlags, pair => {
|
||||
var value = '_.' + pair[0];
|
||||
var value = `_.${ pair[0] }`;
|
||||
if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
|
||||
details.push(value);
|
||||
}
|
||||
|
||||
14
deburr.js
14
deburr.js
@@ -2,22 +2,22 @@ import deburrLetter from './_deburrLetter.js';
|
||||
import toString from './toString.js';
|
||||
|
||||
/** Used to match Latin Unicode letters (excluding mathematical operators). */
|
||||
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
||||
const reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
|
||||
|
||||
/** Used to compose unicode character classes. */
|
||||
var rsComboMarksRange = '\\u0300-\\u036f',
|
||||
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
||||
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
||||
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
||||
const rsComboMarksRange = '\\u0300-\\u036f';
|
||||
const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
|
||||
const rsComboSymbolsRange = '\\u20d0-\\u20ff';
|
||||
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
|
||||
|
||||
/** Used to compose unicode capture groups. */
|
||||
var rsCombo = '[' + rsComboRange + ']';
|
||||
const rsCombo = `[${ rsComboRange }]`;
|
||||
|
||||
/**
|
||||
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
|
||||
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
|
||||
*/
|
||||
var reComboMark = RegExp(rsCombo, 'g');
|
||||
const reComboMark = RegExp(rsCombo, 'g');
|
||||
|
||||
/**
|
||||
* Deburrs `string` by converting
|
||||
|
||||
15
template.js
15
template.js
@@ -162,7 +162,7 @@ function template(string, options, guard) {
|
||||
, 'g');
|
||||
|
||||
// Use a sourceURL for easier debugging.
|
||||
var sourceURL = 'sourceURL' in options ? '//# sourceURL=' + options.sourceURL + '\n' : '';
|
||||
var sourceURL = 'sourceURL' in options ? `//# sourceURL=${ options.sourceURL }\n` : '';
|
||||
|
||||
string.replace(reDelimiters, (
|
||||
match,
|
||||
@@ -180,14 +180,14 @@ function template(string, options, guard) {
|
||||
// Replace delimiters with snippets.
|
||||
if (escapeValue) {
|
||||
isEscaping = true;
|
||||
source += "' +\n__e(" + escapeValue + ") +\n'";
|
||||
source += `' +\n__e(${ escapeValue }) +\n'`;
|
||||
}
|
||||
if (evaluateValue) {
|
||||
isEvaluating = true;
|
||||
source += "';\n" + evaluateValue + ";\n__p += '";
|
||||
source += `';\n${ evaluateValue };\n__p += '`;
|
||||
}
|
||||
if (interpolateValue) {
|
||||
source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
||||
source += `' +\n((__t = (${ interpolateValue })) == null ? '' : __t) +\n'`;
|
||||
}
|
||||
index = offset + match.length;
|
||||
|
||||
@@ -202,7 +202,7 @@ function template(string, options, guard) {
|
||||
// code to add the data object to the top of the scope chain.
|
||||
var variable = options.variable;
|
||||
if (!variable) {
|
||||
source = 'with (obj) {\n' + source + '\n}\n';
|
||||
source = `with (obj) {\n${ source }\n}\n`;
|
||||
}
|
||||
// Cleanup code by stripping empty strings.
|
||||
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
||||
@@ -210,7 +210,7 @@ function template(string, options, guard) {
|
||||
.replace(reEmptyStringTrailing, '$1;');
|
||||
|
||||
// Frame code as the function body.
|
||||
source = 'function(' + (variable || 'obj') + ') {\n' +
|
||||
source = `function(${ variable || 'obj' }) {\n` +
|
||||
(variable
|
||||
? ''
|
||||
: 'obj || (obj = {});\n'
|
||||
@@ -228,8 +228,7 @@ function template(string, options, guard) {
|
||||
source +
|
||||
'return __p\n}';
|
||||
|
||||
var result = attempt(() => Function(importsKeys, sourceURL + 'return ' + source)
|
||||
.apply(undefined, importsValues));
|
||||
var result = attempt(() => Function(importsKeys, `${ sourceURL }return ${ source }`))(...importsValues);
|
||||
|
||||
// Provide the compiled function's source by its `toString` method or
|
||||
// the `source` property as a convenience for inlining compiled templates.
|
||||
|
||||
@@ -51,7 +51,7 @@ function toNumber(value) {
|
||||
}
|
||||
if (isObject(value)) {
|
||||
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
||||
value = isObject(other) ? (other + '') : other;
|
||||
value = isObject(other) ? `${ other }` : other;
|
||||
}
|
||||
if (typeof value != 'string') {
|
||||
return value === 0 ? value : +value;
|
||||
|
||||
@@ -91,7 +91,7 @@ function truncate(string, options) {
|
||||
substring = result;
|
||||
|
||||
if (!separator.global) {
|
||||
separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
|
||||
separator = RegExp(separator.source, `${ toString(reFlags.exec(separator)) }g`);
|
||||
}
|
||||
separator.lastIndex = 0;
|
||||
while ((match = separator.exec(substring))) {
|
||||
|
||||
Reference in New Issue
Block a user