mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Fix baseOrderBy missing dependency (#4105)
This commit is contained in:
committed by
John-David Dalton
parent
2130eacf41
commit
7f2ee90c9f
@@ -1,4 +1,4 @@
|
|||||||
import baseMap from './baseMap.js'
|
import baseEach from './baseEach.js'
|
||||||
import baseSortBy from './baseSortBy.js'
|
import baseSortBy from './baseSortBy.js'
|
||||||
import compareMultiple from './compareMultiple.js'
|
import compareMultiple from './compareMultiple.js'
|
||||||
|
|
||||||
@@ -12,12 +12,15 @@ import compareMultiple from './compareMultiple.js'
|
|||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
*/
|
*/
|
||||||
function baseOrderBy(collection, iteratees, orders) {
|
function baseOrderBy(collection, iteratees, orders) {
|
||||||
let index = -1
|
let criteriaIndex = -1
|
||||||
|
let eachIndex = -1
|
||||||
iteratees = iteratees.length ? iteratees : [(value) => value]
|
iteratees = iteratees.length ? iteratees : [(value) => value]
|
||||||
|
|
||||||
const result = baseMap(collection, (value, key, collection) => {
|
const result = isArrayLike(collection) ? new Array(collection.length) : []
|
||||||
|
|
||||||
|
baseEach(collection, (value) => {
|
||||||
const criteria = iteratees.map((iteratee) => iteratee(value))
|
const criteria = iteratees.map((iteratee) => iteratee(value))
|
||||||
return { 'criteria': criteria, 'index': ++index, 'value': value }
|
result[++eachIndex] = { 'criteria': criteria, 'index': ++criteriaIndex, 'value': value }
|
||||||
})
|
})
|
||||||
|
|
||||||
return baseSortBy(result, (object, other) => compareMultiple(object, other, orders))
|
return baseSortBy(result, (object, other) => compareMultiple(object, other, orders))
|
||||||
|
|||||||
Reference in New Issue
Block a user