Skip to content

Commit f18cb12

Browse files
committed
feat: option to not concat all site entity lists into one
1 parent 846f682 commit f18cb12

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

js/util.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export function supportsDNR() {
8181
* @typedef {Object} SiteListUnpackOptions
8282
* @property {boolean} [withSpacers=false] Whether spacers should be included.
8383
* @property {boolean} [withVirtuals=false] Whether derived records should be included.
84+
* @property {boolean} [compacted=true]
8485
*/
8586

8687

@@ -109,7 +110,12 @@ function _unpackSiteArray( entities, options ) {
109110

110111
// Recurse if an array, or append
111112
if ( Array.isArray( entity ) ) {
112-
out = out.concat( _unpackSiteArray( entity, options ) );
113+
const unpacked = _unpackSiteArray( entity, options );
114+
if ( options.compacted ?? true ) {
115+
out = out.concat( unpacked );
116+
} else {
117+
out.push( unpacked );
118+
}
113119
} else {
114120
out.push( entity );
115121
}
@@ -127,12 +133,14 @@ function _unpackSiteArray( entities, options ) {
127133
* @public
128134
* @param {boolean} [withSpacers=false]
129135
* @param {boolean} [withVirtuals=false]
136+
* @param {boolean} [compacted=true]
130137
* @return {SiteListEntity[]}
131138
*/
132-
export function getWikis( withSpacers, withVirtuals ) {
139+
export function getWikis( withSpacers, withVirtuals, compacted ) {
133140
const out = _unpackSiteArray( sites, {
134141
withSpacers,
135-
withVirtuals
142+
withVirtuals,
143+
compacted
136144
} );
137145

138146
if ( withVirtuals ) {

0 commit comments

Comments
 (0)