Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 13, 2022
1 parent d9a729f commit 7bfa247
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/config/normalize/lib/wild_wild_path/iterate/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,20 @@ const iterateChildren = function* ({ childEntries, childFirst, sort, index }) {
return
}

const childEntriesGroups = Object.values(groupBy(childEntries, getLastProp))
const childEntriesGroups = groupSortChildEntries(childEntries)

// eslint-disable-next-line fp/no-loops
for (const entries of childEntriesGroups) {
yield* iterateLevel({ entries, childFirst, sort, index: nextIndex })
}
}

// We need to group entries by the last property to ensure `childFirst` order.
// We also sort when `sort` is true`
const groupSortChildEntries = function (childEntries) {
return Object.values(groupBy(childEntries, getLastProp))
}

const getLastProp = function ({ path }) {
return path[path.length - 1]
}

0 comments on commit 7bfa247

Please sign in to comment.