@@ -73,24 +73,14 @@ export async function loadGameConfigurations(): Promise<void> {
73
73
74
74
/**
75
75
* find all items in all select groups
76
- * @param groupKey string or array of string of which to find items connected with
76
+ * @param groupKeys array of string of which to find items connected with
77
77
* @return itemsKeys array of itemkeys in all select groups
78
78
*/
79
- export const findItemTagsInGroup = ( groupKey : string | string [ ] ) : string [ ] => {
80
- if ( ! groupKey ) {
81
- return [ ] ;
82
- }
83
-
84
- if ( Array . isArray ( groupKey ) ) {
85
- const collection : Record < string , boolean > = { }
86
- groupKey . forEach ( ( currentGroup ) => {
87
- const items = findItemTagsInGroup ( currentGroup ) ;
88
- items . forEach ( ( item ) => collection [ item ] = true )
89
- } )
90
- return Object . keys ( collection )
91
- }
92
-
93
- return Object . keys ( itemGroupMap [ groupKey ] || { } )
79
+ export const findItemTagsInGroups = ( groupKeys : string [ ] ) : string [ ] => {
80
+ return Object . keys ( groupKeys . reduce < Record < string , boolean > > ( ( all , groupKey ) => {
81
+ const items = itemGroupMap [ groupKey ] || { } ;
82
+ return { ...all , ...items } ;
83
+ } , { } ) ) ;
94
84
}
95
85
96
86
@@ -103,7 +93,7 @@ export const findItemTagsInGroupFilter = (groupKeys: string[]): string[] => {
103
93
if ( ! groupKeys || groupKeys . length === 0 ) {
104
94
return [ ] ;
105
95
}
106
- let collection : Record < string , boolean > | undefined = undefined
96
+ let collection : Record < string , boolean > | undefined = undefined ;
107
97
groupKeys . forEach ( ( groupKey ) => {
108
98
if ( ! collection ) {
109
99
collection = { ...( itemGroupMap [ groupKey ] || { } ) } ;
@@ -115,10 +105,10 @@ export const findItemTagsInGroupFilter = (groupKeys: string[]): string[] => {
115
105
if ( ! ( existingItemKey in current ) ) {
116
106
delete collection [ existingItemKey ] ;
117
107
}
118
- } )
119
- } )
108
+ } ) ;
109
+ } ) ;
120
110
121
- return Object . keys ( collection )
111
+ return Object . keys ( collection ) ;
122
112
}
123
113
124
114
0 commit comments