Adjust spacing in template string expressions.

This commit is contained in:
John-David Dalton
2017-04-08 22:41:48 -07:00
parent 303502efa7
commit d10b44bdef
29 changed files with 90 additions and 90 deletions

View File

@@ -24,7 +24,7 @@ function arrayLikeKeys(value, inherited) {
const result = new Array(skipIndexes ? length : 0)
let index = skipIndexes ? -1 : length
while (++index < length) {
result[index] = `${ index }`
result[index] = `${index}`
}
for (const key in value) {
if ((inherited || hasOwnProperty.call(value, key)) &&

View File

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

View File

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

View File

@@ -22,12 +22,12 @@ function baseToString(value) {
}
if (Array.isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return `${ value.map(baseToString) }`
return `${value.map(baseToString)}`
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : ''
}
const result = `${ value }`
const result = `${value}`
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result
}

View File

@@ -12,11 +12,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.
let pair = `${ number }e`.split('e')
const value = func(`${ pair[0] }e${ +pair[1] + precision }`)
let pair = `${number}e`.split('e')
const value = func(`${pair[0]}e${ +pair[1] + precision }`)
pair = `${ value }e`.split('e')
return +`${ pair[0] }e${ +pair[1] - precision }`
pair = `${value}e`.split('e')
return +`${pair[0]}e${+pair[1] - precision}`
}
return func(number)
}

View File

@@ -74,7 +74,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:
let convert = mapToArray

View File

@@ -9,11 +9,11 @@ const setTag = '[object Set]'
const weakMapTag = '[object WeakMap]'
/** Used to detect maps, sets, and weakmaps. */
const dataViewCtorString = `${ DataView }`
const mapCtorString = `${ Map }`
const promiseCtorString = `${ Promise }`
const setCtorString = `${ Set }`
const weakMapCtorString = `${ WeakMap }`
const dataViewCtorString = `${DataView}`
const mapCtorString = `${Map}`
const promiseCtorString = `${Promise}`
const setCtorString = `${Set}`
const weakMapCtorString = `${WeakMap}`
/**
* Gets the `toStringTag` of `value`.
@@ -33,7 +33,7 @@ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
getTag = (value) => {
const result = baseGetTag(value)
const Ctor = result == objectTag ? value.constructor : undefined
const ctorString = Ctor ? `${ Ctor }` : ''
const ctorString = Ctor ? `${Ctor}` : ''
if (ctorString) {
switch (ctorString) {

View File

@@ -10,7 +10,7 @@ const rsVarRange = '\\ufe0e\\ufe0f'
const 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/). */
const reHasUnicode = RegExp(`[${ rsZWJ + rsAstralRange + rsComboRange + rsVarRange }]`)
const reHasUnicode = RegExp(`[${rsZWJ + rsAstralRange + rsComboRange + rsVarRange}]`)
/**
* Checks if `string` contains Unicode symbols.

View File

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

View File

@@ -7,25 +7,25 @@ const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsR
const rsVarRange = '\\ufe0e\\ufe0f'
/** Used to compose unicode capture groups. */
const rsAstral = `[${ rsAstralRange }]`
const rsCombo = `[${ rsComboRange }]`
const rsAstral = `[${rsAstralRange}]`
const rsCombo = `[${rsComboRange}]`
const rsFitz = '\\ud83c[\\udffb-\\udfff]'
const rsModifier = `(?:${ rsCombo }|${ rsFitz })`
const rsNonAstral = `[^${ rsAstralRange }]`
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. */
const reOptMod = `${ rsModifier }?`
const rsOptVar = `[${ rsVarRange }]?`
const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`
const reOptMod = `${rsModifier}?`
const rsOptVar = `[${rsVarRange}]?`
const rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join('|')})${rsOptVar + reOptMod})*`
const rsSeq = rsOptVar + reOptMod + rsOptJoin
const rsNonAstralCombo = `${ rsNonAstral }${ rsCombo }?`
const rsSymbol = `(?:${ [rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') })`
const rsNonAstralCombo = `${rsNonAstral}${rsCombo}?`
const rsSymbol = `(?:${[rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|')})`
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
const reUnicode = RegExp(`${ rsFitz }(?=${ rsFitz })|${ rsSymbol + rsSeq }`, 'g')
const reUnicode = RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol + rsSeq}`, 'g')
/**
* Gets the size of a Unicode `string`.

View File

@@ -7,25 +7,25 @@ const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsR
const rsVarRange = '\\ufe0e\\ufe0f'
/** Used to compose unicode capture groups. */
const rsAstral = `[${ rsAstralRange }]`
const rsCombo = `[${ rsComboRange }]`
const rsAstral = `[${rsAstralRange}]`
const rsCombo = `[${rsComboRange}]`
const rsFitz = '\\ud83c[\\udffb-\\udfff]'
const rsModifier = `(?:${ rsCombo }|${ rsFitz })`
const rsNonAstral = `[^${ rsAstralRange }]`
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. */
const reOptMod = `${ rsModifier }?`
const rsOptVar = `[${ rsVarRange }]?`
const rsOptJoin = `(?:${ rsZWJ }(?:${ [rsNonAstral, rsRegional, rsSurrPair].join('|') })${ rsOptVar + reOptMod })*`
const reOptMod = `${rsModifier}?`
const rsOptVar = `[${rsVarRange}]?`
const rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join('|')})${rsOptVar + reOptMod})*`
const rsSeq = rsOptVar + reOptMod + rsOptJoin
const rsNonAstralCombo = `${ rsNonAstral }${ rsCombo }?`
const rsSymbol = `(?:${ [rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') })`
const rsNonAstralCombo = `${rsNonAstral}${rsCombo}?`
const rsSymbol = `(?:${[rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|')})`
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
const reUnicode = RegExp(`${ rsFitz }(?=${ rsFitz })|${ rsSymbol + rsSeq }`, 'g')
const reUnicode = RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol + rsSeq}`, 'g')
/**
* Converts a Unicode `string` to an array.

View File

@@ -16,32 +16,32 @@ const rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpa
/** Used to compose unicode capture groups. */
const rsApos = "['\u2019]"
const rsBreak = `[${ rsBreakRange }]`
const rsCombo = `[${ rsComboRange }]`
const rsBreak = `[${rsBreakRange}]`
const rsCombo = `[${rsComboRange}]`
const rsDigits = '\\d+'
const rsDingbat = `[${ rsDingbatRange }]`
const rsLower = `[${ rsLowerRange }]`
const rsMisc = `[^${ rsAstralRange }${ rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange }]`
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 rsModifier = `(?:${rsCombo}|${rsFitz})`
const rsNonAstral = `[^${rsAstralRange}]`
const rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'
const rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'
const rsUpper = `[${ rsUpperRange }]`
const rsUpper = `[${rsUpperRange}]`
const rsZWJ = '\\u200d'
/** Used to compose unicode regexes. */
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 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 }`
const rsEmoji = `(?:${[rsDingbat, rsRegional, rsSurrPair].join('|')})${rsSeq}`
/**
* Splits a Unicode `string` into an array of its words.
@@ -51,10 +51,10 @@ const rsEmoji = `(?:${ [rsDingbat, rsRegional, rsSurrPair].join('|') })${ rsSeq
* @returns {Array} Returns the words of `string`.
*/
const unicodeWords = RegExp.prototype.exec.bind(RegExp([
`${ rsUpper }?${ rsLower }+${ rsOptContrLower }(?=${ [rsBreak, rsUpper, '$'].join('|') })`,
`${ rsMiscUpper }+${ rsOptContrUpper }(?=${ [rsBreak, rsUpper + rsMiscLower, '$'].join('|') })`,
`${ rsUpper }?${ rsMiscLower }+${ rsOptContrLower }`,
`${ rsUpper }+${ rsOptContrUpper }`,
`${rsUpper}?${rsLower}+${rsOptContrLower}(?=${[rsBreak, rsUpper, '$'].join('|')})`,
`${rsMiscUpper}+${rsOptContrUpper}(?=${[rsBreak, rsUpper + rsMiscLower, '$'].join('|')})`,
`${rsUpper}?${rsMiscLower}+${rsOptContrLower}`,
`${rsUpper}+${rsOptContrUpper}`,
rsOrdUpper,
rsOrdLower,
rsDigits,

View File

@@ -21,7 +21,7 @@ import words from './words.js'
* // => 'fooBar'
*/
const camelCase = (string) => (
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => {
words(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => {
word = word.toLowerCase()
return result + (index ? capitalize(word) : word)
}, '')

View File

@@ -10,7 +10,7 @@ const rsComboSymbolsRange = '\\u20d0-\\u20ff'
const rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange
/** Used to compose unicode capture groups. */
const rsCombo = `[${ rsComboRange }]`
const rsCombo = `[${rsComboRange}]`
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and

View File

@@ -17,7 +17,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
*
* const object = { 'a': 1, 'b': 2, 'c': 1 }
*
* invertBy(object, value => `group${ value }`)
* invertBy(object, value => `group${value}`)
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
*/
function invertBy(object, iteratee) {

View File

@@ -21,7 +21,7 @@ import words from './words.js'
* // => 'foo-bar'
*/
const kebabCase = (string) => (
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
words(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
result + (index ? '-' : '') + word.toLowerCase()
), '')
)

View File

@@ -20,7 +20,7 @@ import words from './words.js'
* // => 'foo bar'
*/
const lowerCase = (string) => (
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
words(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
result + (index ? ' ' : '') + word.toLowerCase()
), '')
)

View File

@@ -33,7 +33,7 @@ function parseInt(string, radix) {
} else if (radix) {
radix = +radix
}
return nativeParseInt(`${ string }`.replace(reTrimStart, ''), radix || 0)
return nativeParseInt(`${string}`.replace(reTrimStart, ''), radix || 0)
}
export default parseInt

View File

@@ -64,8 +64,8 @@ function random(lower, upper, floating) {
}
if (floating || lower % 1 || upper % 1) {
const rand = Math.random()
const randLength = `${ rand }`.length - 1
return Math.min(lower + (rand * (upper - lower + freeParseFloat(`1e-${ randLength }`)), upper))
const randLength = `${rand}`.length - 1
return Math.min(lower + (rand * (upper - lower + freeParseFloat(`1e-${randLength}`)), upper))
}
return lower + Math.floor(Math.random() * (upper - lower + 1))
}

View File

@@ -17,7 +17,7 @@
* // => 'Hi Barney'
*/
function replace(...args) {
const string = `${ args[0] }`
const string = `${args[0]}`
return args.length < 3 ? string : string.replace(args[1], args[2])
}

View File

@@ -21,7 +21,7 @@ import words from './words.js'
* // => 'foo_bar'
*/
const snakeCase = (string) => (
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
words(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
result + (index ? '_' : '') + word.toLowerCase()
), '')
)

View File

@@ -22,7 +22,7 @@ import words from './words.js'
* // => 'FOO BAR'
*/
const startCase = (string) => (
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
words(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
result + (index ? ' ' : '') + upperFirst(word)
), '')
)

View File

@@ -29,7 +29,7 @@ function startsWith(string, target, position) {
else if (position > length) {
position = length
}
target = `${ target }`
target = `${target}`
return string.slice(position, position + target.length) == target
}

View File

@@ -155,16 +155,16 @@ function template(string, options) {
let source = "__p += '"
// Compile the regexp to match each delimiter.
const reDelimiters = RegExp(`${ [
const reDelimiters = RegExp(`${[
(options.escape || reNoMatch).source,
interpolate.source,
(interpolate === reInterpolate ? reEsTemplate : reNoMatch).source,
(options.evaluate || reNoMatch).source
].join('|') }|$`, 'g')
].join('|')}|$`, 'g')
// Use a sourceURL for easier debugging.
const sourceURL = 'sourceURL' in options
? `//# sourceURL=${ options.sourceURL }\n`
? `//# sourceURL=${options.sourceURL}\n`
: ''
string.replace(reDelimiters, (
@@ -180,19 +180,19 @@ function template(string, options) {
// Escape characters that can't be included in string literals.
source += string
.slice(index, offset)
.replace(reUnescapedString, (chr) => `\\${ stringEscapes[chr] }`)
.replace(reUnescapedString, (chr) => `\\${stringEscapes[chr]}`)
// 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
@@ -207,7 +207,7 @@ function template(string, options) {
// code to add the data object to the top of the scope chain.
const 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)
@@ -215,15 +215,15 @@ function template(string, options) {
.replace(reEmptyStringTrailing, '$1;')
// Frame code as the function body.
source = `function(${ variable || 'obj' }) {\n` +
`${ variable ? '' : 'obj || (obj = {});\n' }` +
source = `function(${variable || 'obj'}) {\n` +
`${variable ? '' : 'obj || (obj = {});\n'}` +
`var __t, __p = ''` +
`${ isEscaping ? ', __e = _.escape' : '' }` +
`${ isEvaluating ? ', __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, \'\') }\n' : ';\n' }` +
`${ source } return __p;\n}`
`${isEscaping ? ', __e = _.escape' : ''}` +
`${isEvaluating ? ', __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, \'\') }\n' : ';\n'}` +
`${source} return __p;\n}`
const result = attempt(() => (
Function(importsKeys, `${ sourceURL }return ${ source }`))(...importsValues)
Function(importsKeys, `${sourceURL}return ${source}`))(...importsValues)
)
// Provide the compiled function's source by its `toString` method or

View File

@@ -50,7 +50,7 @@ function toNumber(value) {
}
if (isObject(value)) {
const 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

View File

@@ -37,12 +37,12 @@ function toString(value) {
}
if (Array.isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return `${ arrayMap(value, (other) => other == null ? other : toString(other)) }`
return `${arrayMap(value, (other) => other == null ? other : toString(other))}`
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : ''
}
const result = `${ value }`
const result = `${value}`
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result
}

View File

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

View File

@@ -19,7 +19,7 @@ let idCounter = 0
*/
function uniqueId(prefix) {
const id = ++idCounter
return `${ prefix + id }`
return `${prefix + id}`
}
export default uniqueId

View File

@@ -20,7 +20,7 @@ import words from './words.js'
* // => 'FOO BAR'
*/
const upperCase = (string) => (
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
words(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
result + (index ? ' ' : '') + word.toUpperCase()
), '')
)