@@ -22,29 +22,13 @@ export function listStores(
22
22
// We can't use `async/await` here because that would make the signature
23
23
// incompatible with one of the overloads.
24
24
// eslint-disable-next-line promise/prefer-await-to-then
25
- return collectIterator ( iterator ) . then ( ( results ) =>
26
- results . reduce (
27
- ( acc , item ) => ( {
28
- ...acc ,
29
- stores : [ ...acc . stores , ...item . stores ] ,
30
- } ) ,
31
- { stores : [ ] } ,
32
- ) ,
33
- )
25
+ return collectIterator ( iterator ) . then ( ( results ) => ( { stores : results . flatMap ( ( page ) => page . stores ) } ) )
34
26
}
35
27
36
- const formatListStoreResponse = ( rawStores : string [ ] ) =>
37
- rawStores . reduce ( ( acc , rawStore ) => {
38
- if ( rawStore . startsWith ( DEPLOY_STORE_PREFIX ) ) {
39
- return acc
40
- }
41
-
42
- if ( rawStore . startsWith ( SITE_STORE_PREFIX ) ) {
43
- return [ ...acc , rawStore . slice ( SITE_STORE_PREFIX . length ) ]
44
- }
45
-
46
- return [ ...acc , rawStore ]
47
- } , [ ] as string [ ] )
28
+ const formatListStoreResponse = ( stores : string [ ] ) =>
29
+ stores
30
+ . filter ( ( store ) => ! store . startsWith ( DEPLOY_STORE_PREFIX ) )
31
+ . map ( ( store ) => ( store . startsWith ( SITE_STORE_PREFIX ) ? store . slice ( SITE_STORE_PREFIX . length ) : store ) )
48
32
49
33
const getListIterator = ( client : Client , prefix : string ) : AsyncIterable < ListStoresResponse > => {
50
34
const parameters : Record < string , string > = {
0 commit comments