Skip to content

Commit 207df82

Browse files
committed
fixup! fs: add stream utilities to FileHandle
1 parent 4f9977a commit 207df82

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

test/parallel/test-fs-promises-file-handle-stream.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const path = require('path');
1111
const tmpdir = require('../common/tmpdir');
1212
const assert = require('assert');
1313
const { finished } = require('stream/promises');
14-
const { Blob } = require('buffer');
14+
const { buffer } = require('stream/consumers');
1515
const tmpDir = tmpdir.path;
1616

1717
tmpdir.refresh();
@@ -31,19 +31,15 @@ async function validateWrite() {
3131

3232
async 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

4945
Promise.all([

0 commit comments

Comments
 (0)