@@ -155,31 +155,29 @@ exports.supplyDefaults = function(transformIn, traceOut) {
155155 arrayAttrs [ groups ] = 0 ;
156156 }
157157
158- var aggregationsIn = transformIn . aggregations ;
158+ var aggregationsIn = transformIn . aggregations || [ ] ;
159159 var aggregationsOut = transformOut . aggregations = new Array ( aggregationsIn . length ) ;
160160 var aggregationOut ;
161161
162162 function coercei ( attr , dflt ) {
163163 return Lib . coerce ( aggregationsIn [ i ] , aggregationOut , aggAttrs , attr , dflt ) ;
164164 }
165165
166- if ( aggregationsIn ) {
167- for ( i = 0 ; i < aggregationsIn . length ; i ++ ) {
168- aggregationOut = { } ;
169- var target = coercei ( 'target' ) ;
170- var func = coercei ( 'func' ) ;
171- var enabledi = coercei ( 'enabled' ) ;
172-
173- // add this aggregation to the output only if it's the first instance
174- // of a valid target attribute - or an unused target attribute with "count"
175- if ( enabledi && target && ( arrayAttrs [ target ] || ( func === 'count' && arrayAttrs [ target ] === undefined ) ) ) {
176- if ( func === 'stddev' ) coercei ( 'funcmode' ) ;
177-
178- arrayAttrs [ target ] = 0 ;
179- aggregationsOut [ i ] = aggregationOut ;
180- }
181- else aggregationsOut [ i ] = { enabled : false } ;
166+ for ( i = 0 ; i < aggregationsIn . length ; i ++ ) {
167+ aggregationOut = { } ;
168+ var target = coercei ( 'target' ) ;
169+ var func = coercei ( 'func' ) ;
170+ var enabledi = coercei ( 'enabled' ) ;
171+
172+ // add this aggregation to the output only if it's the first instance
173+ // of a valid target attribute - or an unused target attribute with "count"
174+ if ( enabledi && target && ( arrayAttrs [ target ] || ( func === 'count' && arrayAttrs [ target ] === undefined ) ) ) {
175+ if ( func === 'stddev' ) coercei ( 'funcmode' ) ;
176+
177+ arrayAttrs [ target ] = 0 ;
178+ aggregationsOut [ i ] = aggregationOut ;
182179 }
180+ else aggregationsOut [ i ] = { enabled : false } ;
183181 }
184182
185183 // any array attributes we haven't yet covered, fill them with the default aggregation
0 commit comments