Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 9, 2022
1 parent 2e00a28 commit d1ac1c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
25 changes: 9 additions & 16 deletions src/config/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ export const normalizeConfig = function (config) {
}

const normalizeProp = function (config, [propName, normalizer]) {
const { [propName]: value, ...configA } = config
const props = normalizer(value, propName, configA)

if (props === undefined) {
return config
}

return { ...configA, ...props }
const value = normalizer(config[propName], propName, config)
return value === undefined ? config : { ...config, [propName]: value }
}

const normalizeSystem = function (system) {
Expand All @@ -36,7 +30,7 @@ const normalizeRunner = function (value, propName) {
const valueA = normalizeOptionalArray(value)
checkDefinedStringArray(valueA, propName)
checkArrayLength(valueA, propName)
return { [propName]: valueA }
return valueA
}

const normalizeTasks = function (value, propName) {
Expand All @@ -46,32 +40,31 @@ const normalizeTasks = function (value, propName) {

const valueA = normalizeOptionalArray(value)
checkDefinedStringArray(valueA, propName)
return { [propName]: valueA }
return valueA
}

const normalizeReporter = function (value, propName, { force }) {
if (force) {
return { [propName]: [] }
return []
}

const valueA = normalizeOptionalArray(value)
checkDefinedStringArray(valueA, propName)
return { [propName]: valueA }
return valueA
}

const normalizeSelect = function (value, propName) {
const valueA = normalizeOptionalArray(value)
checkStringArray(valueA, propName)
return { [propName]: valueA }
return valueA
}

const normalizeLimit = function (value, propName) {
const normalizeLimit = function (value) {
if (value === undefined) {
return
}

const valueA = parseLimit(value)
return { [propName]: valueA }
return parseLimit(value)
}

const checkTitles = function (value, propName) {
Expand Down
2 changes: 1 addition & 1 deletion src/run/precision.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const normalizePrecision = function (precision, propName) {
)
}

return { [propName]: precisionA }
return precisionA
}

// Associates `precision` (using array index) to the minimum `rmoe` each
Expand Down

0 comments on commit d1ac1c9

Please sign in to comment.