File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,23 +31,20 @@ function flattenFill(docs) {
3131 */
3232 ( function rec ( docArray ) {
3333 for ( const doc of docArray ) {
34- switch ( getDocType ( doc ) ) {
35- case DOC_TYPE_FILL : {
36- const [ head , ...rest ] = doc . parts ;
37- parts . at ( - 1 ) . push ( head ) ;
38- parts . push ( ...rest . map ( ( doc ) => [ doc ] ) ) ;
39- if ( rest . length % 2 === 1 ) {
40- parts . push ( [ ] ) ;
41- }
42- break ;
43- }
44- case DOC_TYPE_ARRAY :
45- rec ( doc ) ;
46- break ;
47- default :
48- parts . at ( - 1 ) . push ( doc ) ;
49- break ;
34+ const docType = getDocType ( doc ) ;
35+ if ( docType === DOC_TYPE_ARRAY ) {
36+ rec ( doc ) ;
37+ continue ;
5038 }
39+
40+ let head = doc ;
41+ let rest = [ ] ;
42+ if ( docType === DOC_TYPE_FILL ) {
43+ [ head , ...rest ] = doc . parts ;
44+ }
45+
46+ parts [ parts . length - 1 ] = [ parts . at ( - 1 ) , head ] ;
47+ parts . push ( ...rest ) ;
5148 }
5249 } ) ( docs ) ;
5350
You can’t perform that action at this time.
0 commit comments