mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Consistent use (always) of parentheses in arrow functions.
This commit is contained in:
@@ -38,9 +38,7 @@ module.exports = {
|
||||
'requireReturnForObjectLiteral': false
|
||||
}],
|
||||
|
||||
'arrow-parens': ['error', 'as-needed', {
|
||||
'requireForBlockBody': true
|
||||
}],
|
||||
'arrow-parens': ['error', 'always'],
|
||||
|
||||
'arrow-spacing': ['error', {
|
||||
'before': true,
|
||||
|
||||
@@ -10,7 +10,7 @@ import keys from '../keys.js'
|
||||
*/
|
||||
function baseConforms(source) {
|
||||
const props = keys(source)
|
||||
return object => baseConformsTo(object, source, props)
|
||||
return (object) => baseConformsTo(object, source, props)
|
||||
}
|
||||
|
||||
export default baseConforms
|
||||
|
||||
@@ -30,7 +30,7 @@ function baseDifference(array, values, iteratee, comparator) {
|
||||
return result
|
||||
}
|
||||
if (iteratee) {
|
||||
values = arrayMap(values, value => iteratee(value))
|
||||
values = arrayMap(values, (value) => iteratee(value))
|
||||
}
|
||||
if (comparator) {
|
||||
includes = arrayIncludesWith
|
||||
|
||||
@@ -31,7 +31,7 @@ function baseIntersection(arrays, iteratee, comparator) {
|
||||
while (othIndex--) {
|
||||
array = arrays[othIndex]
|
||||
if (othIndex && iteratee) {
|
||||
array = arrayMap(array, value => iteratee(value))
|
||||
array = arrayMap(array, (value) => iteratee(value))
|
||||
}
|
||||
maxLength = nativeMin(array.length, maxLength)
|
||||
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
|
||||
|
||||
@@ -14,7 +14,7 @@ function baseMatches(source) {
|
||||
if (matchData.length == 1 && matchData[0][2]) {
|
||||
return matchesStrictComparable(matchData[0][0], matchData[0][1])
|
||||
}
|
||||
return object => object === source || baseIsMatch(object, source, matchData)
|
||||
return (object) => object === source || baseIsMatch(object, source, matchData)
|
||||
}
|
||||
|
||||
export default baseMatches
|
||||
|
||||
@@ -14,10 +14,10 @@ import compareMultiple from './compareMultiple.js'
|
||||
*/
|
||||
function baseOrderBy(collection, iteratees, orders) {
|
||||
let index = -1
|
||||
iteratees = iteratees.length ? iteratees : [value => value]
|
||||
iteratees = iteratees.length ? iteratees : [(value) => value]
|
||||
|
||||
const result = baseMap(collection, (value, key, collection) => {
|
||||
const criteria = arrayMap(iteratees, iteratee => iteratee(value))
|
||||
const criteria = arrayMap(iteratees, (iteratee) => iteratee(value))
|
||||
return { 'criteria': criteria, 'index': ++index, 'value': value }
|
||||
})
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @returns {Function} Returns the new accessor function.
|
||||
*/
|
||||
function baseProperty(key) {
|
||||
return object => object == null ? undefined : object[key]
|
||||
return (object) => object == null ? undefined : object[key]
|
||||
}
|
||||
|
||||
export default baseProperty
|
||||
|
||||
@@ -8,7 +8,7 @@ import baseGet from './baseGet.js'
|
||||
* @returns {Function} Returns the new accessor function.
|
||||
*/
|
||||
function basePropertyDeep(path) {
|
||||
return object => baseGet(object, path)
|
||||
return (object) => baseGet(object, path)
|
||||
}
|
||||
|
||||
export default basePropertyDeep
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @returns {Function} Returns the new accessor function.
|
||||
*/
|
||||
function basePropertyOf(object) {
|
||||
return key => object == null ? undefined : object[key]
|
||||
return (key) => object == null ? undefined : object[key]
|
||||
}
|
||||
|
||||
export default basePropertyOf
|
||||
|
||||
@@ -27,7 +27,7 @@ function basePullAll(array, values, iteratee, comparator) {
|
||||
values = copyArray(values)
|
||||
}
|
||||
if (iteratee) {
|
||||
seen = arrayMap(array, value => iteratee(value))
|
||||
seen = arrayMap(array, (value) => iteratee(value))
|
||||
}
|
||||
while (++index < length) {
|
||||
let fromIndex = 0
|
||||
|
||||
@@ -34,7 +34,7 @@ function baseSortedIndex(array, value, retHighest) {
|
||||
}
|
||||
return high
|
||||
}
|
||||
return baseSortedIndexBy(array, value, value => value, retHighest)
|
||||
return baseSortedIndexBy(array, value, (value) => value, retHighest)
|
||||
}
|
||||
|
||||
export default baseSortedIndex
|
||||
|
||||
@@ -11,7 +11,7 @@ import arrayMap from './arrayMap.js'
|
||||
* @returns {Object} Returns the array of property values.
|
||||
*/
|
||||
function baseValues(object, props) {
|
||||
return arrayMap(props, key => object[key])
|
||||
return arrayMap(props, (key) => object[key])
|
||||
}
|
||||
|
||||
export default baseValues
|
||||
|
||||
@@ -13,7 +13,7 @@ const reApos = /['\u2019]/g
|
||||
* @returns {Function} Returns the new compounder function.
|
||||
*/
|
||||
function createCompounder(callback) {
|
||||
return string => (
|
||||
return (string) => (
|
||||
arrayReduce(words(toString(string).replace(reApos, '')), callback, '')
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const INFINITY = 1 / 0
|
||||
* @returns {Object} Returns the new set.
|
||||
*/
|
||||
const createSet = (Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY)
|
||||
? values => new Set(values)
|
||||
? (values) => new Set(values)
|
||||
: () => {}
|
||||
|
||||
export default createSet
|
||||
|
||||
@@ -18,7 +18,7 @@ const getSymbols = !nativeGetSymbols ? () => [] : (object) => {
|
||||
return []
|
||||
}
|
||||
object = Object(object)
|
||||
return arrayFilter(nativeGetSymbols(object), symbol => propertyIsEnumerable.call(object, symbol))
|
||||
return arrayFilter(nativeGetSymbols(object), (symbol) => propertyIsEnumerable.call(object, symbol))
|
||||
}
|
||||
|
||||
export default getSymbols
|
||||
|
||||
@@ -9,7 +9,7 @@ function setToPairs(set) {
|
||||
let index = -1
|
||||
const result = Array(set.size)
|
||||
|
||||
set.forEach(value =>
|
||||
set.forEach((value) =>
|
||||
result[++index] = [value, value]
|
||||
)
|
||||
return result
|
||||
|
||||
@@ -43,7 +43,7 @@ const reHasUnescapedHtml = RegExp(reUnescapedHtml.source)
|
||||
function escape(string) {
|
||||
string = toString(string)
|
||||
return (string && reHasUnescapedHtml.test(string))
|
||||
? string.replace(reUnescapedHtml, chr => htmlEscapes[chr])
|
||||
? string.replace(reUnescapedHtml, (chr) => htmlEscapes[chr])
|
||||
: string
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
*/
|
||||
function forOwn(object, iteratee) {
|
||||
if (object != null) {
|
||||
Object.keys(Object(object)).forEach(key => iteratee(object[key], key, object))
|
||||
Object.keys(Object(object)).forEach((key) => iteratee(object[key], key, object))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ function functions(object) {
|
||||
if (object == null) {
|
||||
return []
|
||||
}
|
||||
return Object.keys(object).filter(key => typeof object[key] == 'function')
|
||||
return Object.keys(object).filter((key) => typeof object[key] == 'function')
|
||||
}
|
||||
|
||||
export default functions
|
||||
|
||||
@@ -21,7 +21,7 @@ const nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer
|
||||
* // => false
|
||||
*/
|
||||
const isArrayBuffer = nodeIsArrayBuffer
|
||||
? value => nodeIsArrayBuffer(value)
|
||||
: value => isObjectLike(value) && baseGetTag(value) == '[object ArrayBuffer]'
|
||||
? (value) => nodeIsArrayBuffer(value)
|
||||
: (value) => isObjectLike(value) && baseGetTag(value) == '[object ArrayBuffer]'
|
||||
|
||||
export default isArrayBuffer
|
||||
|
||||
@@ -21,7 +21,7 @@ const nodeIsDate = nodeUtil && nodeUtil.isDate
|
||||
* // => false
|
||||
*/
|
||||
const isDate = nodeIsDate
|
||||
? value => nodeIsDate(value)
|
||||
: value => isObjectLike(value) && baseGetTag(value) == '[object Date]'
|
||||
? (value) => nodeIsDate(value)
|
||||
: (value) => isObjectLike(value) && baseGetTag(value) == '[object Date]'
|
||||
|
||||
export default isDate
|
||||
|
||||
4
isMap.js
4
isMap.js
@@ -21,7 +21,7 @@ const nodeIsMap = nodeUtil && nodeUtil.isMap
|
||||
* // => false
|
||||
*/
|
||||
const isMap = nodeIsMap
|
||||
? value => nodeIsMap(value)
|
||||
: value => isObjectLike(value) && getTag(value) == '[object Map]'
|
||||
? (value) => nodeIsMap(value)
|
||||
: (value) => isObjectLike(value) && getTag(value) == '[object Map]'
|
||||
|
||||
export default isMap
|
||||
|
||||
@@ -21,7 +21,7 @@ const nodeIsRegExp = nodeUtil && nodeUtil.isRegExp
|
||||
* // => false
|
||||
*/
|
||||
const isRegExp = nodeIsRegExp
|
||||
? value => nodeIsRegExp(value)
|
||||
: value => isObjectLike(value) && baseGetTag(value) == '[object RegExp]'
|
||||
? (value) => nodeIsRegExp(value)
|
||||
: (value) => isObjectLike(value) && baseGetTag(value) == '[object RegExp]'
|
||||
|
||||
export default isRegExp
|
||||
|
||||
4
isSet.js
4
isSet.js
@@ -20,7 +20,7 @@ const nodeIsSet = nodeUtil && nodeUtil.isSet
|
||||
* // => false
|
||||
*/
|
||||
const isSet = nodeIsSet
|
||||
? value => nodeIsSet(value)
|
||||
: value => typeof value == 'object' && value != null && getTag(value) == '[object Set]'
|
||||
? (value) => nodeIsSet(value)
|
||||
: (value) => typeof value == 'object' && value != null && getTag(value) == '[object Set]'
|
||||
|
||||
export default isSet
|
||||
|
||||
@@ -23,7 +23,7 @@ const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray
|
||||
* // => false
|
||||
*/
|
||||
const isTypedArray = nodeIsTypedArray
|
||||
? value => nodeIsTypedArray(value)
|
||||
: value => typeof value == 'object' && value != null && reTypedTag.test(getTag(value))
|
||||
? (value) => nodeIsTypedArray(value)
|
||||
: (value) => typeof value == 'object' && value != null && reTypedTag.test(getTag(value))
|
||||
|
||||
export default isTypedArray
|
||||
|
||||
2
mean.js
2
mean.js
@@ -13,7 +13,7 @@ import baseMean from './meanBy.js'
|
||||
* // => 5
|
||||
*/
|
||||
function mean(array) {
|
||||
return baseMean(array, value => value)
|
||||
return baseMean(array, (value) => value)
|
||||
}
|
||||
|
||||
export default mean
|
||||
|
||||
@@ -23,7 +23,7 @@ import invoke from './invoke.js'
|
||||
* // => [2, 1]
|
||||
*/
|
||||
function method(path, args) {
|
||||
return object => invoke(object, path, args)
|
||||
return (object) => invoke(object, path, args)
|
||||
}
|
||||
|
||||
export default method
|
||||
|
||||
@@ -22,7 +22,7 @@ import invoke from './invoke.js'
|
||||
* // => [2, 0]
|
||||
*/
|
||||
function methodOf(object, args) {
|
||||
return path => invoke(object, path, args)
|
||||
return (path) => invoke(object, path, args)
|
||||
}
|
||||
|
||||
export default methodOf
|
||||
|
||||
2
over.js
2
over.js
@@ -18,7 +18,7 @@ import arrayMap from './.internal/arrayMap.js'
|
||||
*/
|
||||
function over(iteratees) {
|
||||
return function(...args) {
|
||||
return arrayMap(iteratees, iteratee => iteratee.apply(this, args))
|
||||
return arrayMap(iteratees, (iteratee) => iteratee.apply(this, args))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import arrayEvery from './.internal/arrayEvery.js'
|
||||
*/
|
||||
function overEvery(iteratees) {
|
||||
return function(...args) {
|
||||
return arrayEvery(iteratees, iteratee => iteratee.apply(this, args))
|
||||
return arrayEvery(iteratees, (iteratee) => iteratee.apply(this, args))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import arraySome from './.internal/arraySome.js'
|
||||
*/
|
||||
function overSome(iteratees) {
|
||||
return function(...args) {
|
||||
return arraySome(iteratees, iteratee => iteratee.apply(this, args))
|
||||
return arraySome(iteratees, (iteratee) => iteratee.apply(this, args))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ function pickBy(object, predicate) {
|
||||
if (object == null) {
|
||||
return {}
|
||||
}
|
||||
const props = arrayMap(getAllKeysIn(object), prop => [prop])
|
||||
const props = arrayMap(getAllKeysIn(object), (prop) => [prop])
|
||||
return basePickBy(object, props, (value, path) => predicate(value, path[0]))
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import baseGet from './.internal/baseGet.js'
|
||||
* // => [2, 0]
|
||||
*/
|
||||
function propertyOf(object) {
|
||||
return path => object == null ? undefined : baseGet(object, path)
|
||||
return (path) => object == null ? undefined : baseGet(object, path)
|
||||
}
|
||||
|
||||
export default propertyOf
|
||||
|
||||
@@ -31,7 +31,7 @@ function pullAt(array, ...indexes) {
|
||||
const length = array == null ? 0 : array.length
|
||||
const result = baseAt(array, indexes)
|
||||
|
||||
basePullAt(array, arrayMap(indexes, index => isIndex(index, length) ? +index : index).sort(compareAscending))
|
||||
basePullAt(array, arrayMap(indexes, (index) => isIndex(index, length) ? +index : index).sort(compareAscending))
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
2
sum.js
2
sum.js
@@ -14,7 +14,7 @@ import baseSum from './.internal/baseSum.js'
|
||||
*/
|
||||
function sum(array) {
|
||||
return (array != null && array.length)
|
||||
? baseSum(array, value => value)
|
||||
? baseSum(array, (value) => value)
|
||||
: 0
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ 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) {
|
||||
|
||||
@@ -37,7 +37,7 @@ 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) : ''
|
||||
|
||||
@@ -34,7 +34,7 @@ const reHasEscapedHtml = RegExp(reEscapedHtml.source)
|
||||
function unescape(string) {
|
||||
string = toString(string)
|
||||
return (string && reHasEscapedHtml.test(string))
|
||||
? string.replace(reEscapedHtml, entity => htmlUnescapes[entity])
|
||||
? string.replace(reEscapedHtml, (entity) => htmlUnescapes[entity])
|
||||
: string
|
||||
}
|
||||
|
||||
|
||||
2
unzip.js
2
unzip.js
@@ -36,7 +36,7 @@ function unzip(array) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
return baseTimes(length, index => arrayMap(array, baseProperty(index)))
|
||||
return baseTimes(length, (index) => arrayMap(array, baseProperty(index)))
|
||||
}
|
||||
|
||||
export default unzip
|
||||
|
||||
@@ -25,7 +25,7 @@ function unzipWith(array, iteratee) {
|
||||
return []
|
||||
}
|
||||
const result = unzip(array)
|
||||
return arrayMap(result, group => iteratee.apply(undefined, group))
|
||||
return arrayMap(result, (group) => iteratee.apply(undefined, group))
|
||||
}
|
||||
|
||||
export default unzipWith
|
||||
|
||||
Reference in New Issue
Block a user