File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 6868 "onetime" : " ^5.1.0" ,
6969 "p-limit" : " ^2.2.0" ,
7070 "pumpify" : " ^2.0.0" ,
71+ "readable-stream" : " ^3.4.0" ,
7172 "snakeize" : " ^0.1.0" ,
7273 "stream-events" : " ^1.0.1" ,
7374 "through2" : " ^3.0.0" ,
Original file line number Diff line number Diff line change @@ -1190,6 +1190,9 @@ class File extends ServiceObject<File> {
11901190
11911191 // tslint:disable-next-line:no-any
11921192 let validateStream : any ; // Created later, if necessary.
1193+
1194+ // TODO: remove `through2` dependency in favor of native PassThrough
1195+ // once Node 8 support is discontinued
11931196 const throughStream = streamEvents ( through ( ) ) as Duplex ;
11941197
11951198 let crc32c = true ;
Original file line number Diff line number Diff line change @@ -2061,6 +2061,19 @@ describe('storage', () => {
20612061 } ) ;
20622062 } ) ;
20632063
2064+ it ( 'should support readable[Symbol.asyncIterator]()' , async ( ) => {
2065+ const fileContents = fs . readFileSync ( FILES . big . path ) ;
2066+
2067+ const [ file ] = await bucket . upload ( FILES . big . path ) ;
2068+ const stream = file . createReadStream ( ) ;
2069+ const chunks : Buffer [ ] = [ ] ;
2070+ for await ( const chunk of stream ) {
2071+ chunks . push ( chunk ) ;
2072+ }
2073+ const remoteContents = Buffer . concat ( chunks ) . toString ( ) ;
2074+ assert . strictEqual ( String ( fileContents ) , String ( remoteContents ) ) ;
2075+ } ) ;
2076+
20642077 it ( 'should download a file to memory' , done => {
20652078 const fileContents = fs . readFileSync ( FILES . big . path ) ;
20662079 bucket . upload ( FILES . big . path , ( err : Error | null , file ?: File | null ) => {
You can’t perform that action at this time.
0 commit comments