File tree 1 file changed +7
-11
lines changed
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');
11
11
const tmpdir = require ( '../common/tmpdir' ) ;
12
12
const assert = require ( 'assert' ) ;
13
13
const { finished } = require ( 'stream/promises' ) ;
14
- const { Blob } = require ( 'buffer ' ) ;
14
+ const { buffer } = require ( 'stream/consumers ' ) ;
15
15
const tmpDir = tmpdir . path ;
16
16
17
17
tmpdir . refresh ( ) ;
@@ -31,19 +31,15 @@ async function validateWrite() {
31
31
32
32
async function validateRead ( ) {
33
33
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' ) ;
35
35
36
- fs . writeFileSync ( filePathForHandle , buffer ) ;
36
+ fs . writeFileSync ( filePathForHandle , buf ) ;
37
37
38
38
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
+ ) ;
47
43
}
48
44
49
45
Promise . all ( [
You can’t perform that action at this time.
0 commit comments