Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 5, 2021
1 parent 4062b5e commit b216279
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
23 changes: 22 additions & 1 deletion src/report/reporters/histogram/width.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getColWidths } from '../../utils/width.js'
import { getCombinationPaddedName } from '../../utils/name.js'

import { getPaddedStatLength } from './abscissa.js'

Expand All @@ -18,3 +18,24 @@ const getHistogramColWidth = function (statName, { stats }) {
? 0
: getPaddedStatLength(stats[statName])
}

const getColWidths = function ({
combinations,
minWidths,
maxWidths,
mini,
screenWidth,
}) {
const titlesWidth = getCombinationPaddedName(combinations[0]).length
const minBlockWidth = getMinMaxBlockWidth(combinations, mini, minWidths)
const maxBlockWidth = getMinMaxBlockWidth(combinations, mini, maxWidths)
const contentWidth = Math.max(
screenWidth - titlesWidth - minBlockWidth - maxBlockWidth,
1,
)
return { titlesWidth, minBlockWidth, contentWidth }
}

const getMinMaxBlockWidth = function (combinations, mini, widths) {
return mini ? 0 : Math.max(...widths)
}
30 changes: 0 additions & 30 deletions src/report/utils/width.js

This file was deleted.

0 comments on commit b216279

Please sign in to comment.