Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent d9942b2 commit 9f552ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/combination/ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getCombinationsIds = function (combinations) {

// Same but for a single combination
export const getCombinationIds = function (combination) {
return getIdInfos(combination).map(getId)
return getIdInfos(combination)
}

export const getCombinationName = function (combination) {
Expand All @@ -40,10 +40,6 @@ const getIdInfos = function (combination) {
}))
}

const getId = function ({ id }) {
return id
}

// Remove duplicate ids with the same dimension, since this happens due to the
// cartesian product.
// Duplicate ids with a different dimension are validated later.
Expand Down
8 changes: 3 additions & 5 deletions src/select/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ export const matchSelectors = function (combination, selectors) {
return true
}

const combinationIds = getCombinationIds(combination).map(
removeCombinationIdCase,
)
const combinationIds = getCombinationIds(combination).map(getCombinationId)
const index = findIndexReverse(selectors, (selector) =>
matchIds(combinationIds, selector),
)
Expand All @@ -46,8 +44,8 @@ export const matchSelectors = function (combination, selectors) {
}

// Matching is case-insensitive
const removeCombinationIdCase = function (combinationId) {
return combinationId.toLowerCase()
const getCombinationId = function ({ id }) {
return id.toLowerCase()
}

// An empty array selects any combinations:
Expand Down

0 comments on commit 9f552ea

Please sign in to comment.