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