From 43fb35486ee365952140e23325a1d152e6029c6a Mon Sep 17 00:00:00 2001 From: Kevin Van Der Werff Date: Mon, 21 Oct 2019 23:17:10 +0200 Subject: [PATCH] :art: rewrite findCategory --- .eslintrc.js | 6 +++--- store/data.js | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index aab30e7..a3152e0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', } } \ No newline at end of file diff --git a/store/data.js b/store/data.js index 7f775ae..4be5fd9 100644 --- a/store/data.js +++ b/store/data.js @@ -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)