🎨 rewrite findCategory

This commit is contained in:
Kevin Van Der Werff
2019-10-21 23:17:10 +02:00
parent 6bca23dca5
commit 43fb35486e
2 changed files with 10 additions and 5 deletions

View File

@@ -20,11 +20,11 @@ module.exports = {
],
// add your custom rules here
rules: {
'semi': ['error', 'never'],
'semi': ['warning', 'never'],
'no-console': 'off',
'vue/max-attributes-per-line': 'off',
'quotes': ['error', 'single', { 'avoidEscape': true }],
'comma-dangle': ['error', 'always-multiline'],
'quotes': ['warning', 'single', { 'avoidEscape': true }],
'comma-dangle': ['warning', 'always-multiline'],
'vue/require-default-prop': 'off',
}
}

View File

@@ -47,7 +47,13 @@ export const getters = {
tags: state => state.tags,
resources: state => state.resources,
findCategory: state => categoryTitle => {
return Object.assign(state.resources.find(category => category.title.toLowerCase() === categoryTitle.toLowerCase()))
// equalsCategoryTitle :: Category -> Bool
const equalsCategoryTitle = R.compose(
R.equals(R.toLower(categoryTitle)), R.toLower, R.prop('title')
)
// findCategory :: [Category] -> Category
const findCategory = R.find(equalsCategoryTitle)
return findCategory(state.resources)
},
findByName: state => names => {
const cleaned = R.map(cleanString, names)
@@ -59,7 +65,6 @@ export const getters = {
// [Category] -> [Resource]
const getDesiredResources = R.compose(appearsInResource, getAllResources)
return getDesiredResources(state.resources)
},
findByTags: state => tags => {
const cleaned = R.map(cleanString, tags)