@@ -113,11 +113,9 @@ const analyze = (css) => {
113113 let specificityA = new AggregateCollection ( )
114114 let specificityB = new AggregateCollection ( )
115115 let specificityC = new AggregateCollection ( )
116- const complexityAggregator = new AggregateCollection ( )
116+ const selectorComplexities = new AggregateCollection ( )
117117 /** @type [number,number,number][] */
118118 const specificities = [ ]
119- /** @type number[] */
120- const complexities = [ ]
121119 const ids = new CountableCollection ( )
122120 const a11y = new CountableCollection ( )
123121
@@ -233,7 +231,7 @@ const analyze = (css) => {
233231 }
234232
235233 uniqueSelectors . push ( selector )
236- complexityAggregator . add ( complexity )
234+ selectorComplexities . add ( complexity )
237235
238236 if ( maxSpecificity === undefined ) {
239237 maxSpecificity = specificity
@@ -256,7 +254,6 @@ const analyze = (css) => {
256254 }
257255
258256 specificities . push ( specificity )
259- complexities . push ( complexity )
260257
261258 // Avoid deeper walking of selectors to not mess with
262259 // our specificity calculations in case of a selector
@@ -415,11 +412,11 @@ const analyze = (css) => {
415412
416413 const totalUniqueDeclarations = uniqueDeclarations . count ( )
417414
418- const totalSelectors = complexities . length
419- const aggregatesA = specificityA . aggregate ( )
420- const aggregatesB = specificityB . aggregate ( )
421- const aggregatesC = specificityC . aggregate ( )
422- const complexityCount = new CountableCollection ( complexities ) . count ( )
415+ const totalSelectors = selectorComplexities . size ( )
416+ const specificitiesA = specificityA . aggregate ( )
417+ const specificitiesB = specificityB . aggregate ( )
418+ const specificitiesC = specificityC . aggregate ( )
419+ const complexityCount = new CountableCollection ( selectorComplexities . toArray ( ) ) . count ( )
423420 const totalUniqueSelectors = uniqueSelectors . count ( )
424421
425422 return {
@@ -481,16 +478,16 @@ const analyze = (css) => {
481478 specificity : {
482479 min : minSpecificity === undefined ? [ 0 , 0 , 0 ] : minSpecificity ,
483480 max : maxSpecificity === undefined ? [ 0 , 0 , 0 ] : maxSpecificity ,
484- sum : [ aggregatesA . sum , aggregatesB . sum , aggregatesC . sum ] ,
485- mean : [ aggregatesA . mean , aggregatesB . mean , aggregatesC . mean ] ,
486- mode : [ aggregatesA . mode , aggregatesB . mode , aggregatesC . mode ] ,
487- median : [ aggregatesA . median , aggregatesB . median , aggregatesC . median ] ,
481+ sum : [ specificitiesA . sum , specificitiesB . sum , specificitiesC . sum ] ,
482+ mean : [ specificitiesA . mean , specificitiesB . mean , specificitiesC . mean ] ,
483+ mode : [ specificitiesA . mode , specificitiesB . mode , specificitiesC . mode ] ,
484+ median : [ specificitiesA . median , specificitiesB . median , specificitiesC . median ] ,
488485 items : specificities
489486 } ,
490487 complexity : Object . assign (
491- complexityAggregator . aggregate ( ) ,
488+ selectorComplexities . aggregate ( ) ,
492489 complexityCount , {
493- items : complexities
490+ items : selectorComplexities . toArray ( ) ,
494491 } ) ,
495492 id : Object . assign (
496493 ids . count ( ) , {
0 commit comments