Skip to content

Commit

Permalink
Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 13, 2022
1 parent fc33a55 commit 707a8f1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/config/normalize/lib/wild_wild_path/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ const setEntry = function (value, target, path, index) {
return value
}

const key = path[index]
const { value: defaultedTarget } = handleMissingValue(target, key)
const childTarget = defaultedTarget[key]
const prop = path[index]
const { value: defaultedTarget } = handleMissingValue(target, prop)
const childTarget = defaultedTarget[prop]
const childValue = setEntry(value, childTarget, path, index + 1)
return setValue(defaultedTarget, key, childValue)
return setValue(defaultedTarget, prop, childValue)
}

export const setValue = function (target, key, childValue) {
if (isNoopSet(target, key, childValue)) {
export const setValue = function (target, prop, childValue) {
if (isNoopSet(target, prop, childValue)) {
return target
}

return Array.isArray(target)
? setArray(target, key, childValue)
: { ...target, [key]: childValue }
? setArray(target, prop, childValue)
: { ...target, [prop]: childValue }
}

// Do not set value if it has not changed.
// We distinguish between `undefined` values with the property set and unset.
const isNoopSet = function (target, key, childValue) {
const isNoopSet = function (target, prop, childValue) {
return (
target[key] === childValue && (childValue !== undefined || key in target)
target[prop] === childValue && (childValue !== undefined || prop in target)
)
}

0 comments on commit 707a8f1

Please sign in to comment.