Skip to content

Commit

Permalink
Continue removing concept of nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 6, 2022
1 parent 19ff52b commit fc58300
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/config/normalize/lib/star_dot_path/entries/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import { isRecurseObject } from './recurse.js'
// List all values (and their associated path) matching a specific query for
// on specific target value.
export const listEntries = function (target, path) {
return path.reduce(listNodeEntries, [{ value: target, path: [] }])
return path.reduce(listTokenEntries, [{ value: target, path: [] }])
}

const listNodeEntries = function (entries, node) {
return entries.flatMap((entry) => getNodeEntries(entry, node))
const listTokenEntries = function (entries, token) {
return entries.flatMap((entry) => getTokenEntries(entry, token))
}

const getNodeEntries = function ({ value, path }, node) {
const token = Array.isArray(node) ? node[0] : node
const getTokenEntries = function ({ value, path }, token) {
return token === ANY_TOKEN
? getAnyEntries(value, path)
: getKeyEntries(value, path, token)
Expand Down

0 comments on commit fc58300

Please sign in to comment.