Skip to content

Commit 054a480

Browse files
author
Jérémy
committed
refactor(service-module.getters): formatting and removing hasOwnProperty check on params
1 parent 2990af5 commit 054a480

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/service-module/service-module.getters.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const getCopiesById = ({
3131

3232
export default function makeServiceGetters() {
3333
return {
34-
list: (state) => Object.values(state.keyedById),
35-
find: (state) => (_params) => {
34+
list: state => Object.values(state.keyedById),
35+
find: state => _params => {
3636
const params = unref(_params) || {}
3737

3838
const {
@@ -50,18 +50,16 @@ export default function makeServiceGetters() {
5050

5151
let values = Object.values(keyedById) as any
5252

53-
if (params.hasOwnProperty('temps') && params.temps) {
53+
if (params.temps) {
5454
values.push(...(Object.values(tempsById) as any))
5555
}
5656

5757
values = values.filter(sift(query))
5858

59-
if (params.hasOwnProperty('copies') && params.copies) {
59+
if (params.copies) {
6060
const copiesById = getCopiesById(state)
6161
// replace keyedById value with existing clone value
62-
values = values.map(
63-
(value, index) => copiesById[value[idField]] || value
64-
)
62+
values = values.map(value => copiesById[value[idField]] || value)
6563
}
6664

6765
const total = values.length
@@ -87,7 +85,7 @@ export default function makeServiceGetters() {
8785
data: values
8886
}
8987
},
90-
count: (state, getters) => (_params) => {
88+
count: (state, getters) => _params => {
9189
const params = unref(_params) || {}
9290

9391
const cleanQuery = _omit(params.query, FILTERS)
@@ -111,7 +109,7 @@ export default function makeServiceGetters() {
111109

112110
return tempRecord || null
113111
},
114-
getCopyById: (state) => (id) => {
112+
getCopyById: state => id => {
115113
const copiesById = getCopiesById(state)
116114
return copiesById[id]
117115
},

0 commit comments

Comments
 (0)