Skip to content

Commit

Permalink
Move code
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 13, 2022
1 parent 1456c26 commit 7f2ea52
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/config/normalize/lib/wild_wild_path/iterate.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ const normalizeEntry = function ({ value, simplePath: path, missing }) {
return { value, path, query, missing }
}

// eslint-disable-next-line max-params
const iterateChildEntries = function* (
entries,
parentEntries,
childFirst,
index,
) {
if (parentEntries.length === entries.length) {
return
}

const levelEntries = entries
.filter(({ path }) => path.length !== index)
.flatMap((entry) => iteratePath(entry, index))

if (levelEntries.length === 0) {
return
}

yield* iterateChildren(levelEntries, childFirst, index)
}

// Iteration among siglings is not sorted, for performance reasons.
// - Consumers can sort it through using the `query` property
// However, iteration is guaranteed to return child entries before parent ones.
Expand Down Expand Up @@ -110,28 +132,6 @@ export const handleMissingValue = function (value, token) {
return { tokenType, missing, value: valueA }
}

// eslint-disable-next-line max-params
const iterateChildEntries = function* (
entries,
parentEntries,
childFirst,
index,
) {
if (parentEntries.length === entries.length) {
return
}

const levelEntries = entries
.filter(({ path }) => path.length !== index)
.flatMap((entry) => iteratePath(entry, index))

if (levelEntries.length === 0) {
return
}

yield* iterateChildren(levelEntries, childFirst, index)
}

const iterateChildren = function* (levelEntries, childFirst, index) {
const nextIndex = index + 1

Expand Down

0 comments on commit 7f2ea52

Please sign in to comment.