mirror of
https://github.com/ragestudio/comty.js.git
synced 2025-06-09 02:24:18 +00:00
added standartListMerge
This commit is contained in:
parent
4d90a7cc5a
commit
571ba5a1d0
18
src/utils/standartListMerge.js
Normal file
18
src/utils/standartListMerge.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export default (base, obj) => {
|
||||||
|
const validGroups = Object.keys(obj).filter(
|
||||||
|
(key) => Array.isArray(obj[key]?.items) && obj[key].items.length > 0,
|
||||||
|
)
|
||||||
|
|
||||||
|
return validGroups.reduce(
|
||||||
|
(acc, group) => {
|
||||||
|
if (!acc[group]) {
|
||||||
|
acc[group] = { items: [], total_items: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
acc[group].items = [...acc[group].items, ...obj[group].items]
|
||||||
|
acc[group].total_items += obj[group].total_items || 0
|
||||||
|
return acc
|
||||||
|
},
|
||||||
|
{ ...base },
|
||||||
|
)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user