Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 6, 2022
1 parent c353683 commit c4fa306
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/config/normalize/lib/star_dot_path_utils/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const map = function (target, queryOrPath, mapFunc) {
return entries.reduceRight(mapEntry.bind(undefined, mapFunc), target)
}

const mapEntry = function (mapFunc, target, { path, query }) {
const mapEntry = function (mapFunc, target, { path, query, missing }) {
const value = get(target, path)
const mappedValue = mapFunc({ path, query, value })
const mappedValue = mapFunc({ path, query, value, missing })
return set(target, path, mappedValue)
}

Expand All @@ -20,7 +20,9 @@ export const exclude = function (target, queryOrPath, condition) {
return entries.reduceRight(excludeEntry.bind(undefined, condition), target)
}

const excludeEntry = function (condition, target, { path, query }) {
const excludeEntry = function (condition, target, { path, query, missing }) {
const value = get(target, path)
return condition({ path, query, value }) ? remove(target, path) : target
return condition({ path, query, value, missing })
? remove(target, path)
: target
}

0 comments on commit c4fa306

Please sign in to comment.