Apply template string transform.

This commit is contained in:
John-David Dalton
2017-01-06 18:02:01 -08:00
parent 41ad5e901f
commit 4c881b2726
24 changed files with 132 additions and 132 deletions

View File

@@ -23,10 +23,11 @@ const funcToString = funcProto.toString;
const hasOwnProperty = objectProto.hasOwnProperty; const hasOwnProperty = objectProto.hasOwnProperty;
/** Used to detect if a method is native. */ /** Used to detect if a method is native. */
const reIsNative = RegExp('^' + const reIsNative = RegExp(`^${
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') funcToString.call(hasOwnProperty)
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' .replace(reRegExpChar, '\\$&')
); .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?')
}$`);
/** /**
* The base implementation of `_.isNative` without bad shim checks. * The base implementation of `_.isNative` without bad shim checks.

View File

@@ -27,7 +27,7 @@ function baseMerge(object, source, srcIndex, customizer, stack) {
} }
else { else {
const newValue = customizer const newValue = customizer
? customizer(object[key], srcValue, (key + ''), object, source, stack) ? customizer(object[key], srcValue, `${ key }`, object, source, stack)
: undefined; : undefined;
if (newValue === undefined) { if (newValue === undefined) {

View File

@@ -38,7 +38,7 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
return; return;
} }
var newValue = customizer var newValue = customizer
? customizer(objValue, srcValue, (key + ''), object, source, stack) ? customizer(objValue, srcValue, `${ key }`, object, source, stack)
: undefined; : undefined;
var isCommon = newValue === undefined; var isCommon = newValue === undefined;

View File

@@ -11,7 +11,7 @@ import setToString from './_setToString.js';
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
*/ */
function baseRest(func, start) { function baseRest(func, start) {
return setToString(overRest(func, start, identity), func + ''); return setToString(overRest(func, start, identity), `${ func }`);
} }
export default baseRest; export default baseRest;

View File

@@ -4,11 +4,11 @@ import isArray from './isArray.js';
import isSymbol from './isSymbol.js'; import isSymbol from './isSymbol.js';
/** Used as references for various `Number` constants. */ /** Used as references for various `Number` constants. */
var INFINITY = 1 / 0; const INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */ /** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined, const symbolProto = Symbol ? Symbol.prototype : undefined;
symbolToString = symbolProto ? symbolProto.toString : undefined; const symbolToString = symbolProto ? symbolProto.toString : undefined;
/** /**
* The base implementation of `_.toString` which doesn't convert nullish * The base implementation of `_.toString` which doesn't convert nullish
@@ -25,12 +25,12 @@ function baseToString(value) {
} }
if (isArray(value)) { if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits). // Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + ''; return `${ arrayMap(value, baseToString) }`;
} }
if (isSymbol(value)) { if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : ''; return symbolToString ? symbolToString.call(value) : '';
} }
var result = (value + ''); const result = `${ value }`;
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
} }

View File

@@ -20,11 +20,11 @@ function createRound(methodName) {
if (precision) { if (precision) {
// Shift with exponential notation to avoid floating-point issues. // Shift with exponential notation to avoid floating-point issues.
// See [MDN](https://mdn.io/round#Examples) for more details. // See [MDN](https://mdn.io/round#Examples) for more details.
var pair = (toString(number) + 'e').split('e'), var pair = `${ toString(number) }e`.split('e'),
value = func(pair[0] + 'e' + (+pair[1] + precision)); value = func(`${ pair[0] }e${ +pair[1] + precision }`);
pair = (toString(value) + 'e').split('e'); pair = `${ toString(value) }e`.split('e');
return +(pair[0] + 'e' + (+pair[1] - precision)); return +`${ pair[0] }e${ +pair[1] - precision }`;
} }
return func(number); return func(number);
}; };

View File

@@ -76,7 +76,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
// Coerce regexes to strings and treat strings, primitives and objects, // 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 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
// for more details. // for more details.
return object == (other + ''); return object == `${ other }`;
case mapTag: case mapTag:
var convert = mapToArray; var convert = mapToArray;

View File

@@ -16,7 +16,7 @@ var stringEscapes = {
* @returns {string} Returns the escaped character. * @returns {string} Returns the escaped character.
*/ */
function escapeStringChar(chr) { function escapeStringChar(chr) {
return '\\' + stringEscapes[chr]; return `\\${ stringEscapes[chr] }`;
} }
export default escapeStringChar; export default escapeStringChar;

View File

@@ -10,7 +10,7 @@ import setToString from './_setToString.js';
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
*/ */
function flatRest(func) { function flatRest(func) {
return setToString(overRest(func, undefined, flatten), func + ''); return setToString(overRest(func, undefined, flatten), `${ func }`);
} }
export default flatRest; export default flatRest;

View File

@@ -14,7 +14,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* @returns {string} Returns the function name. * @returns {string} Returns the function name.
*/ */
function getFuncName(func) { function getFuncName(func) {
var result = (func.name + ''), var result = `${ func.name }`,
array = realNames[result], array = realNames[result],
length = hasOwnProperty.call(realNames, result) ? array.length : 0; length = hasOwnProperty.call(realNames, result) ? array.length : 0;

View File

@@ -10,7 +10,7 @@ var rsAstralRange = '\\ud800-\\udfff',
var rsZWJ = '\\u200d'; 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/). */ /** 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. * Checks if `string` contains Unicode symbols.

View File

@@ -10,14 +10,14 @@ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;
* @returns {string} Returns the modified source. * @returns {string} Returns the modified source.
*/ */
function insertWrapDetails(source, details) { function insertWrapDetails(source, details) {
var length = details.length; const length = details.length;
if (!length) { if (!length) {
return source; return source;
} }
var lastIndex = length - 1; const lastIndex = length - 1;
details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
details = details.join(length > 2 ? ', ' : ' '); 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; export default insertWrapDetails;

View File

@@ -2,8 +2,8 @@ import coreJsData from './_coreJsData.js';
/** Used to detect methods masquerading as native. */ /** Used to detect methods masquerading as native. */
var maskSrcKey = ((() => { var maskSrcKey = ((() => {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); const uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : ''; return uid ? `Symbol(src)_1.${ uid }` : '';
})()); })());
/** /**

View File

@@ -14,7 +14,7 @@ import updateWrapDetails from './_updateWrapDetails.js';
* @returns {Function} Returns `wrapper`. * @returns {Function} Returns `wrapper`.
*/ */
function setWrapToString(wrapper, reference, bitmask) { function setWrapToString(wrapper, reference, bitmask) {
var source = (reference + ''); const source = `${ reference }`;
return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
} }

View File

@@ -14,7 +14,7 @@ function toKey(value) {
if (typeof value == 'string' || isSymbol(value)) { if (typeof value == 'string' || isSymbol(value)) {
return value; return value;
} }
var result = (value + ''); const result = `${ value }`;
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
} }

View File

@@ -17,7 +17,7 @@ function toSource(func) {
return funcToString.call(func); return funcToString.call(func);
} catch (e) {} } catch (e) {}
try { try {
return (func + ''); return `${ func }`;
} catch (e) {} } catch (e) {}
} }
return ''; return '';

View File

@@ -1,30 +1,30 @@
/** Used to compose unicode character classes. */ /** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff', const rsAstralRange = '\\ud800-\\udfff';
rsComboMarksRange = '\\u0300-\\u036f', const rsComboMarksRange = '\\u0300-\\u036f';
reComboHalfMarksRange = '\\ufe20-\\ufe2f', const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
rsComboSymbolsRange = '\\u20d0-\\u20ff', const rsComboSymbolsRange = '\\u20d0-\\u20ff';
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
rsVarRange = '\\ufe0e\\ufe0f'; const rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */ /** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange + ']', const rsAstral = `[${ rsAstralRange }]`;
rsCombo = '[' + rsComboRange + ']', const rsCombo = `[${ rsComboRange }]`;
rsFitz = '\\ud83c[\\udffb-\\udfff]', const rsFitz = '\\ud83c[\\udffb-\\udfff]';
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', const rsModifier = `(?:${ rsCombo }|${ rsFitz })`;
rsNonAstral = '[^' + rsAstralRange + ']', const rsNonAstral = `[^${ rsAstralRange }]`;
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
rsZWJ = '\\u200d'; const rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */ /** Used to compose unicode regexes. */
var reOptMod = rsModifier + '?', const reOptMod = `${ rsModifier }?`;
rsOptVar = '[' + rsVarRange + ']?', const rsOptVar = `[${ rsVarRange }]?`;
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`;
rsSeq = rsOptVar + reOptMod + rsOptJoin, const rsSeq = rsOptVar + reOptMod + rsOptJoin;
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; const rsSymbol = `(?:${ [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') })`;
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ /** 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`. * 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. * @returns {number} Returns the string size.
*/ */
function unicodeSize(string) { function unicodeSize(string) {
var result = reUnicode.lastIndex = 0; let result = reUnicode.lastIndex = 0;
while (reUnicode.test(string)) { while (reUnicode.test(string)) {
++result; ++result;
} }

View File

@@ -1,30 +1,30 @@
/** Used to compose unicode character classes. */ /** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff', const rsAstralRange = '\\ud800-\\udfff';
rsComboMarksRange = '\\u0300-\\u036f', const rsComboMarksRange = '\\u0300-\\u036f';
reComboHalfMarksRange = '\\ufe20-\\ufe2f', const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
rsComboSymbolsRange = '\\u20d0-\\u20ff', const rsComboSymbolsRange = '\\u20d0-\\u20ff';
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
rsVarRange = '\\ufe0e\\ufe0f'; const rsVarRange = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */ /** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange + ']', const rsAstral = `[${ rsAstralRange }]`;
rsCombo = '[' + rsComboRange + ']', const rsCombo = `[${ rsComboRange }]`;
rsFitz = '\\ud83c[\\udffb-\\udfff]', const rsFitz = '\\ud83c[\\udffb-\\udfff]';
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', const rsModifier = `(?:${ rsCombo }|${ rsFitz })`;
rsNonAstral = '[^' + rsAstralRange + ']', const rsNonAstral = `[^${ rsAstralRange }]`;
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
rsZWJ = '\\u200d'; const rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */ /** Used to compose unicode regexes. */
var reOptMod = rsModifier + '?', const reOptMod = `${ rsModifier }?`;
rsOptVar = '[' + rsVarRange + ']?', const rsOptVar = `[${ rsVarRange }]?`;
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`;
rsSeq = rsOptVar + reOptMod + rsOptJoin, const rsSeq = rsOptVar + reOptMod + rsOptJoin;
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; const rsSymbol = `(?:${ [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') })`;
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ /** 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. * Converts a Unicode `string` to an array.

View File

@@ -1,54 +1,54 @@
/** Used to compose unicode character classes. */ /** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff', const rsAstralRange = '\\ud800-\\udfff';
rsComboMarksRange = '\\u0300-\\u036f', const rsComboMarksRange = '\\u0300-\\u036f';
reComboHalfMarksRange = '\\ufe20-\\ufe2f', const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
rsComboSymbolsRange = '\\u20d0-\\u20ff', const rsComboSymbolsRange = '\\u20d0-\\u20ff';
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
rsDingbatRange = '\\u2700-\\u27bf', const rsDingbatRange = '\\u2700-\\u27bf';
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', const rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff';
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', const rsMathOpRange = '\\xac\\xb1\\xd7\\xf7';
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', const rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf';
rsPunctuationRange = '\\u2000-\\u206f', const 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', 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';
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', const rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde';
rsVarRange = '\\ufe0e\\ufe0f', const rsVarRange = '\\ufe0e\\ufe0f';
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; const rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
/** Used to compose unicode capture groups. */ /** Used to compose unicode capture groups. */
var rsApos = "['\u2019]", const rsApos = "['\u2019]";
rsBreak = '[' + rsBreakRange + ']', const rsBreak = `[${ rsBreakRange }]`;
rsCombo = '[' + rsComboRange + ']', const rsCombo = `[${ rsComboRange }]`;
rsDigits = '\\d+', const rsDigits = '\\d+';
rsDingbat = '[' + rsDingbatRange + ']', const rsDingbat = `[${ rsDingbatRange }]`;
rsLower = '[' + rsLowerRange + ']', const rsLower = `[${ rsLowerRange }]`;
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', const rsMisc = `[^${ rsAstralRange }${ rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange }]`;
rsFitz = '\\ud83c[\\udffb-\\udfff]', const rsFitz = '\\ud83c[\\udffb-\\udfff]';
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', const rsModifier = `(?:${ rsCombo }|${ rsFitz })`;
rsNonAstral = '[^' + rsAstralRange + ']', const rsNonAstral = `[^${ rsAstralRange }]`;
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
rsUpper = '[' + rsUpperRange + ']', const rsUpper = `[${ rsUpperRange }]`;
rsZWJ = '\\u200d'; const rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */ /** Used to compose unicode regexes. */
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', const rsMiscLower = `(?:${ rsLower }|${ rsMisc })`;
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', const rsMiscUpper = `(?:${ rsUpper }|${ rsMisc })`;
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', const rsOptContrLower = `(?:${ rsApos }(?:d|ll|m|re|s|t|ve))?`;
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', const rsOptContrUpper = `(?:${ rsApos }(?:D|LL|M|RE|S|T|VE))?`;
reOptMod = rsModifier + '?', const reOptMod = `${ rsModifier }?`;
rsOptVar = '[' + rsVarRange + ']?', const rsOptVar = `[${ rsVarRange }]?`;
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`;
rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', const rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)';
rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', const rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)';
rsSeq = rsOptVar + reOptMod + rsOptJoin, const rsSeq = rsOptVar + reOptMod + rsOptJoin;
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq; const rsEmoji = `(?:${ [rsDingbat, rsRegional, rsSurrPair].join('|') })${ rsSeq }`;
/** Used to match complex or compound words. */ /** Used to match complex or compound words. */
var reUnicodeWord = RegExp([ const reUnicodeWord = RegExp([
rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', `${ rsUpper }?${ rsLower }+${ rsOptContrLower }(?=${ [rsBreak, rsUpper, '$'].join('|') })`,
rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', `${ rsMiscUpper }+${ rsOptContrUpper }(?=${ [rsBreak, rsUpper + rsMiscLower, '$'].join('|') })`,
rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, `${ rsUpper }?${ rsMiscLower}+${ rsOptContrLower }`,
rsUpper + '+' + rsOptContrUpper, `${ rsUpper }+${ rsOptContrUpper }`,
rsOrdUpper, rsOrdUpper,
rsOrdLower, rsOrdLower,
rsDigits, rsDigits,

View File

@@ -35,7 +35,7 @@ var wrapFlags = [
*/ */
function updateWrapDetails(details, bitmask) { function updateWrapDetails(details, bitmask) {
arrayEach(wrapFlags, pair => { arrayEach(wrapFlags, pair => {
var value = '_.' + pair[0]; var value = `_.${ pair[0] }`;
if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
details.push(value); details.push(value);
} }

View File

@@ -2,22 +2,22 @@ import deburrLetter from './_deburrLetter.js';
import toString from './toString.js'; import toString from './toString.js';
/** Used to match Latin Unicode letters (excluding mathematical operators). */ /** 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. */ /** Used to compose unicode character classes. */
var rsComboMarksRange = '\\u0300-\\u036f', const rsComboMarksRange = '\\u0300-\\u036f';
reComboHalfMarksRange = '\\ufe20-\\ufe2f', const reComboHalfMarksRange = '\\ufe20-\\ufe2f';
rsComboSymbolsRange = '\\u20d0-\\u20ff', const rsComboSymbolsRange = '\\u20d0-\\u20ff';
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
/** Used to compose unicode capture groups. */ /** 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 * 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). * [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 * Deburrs `string` by converting

View File

@@ -162,7 +162,7 @@ function template(string, options, guard) {
, 'g'); , 'g');
// Use a sourceURL for easier debugging. // 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, ( string.replace(reDelimiters, (
match, match,
@@ -180,14 +180,14 @@ function template(string, options, guard) {
// Replace delimiters with snippets. // Replace delimiters with snippets.
if (escapeValue) { if (escapeValue) {
isEscaping = true; isEscaping = true;
source += "' +\n__e(" + escapeValue + ") +\n'"; source += `' +\n__e(${ escapeValue }) +\n'`;
} }
if (evaluateValue) { if (evaluateValue) {
isEvaluating = true; isEvaluating = true;
source += "';\n" + evaluateValue + ";\n__p += '"; source += `';\n${ evaluateValue };\n__p += '`;
} }
if (interpolateValue) { if (interpolateValue) {
source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; source += `' +\n((__t = (${ interpolateValue })) == null ? '' : __t) +\n'`;
} }
index = offset + match.length; 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. // code to add the data object to the top of the scope chain.
var variable = options.variable; var variable = options.variable;
if (!variable) { if (!variable) {
source = 'with (obj) {\n' + source + '\n}\n'; source = `with (obj) {\n${ source }\n}\n`;
} }
// Cleanup code by stripping empty strings. // Cleanup code by stripping empty strings.
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
@@ -210,7 +210,7 @@ function template(string, options, guard) {
.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'
@@ -228,8 +228,7 @@ function template(string, options, guard) {
source + source +
'return __p\n}'; 'return __p\n}';
var result = attempt(() => Function(importsKeys, sourceURL + 'return ' + source) var result = attempt(() => Function(importsKeys, `${ sourceURL }return ${ source }`))(...importsValues);
.apply(undefined, importsValues));
// Provide the compiled function's source by its `toString` method or // Provide the compiled function's source by its `toString` method or
// the `source` property as a convenience for inlining compiled templates. // the `source` property as a convenience for inlining compiled templates.

View File

@@ -51,7 +51,7 @@ function toNumber(value) {
} }
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;

View File

@@ -91,7 +91,7 @@ function truncate(string, options) {
substring = result; substring = result;
if (!separator.global) { if (!separator.global) {
separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); separator = RegExp(separator.source, `${ toString(reFlags.exec(separator)) }g`);
} }
separator.lastIndex = 0; separator.lastIndex = 0;
while ((match = separator.exec(substring))) { while ((match = separator.exec(substring))) {