Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 12, 2021
1 parent e317f63 commit 25f74d2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/stats/cold.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getCold = function (
) {
const minIndex = getIndexFromLength(COLD_MIN_PERCENTAGE, length)
const maxIndex = getIndexFromLength(COLD_MAX_PERCENTAGE, length)
const closestMean = getClosestMean(array, {
const { closestMean } = getClosestMean(array, {
mean,
minIndex,
maxIndex,
Expand All @@ -52,15 +52,14 @@ export const getColdLoopsLeft = function (
const incrementalMeanMax = mean * (1 + precisionTarget)
const minIndex = getIndexFromLength(COLD_MAX_PERCENTAGE, length)
const maxIndex = length - 1
const closestMeanIndex = getClosestMeanIndex(array, {
const { index } = getClosestMeanIndex(array, {
minIndex,
maxIndex,
filter,
incrementalMeanMin,
incrementalMeanMax,
})
const coldLoopsLeft =
getLengthFromIndex(COLD_MAX_PERCENTAGE, closestMeanIndex) - length
const coldLoopsLeft = getLengthFromIndex(COLD_MAX_PERCENTAGE, index) - length
return coldLoopsLeft
}

Expand Down Expand Up @@ -145,7 +144,7 @@ const getClosestMean = function (array, { mean, minIndex, maxIndex, filter }) {
}
}

return closestMean
return { closestMean }
}
/* eslint-enable max-statements, complexity, fp/no-let, fp/no-loops,
fp/no-mutation, max-depth, no-continue */
Expand Down Expand Up @@ -181,11 +180,11 @@ const getClosestMeanIndex = function (
incrementalMean >= incrementalMeanMin &&
incrementalMean <= incrementalMeanMax
) {
return index
return { index }
}
}

return maxIndex
return { index: maxIndex }
}
/* eslint-enable max-statements, complexity, fp/no-let, fp/no-loops,
fp/no-mutation, max-depth, no-continue */

0 comments on commit 25f74d2

Please sign in to comment.