File tree Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change 114114 "is-glob" : " ^4.0.3" ,
115115 "minimatch" : " ^3.1.2" ,
116116 "object.fromentries" : " ^2.0.6" ,
117+ "object.groupby" : " ^1.0.0" ,
117118 "object.values" : " ^1.1.6" ,
118119 "resolve" : " ^1.22.3" ,
119120 "semver" : " ^6.3.1" ,
Original file line number Diff line number Diff line change 22
33import minimatch from 'minimatch' ;
44import includes from 'array-includes' ;
5+ import groupBy from 'object.groupby' ;
56
67import importType from '../core/importType' ;
78import isStaticRequire from '../core/staticRequire' ;
@@ -325,13 +326,7 @@ function getSorter(alphabetizeOptions) {
325326}
326327
327328function mutateRanksToAlphabetize ( imported , alphabetizeOptions ) {
328- const groupedByRanks = imported . reduce ( function ( acc , importedItem ) {
329- if ( ! Array . isArray ( acc [ importedItem . rank ] ) ) {
330- acc [ importedItem . rank ] = [ ] ;
331- }
332- acc [ importedItem . rank ] . push ( importedItem ) ;
333- return acc ;
334- } , { } ) ;
329+ const groupedByRanks = groupBy ( imported , ( item ) => item . rank ) ;
335330
336331 const sorterFn = getSorter ( alphabetizeOptions ) ;
337332
You can’t perform that action at this time.
0 commit comments