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 cc5e143 commit dc3d7bc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/config/normalize/lib/wild_wild_path/iterate.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,15 @@ export const handleMissingValue = function (value, token) {

const iterateChildren = function (levelEntries, childFirst, index) {
const nextIndex = index + 1
return levelEntries.length === 1
? iterateLevel(levelEntries, childFirst, nextIndex)
: Object.values(groupBy(levelEntries, getLastProp)).flatMap(
(groupedLevelEntries) =>
iterateLevel(groupedLevelEntries, childFirst, nextIndex),
)

if (levelEntries.length === 1) {
return iterateLevel(levelEntries, childFirst, nextIndex)
}

const levelEntriesGroups = Object.values(groupBy(levelEntries, getLastProp))
return levelEntriesGroups.flatMap((levelEntriesA) =>
iterateLevel(levelEntriesA, childFirst, nextIndex),
)
}

const getLastProp = function ({ props }) {
Expand Down

0 comments on commit dc3d7bc

Please sign in to comment.