@@ -20,7 +20,6 @@ import {
20
20
BundleMetadata
21
21
} from '../protos/firestore_bundle_proto' ;
22
22
import { Deferred } from './promise' ;
23
- import { AsyncQueue } from './async_queue' ;
24
23
25
24
/**
26
25
* A complete element in the bundle stream, together with the byte length it
@@ -101,10 +100,9 @@ export class BundleReader {
101
100
if ( element && element . isBundleMetadata ( ) ) {
102
101
this . metadata . resolve ( element . payload . metadata ! ) ;
103
102
} else {
104
- const payload = ( element || { payload : null } ) . payload ;
105
103
this . metadata . reject (
106
104
new Error ( `The first element of the bundle is not a metadata, it is
107
- ${ JSON . stringify ( payload ) } ` )
105
+ ${ JSON . stringify ( element ?. payload ) } ` )
108
106
) ;
109
107
}
110
108
} ,
@@ -172,8 +170,7 @@ export class BundleReader {
172
170
* If reached end of the stream, returns a null.
173
171
*/
174
172
private async readLength ( ) : Promise < Uint8Array | null > {
175
- let position : number ;
176
- while ( ( position = this . indexOfOpenBracket ( ) ) < 0 ) {
173
+ while ( this . indexOfOpenBracket ( ) < 0 ) {
177
174
const done = await this . pullMoreDataToBuffer ( ) ;
178
175
if ( done ) {
179
176
break ;
@@ -186,7 +183,7 @@ export class BundleReader {
186
183
return null ;
187
184
}
188
185
189
- position = this . indexOfOpenBracket ( ) ;
186
+ const position = this . indexOfOpenBracket ( ) ;
190
187
// Broke out of the loop because underlying stream is closed, but still
191
188
// cannot find an open bracket.
192
189
if ( position < 0 ) {
0 commit comments