mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 20:08:02 +00:00

* use const and let instead of var * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10556 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Brian White <mscdex@mscdex.net>
23 lines
540 B
JavaScript
23 lines
540 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const file = path.join(common.tmpDir, '/read_stream_fd_test.txt');
|
|
const input = 'hello world';
|
|
|
|
let output = '';
|
|
common.refreshTmpDir();
|
|
fs.writeFileSync(file, input);
|
|
|
|
const fd = fs.openSync(file, 'r');
|
|
const stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' });
|
|
|
|
stream.on('data', (data) => {
|
|
output += data;
|
|
});
|
|
|
|
process.on('exit', () => {
|
|
assert.strictEqual(output, input);
|
|
});
|