Skip to content

Commit d336260

Browse files
committed
refactoring for enhanced code readability
1 parent bc7e6ac commit d336260

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

utils.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,9 @@ const getKeys = (cache, pattern) => new Promise((resolve) => {
1818
const get = (cache, key) => cache.getAndPassUp(key)
1919

2020
const deleteKeys = (stores, patterns) => {
21-
patterns = patterns.map(pattern => pattern.endsWith('*')
22-
? pattern
23-
: [pattern, pattern + DATA_POSTFIX]
24-
).reduce((acc, item) => {
25-
if (Array.isArray(item)) {
26-
acc.push(...item)
27-
} else {
28-
acc.push(item)
29-
}
30-
31-
return acc
32-
}, [])
21+
patterns = patterns.map(pattern =>
22+
pattern.endsWith('*') ? pattern : [pattern, pattern + DATA_POSTFIX]
23+
).flat()
3324

3425
patterns.forEach(pattern => stores.forEach(store => getKeys(store, pattern).then(keys => keys.length > 0 ? store.del(keys) : null)))
3526
}

0 commit comments

Comments
 (0)