Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 09b0d14

Browse files
author
tkostuch
committed
3948 move filter after map
1 parent f6c61f9 commit 09b0d14

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/api/attribute/service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,20 @@ async function list (attributesParam: AttributeListParam, config, indexName: str
9494
)
9595

9696
const cachedAttributeList = rawCachedAttributeList
97-
.filter(Boolean) // remove empty results from cache.get
9897
.map((cachedAttribute, index) => {
9998
if (cachedAttribute) {
10099
const attributeOptionsIds = attributesParam[cachedAttribute.attribute_code]
101100

102-
// side effect - we want to reduce starting 'attributeCodes' because some of them are in cache
101+
// side effect - we want to reduce starting 'attributeCodes' if some of them are in cache
103102
attributeCodes.splice(index, 1)
104103

105104
// clear unused options
106105
return clearAttributeOpitons(cachedAttribute, attributeOptionsIds)
107106
}
108107
})
108+
// remove empty results from cache.get
109+
// this needs to be after .map because we want to have same indexes as are in attributeCodes
110+
.filter(Boolean)
109111

110112
// if all requested attributes are in cache then we can return here
111113
if (!attributeCodes.length) {

0 commit comments

Comments
 (0)