Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 26, 2021
1 parent c6031fa commit ad83881
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/system/footer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { omitFooterProps } from '../omit.js'

import { serializeFooter } from './serialize.js'
import { addSharedSystems } from './shared/main.js'
import { sortSystems } from './sort/main.js'

// Add each `reporter.footer`
// TODO:
// - use `addSharedSystems()` then `sortSystems()`
// - this logic should come after `serialize.js`, i.e. there are no deep
// properties and all properties values are strings
// - However, the `system.title` logic should be moved after it
Expand All @@ -33,8 +33,9 @@ export const addFooter = function ({
const footerA = addFooterTitles(footer, titles, showTitles)
const footerB = omitFooterProps(footerA, showMetadata, showSystem)
const footerC = addSharedSystems(footerB)
const footerD = serializeFooter(footerC)
const { footerParams, footerString } = applyFooterFormat(footerD, format)
const footerD = sortSystems(footerC)
const footerE = serializeFooter(footerD)
const { footerParams, footerString } = applyFooterFormat(footerE, format)
return { ...reporter, footerParams, footerString }
}

Expand Down
8 changes: 6 additions & 2 deletions src/system/footer/sort/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { compareSystems } from './systems.js'

// Sort systems deeply so they are shown in a user-friendly and predictable way
// in the footer
export const sortSystems = function (systems) {
export const sortSystems = function (footer) {
// eslint-disable-next-line fp/no-mutating-methods
return systems.map(addSortProps).sort(compareSystems).map(removeSortProps)
const systems = footer.systems
.map(addSortProps)
.sort(compareSystems)
.map(removeSortProps)
return { ...footer, systems }
}

// Add properties used during sorting so they are only computed once
Expand Down

0 comments on commit ad83881

Please sign in to comment.