mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Use more Array#map.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
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'
|
||||||
@@ -17,7 +16,7 @@ function baseOrderBy(collection, iteratees, orders) {
|
|||||||
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 = iteratees.map((iteratee) => iteratee(value))
|
||||||
return { 'criteria': criteria, 'index': ++index, 'value': value }
|
return { 'criteria': criteria, 'index': ++index, 'value': value }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import arrayMap from './arrayMap.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. */
|
||||||
@@ -23,7 +22,7 @@ function baseToString(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, baseToString) }`
|
return `${ value.map(baseToString) }`
|
||||||
}
|
}
|
||||||
if (isSymbol(value)) {
|
if (isSymbol(value)) {
|
||||||
return symbolToString ? symbolToString.call(value) : ''
|
return symbolToString ? symbolToString.call(value) : ''
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import arrayMap from './arrayMap.js'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `values` and `valuesIn` which creates an
|
* The base implementation of `values` and `valuesIn` which creates an
|
||||||
* array of `object` property values corresponding to the property names
|
* array of `object` property values corresponding to the property names
|
||||||
@@ -11,7 +9,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 props == null ? [] : props.map((key) => object[key])
|
||||||
}
|
}
|
||||||
|
|
||||||
export default baseValues
|
export default baseValues
|
||||||
|
|||||||
Reference in New Issue
Block a user