From 6d1fee689d3eed9f5508f0c81523dd6c92fa4a49 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 9 Jan 2022 17:49:32 +0100 Subject: [PATCH] Refactoring --- src/report/main.js | 17 ++--------------- src/report/normalize/early.js | 21 ++++++++++++--------- src/report/normalize/raw.js | 2 +- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/report/main.js b/src/report/main.js index 51b8bacb9..32fe27951 100644 --- a/src/report/main.js +++ b/src/report/main.js @@ -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' @@ -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 } } diff --git a/src/report/normalize/early.js b/src/report/normalize/early.js index b33c04751..d7eb6b7d2 100644 --- a/src/report/normalize/early.js +++ b/src/report/normalize/early.js @@ -1,3 +1,5 @@ +import { getNoDimensions } from '../../combination/filter.js' + import { normalizeNonCombAll, normalizeCombAll, @@ -5,19 +7,20 @@ import { 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, @@ -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. diff --git a/src/report/normalize/raw.js b/src/report/normalize/raw.js index 20f899738..cf1147769 100644 --- a/src/report/normalize/raw.js +++ b/src/report/normalize/raw.js @@ -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,