🎨 replace R.map(R.prop) by R.pluck (equivalent).
refactor state.tags & state.resources
This commit is contained in:
@@ -21,13 +21,12 @@ export const state = () => ({
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
})),
|
})),
|
||||||
// List of all tags, duplicates removed
|
|
||||||
tags: getAllTags(resources),
|
tags: getAllTags(resources),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
tags: state => state.tags,
|
tags: R.prop('tags'),
|
||||||
resources: state => state.resources,
|
resources: R.prop('resources'),
|
||||||
findCategory: state => categoryTitle => {
|
findCategory: state => categoryTitle => {
|
||||||
// equalsCategoryTitle :: Category -> Bool
|
// equalsCategoryTitle :: Category -> Bool
|
||||||
const equalsCategoryTitle = R.compose(
|
const equalsCategoryTitle = R.compose(
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ const Category = {
|
|||||||
export const isNotEmpty = R.compose(R.not, R.isEmpty)
|
export const isNotEmpty = R.compose(R.not, R.isEmpty)
|
||||||
|
|
||||||
// getAllResources :: [Category] -> [Resource]
|
// getAllResources :: [Category] -> [Resource]
|
||||||
export const getAllResources = R.compose(R.flatten, R.map(R.prop('resources')))
|
export const getAllResources = R.compose(R.flatten, R.pluck('resources'))
|
||||||
|
|
||||||
// getAllTags :: [Category] -> [String]
|
// getAllTags :: [Category] -> [String]
|
||||||
export const getAllTags = R.compose(
|
export const getAllTags = R.compose(
|
||||||
R.uniq,
|
R.uniq,
|
||||||
R.flatten,
|
R.flatten,
|
||||||
R.map(R.prop('tags')),
|
R.pluck('tags'),
|
||||||
getAllResources
|
getAllResources
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user