@@ -189,8 +189,9 @@ class JsonStreamStringify extends Readable {
189
189
obj . isEmpty = ! obj . unread . length ;
190
190
} else if ( type === 'Array' ) {
191
191
this . depth += 1 ;
192
- obj . unread = Array . from ( Array ( realValue . length ) . keys ( ) ) ;
193
- obj . isEmpty = ! obj . unread . length ;
192
+ obj . unread = realValue . length ;
193
+ obj . arrayLength = obj . unread ;
194
+ obj . isEmpty = ! obj . unread ;
194
195
} else if ( type . startsWith ( 'Readable' ) ) {
195
196
this . depth += 1 ;
196
197
if ( realValue . _readableState . ended ) {
@@ -267,12 +268,20 @@ class JsonStreamStringify extends Readable {
267
268
}
268
269
const key = current . unread . shift ( ) ;
269
270
const value = current . value [ key ] ;
270
-
271
- this . addToStack ( value , current . type === 'Object' && key , current . type === 'Array' && key , current ) ;
271
+ this . addToStack ( value , key , undefined , current ) ;
272
272
}
273
273
274
274
processArray ( current ) {
275
- return this . processObject ( current ) ;
275
+ const key = current . unread ;
276
+ if ( ! key ) {
277
+ this . removeFromStack ( current ) ;
278
+ return ;
279
+ }
280
+ const index = current . arrayLength - key ;
281
+ const value = current . value [ index ] ;
282
+ /* eslint-disable-next-line no-param-reassign */
283
+ current . unread -= 1 ;
284
+ this . addToStack ( value , undefined , index , current ) ;
276
285
}
277
286
278
287
processPrimitive ( current ) {
0 commit comments