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 ad28a2f commit 6d1fee6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
17 changes: 2 additions & 15 deletions src/report/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { getNoDimensions } from '../combination/filter.js'

import { getContents } from './contents.js'
import { finalizeContents } from './finalize.js'
import { normalizeComputedResult } from './normalize/computed.js'
import { normalizeEarlyResult } from './normalize/early.js'
import { normalizeReportedResults } from './normalize/raw.js'
import { outputContents } from './output.js'
import { startReporters, endReporters } from './start_end.js'

Expand All @@ -31,22 +28,12 @@ export const reportResult = async function (rawResult, history, config) {
// Start reporting
export const reportStart = async function (rawResult, history, config) {
const configA = await startReporters(config)
const { result, history: historyA } = normalizeReportedResults(
rawResult,
history,
configA.select,
)
const noDimensions = getNoDimensions(result.combinations)
const {
result: resultA,
sinceResult,
config: configB,
} = normalizeEarlyResult({
result,
history: historyA,
noDimensions,
config: configA,
})
config: configB,
} = normalizeEarlyResult(rawResult, history, configA)
return { result: resultA, sinceResult, noDimensions, config: configB }
}

Expand Down
21 changes: 12 additions & 9 deletions src/report/normalize/early.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { getNoDimensions } from '../../combination/filter.js'

import {
normalizeNonCombAll,
normalizeCombAll,
normalizeNonCombEach,
mergeResultProps,
normalizeCombEach,
} from './common.js'
import { normalizeReportedResults } from './raw.js'
import { normalizeTargetResult } from './target.js'

// Normalize as many properties as possible at the beginning of the reporting
// (once) as opposed to later on (repeatedly)
export const normalizeEarlyResult = function ({
result,
history,
history: [sinceResult],
noDimensions,
config,
}) {
export const normalizeEarlyResult = function (rawResult, history, config) {
const {
result,
history: historyA,
history: [sinceResult],
} = normalizeReportedResults(rawResult, history, config)
const noDimensions = getNoDimensions(result.combinations)
const configA = normalizeHistory({
history,
history: historyA,
result,
sinceResult,
noDimensions,
Expand All @@ -27,7 +30,7 @@ export const normalizeEarlyResult = function ({
result,
configA,
)
return { result: resultA, sinceResult, config: configB }
return { result: resultA, sinceResult, noDimensions, config: configB }
}

// Add report-specific properties to each `history` result.
Expand Down
2 changes: 1 addition & 1 deletion src/report/normalize/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { selectRawResult } from '../../select/main.js'
export const normalizeReportedResults = function (
targetResult,
history,
select,
{ select },
) {
const { history: historyA, targetResult: targetResultA } = mergeResults(
history,
Expand Down

0 comments on commit 6d1fee6

Please sign in to comment.