File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const path = require('path');
1111const tmpdir = require ( '../common/tmpdir' ) ;
1212const assert = require ( 'assert' ) ;
1313const { finished } = require ( 'stream/promises' ) ;
14- const { Blob } = require ( 'buffer ' ) ;
14+ const { buffer } = require ( 'stream/consumers ' ) ;
1515const tmpDir = tmpdir . path ;
1616
1717tmpdir . refresh ( ) ;
@@ -31,19 +31,15 @@ async function validateWrite() {
3131
3232async function validateRead ( ) {
3333 const filePathForHandle = path . resolve ( tmpDir , 'tmp-read.txt' ) ;
34- const buffer = Buffer . from ( 'Hello world' . repeat ( 100 ) , 'utf8' ) ;
34+ const buf = Buffer . from ( 'Hello world' . repeat ( 100 ) , 'utf8' ) ;
3535
36- fs . writeFileSync ( filePathForHandle , buffer ) ;
36+ fs . writeFileSync ( filePathForHandle , buf ) ;
3737
3838 const fileHandle = await open ( filePathForHandle ) ;
39-
40- const chunks = [ ] ;
41- for await ( const chunk of fileHandle . createReadStream ( ) ) {
42- chunks . push ( chunk ) ;
43- }
44-
45- const arrayBuffer = await new Blob ( chunks ) . arrayBuffer ( ) ;
46- assert . deepStrictEqual ( Buffer . from ( arrayBuffer ) , buffer ) ;
39+ assert . deepStrictEqual (
40+ await buffer ( fileHandle . createReadStream ( ) ) ,
41+ buf
42+ ) ;
4743}
4844
4945Promise . all ( [
You can’t perform that action at this time.
0 commit comments