mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Complete identity removal module. (#2993)
This commit is contained in:
committed by
John-David Dalton
parent
39931f9eaa
commit
d460c42230
@@ -2,7 +2,6 @@ import arrayMap from './arrayMap.js'
|
|||||||
import baseMap from './baseMap.js'
|
import baseMap from './baseMap.js'
|
||||||
import baseSortBy from './baseSortBy.js'
|
import baseSortBy from './baseSortBy.js'
|
||||||
import compareMultiple from './compareMultiple.js'
|
import compareMultiple from './compareMultiple.js'
|
||||||
import identity from '../identity.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `orderBy` without param guards.
|
* The base implementation of `orderBy` without param guards.
|
||||||
@@ -15,7 +14,7 @@ import identity from '../identity.js'
|
|||||||
*/
|
*/
|
||||||
function baseOrderBy(collection, iteratees, orders) {
|
function baseOrderBy(collection, iteratees, orders) {
|
||||||
let index = -1
|
let index = -1
|
||||||
iteratees = iteratees.length ? iteratees : [identity]
|
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))
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
import constant from '../constant.js'
|
|
||||||
import identity from '../identity.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `setToString` without support for hot loop shorting.
|
* The base implementation of `setToString` without support for hot loop shorting.
|
||||||
*
|
*
|
||||||
@@ -13,7 +10,7 @@ function baseSetToString(func, string){
|
|||||||
return Object.defineProperty(func, 'toString', {
|
return Object.defineProperty(func, 'toString', {
|
||||||
'configurable': true,
|
'configurable': true,
|
||||||
'enumerable': false,
|
'enumerable': false,
|
||||||
'value': constant(string),
|
'value': () => string,
|
||||||
'writable': true
|
'writable': true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import baseSortedIndexBy from './baseSortedIndexBy.js'
|
import baseSortedIndexBy from './baseSortedIndexBy.js'
|
||||||
import identity from '../identity.js'
|
|
||||||
import isSymbol from '../isSymbol.js'
|
import isSymbol from '../isSymbol.js'
|
||||||
|
|
||||||
/** Used as references for the maximum length and index of an array. */
|
/** Used as references for the maximum length and index of an array. */
|
||||||
@@ -35,7 +34,7 @@ function baseSortedIndex(array, value, retHighest) {
|
|||||||
}
|
}
|
||||||
return high
|
return high
|
||||||
}
|
}
|
||||||
return baseSortedIndexBy(array, value, identity, retHighest)
|
return baseSortedIndexBy(array, value, value => value, retHighest)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseSortedIndex
|
export default baseSortedIndex
|
||||||
|
|||||||
3
mean.js
3
mean.js
@@ -1,5 +1,4 @@
|
|||||||
import baseMean from './meanBy.js'
|
import baseMean from './meanBy.js'
|
||||||
import identity from './identity.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the mean of the values in `array`.
|
* Computes the mean of the values in `array`.
|
||||||
@@ -14,7 +13,7 @@ import identity from './identity.js'
|
|||||||
* // => 5
|
* // => 5
|
||||||
*/
|
*/
|
||||||
function mean(array) {
|
function mean(array) {
|
||||||
return baseMean(array, identity)
|
return baseMean(array, value => value)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default mean
|
export default mean
|
||||||
|
|||||||
3
sum.js
3
sum.js
@@ -1,5 +1,4 @@
|
|||||||
import baseSum from './.internal/baseSum.js'
|
import baseSum from './.internal/baseSum.js'
|
||||||
import identity from './identity.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the sum of the values in `array`.
|
* Computes the sum of the values in `array`.
|
||||||
@@ -15,7 +14,7 @@ import identity from './identity.js'
|
|||||||
*/
|
*/
|
||||||
function sum(array) {
|
function sum(array) {
|
||||||
return (array && array.length)
|
return (array && array.length)
|
||||||
? baseSum(array, identity)
|
? baseSum(array, value => value)
|
||||||
: 0
|
: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user