From dba8d20ccc0086f1346712d462a8f6fe5fdc29c4 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Mon, 2 Jan 2017 22:22:29 -0500 Subject: [PATCH] test: improve the code in test-fs-read-stream * 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 Reviewed-By: Evan Lucas Reviewed-By: Italo A. Casas Reviewed-By: Brian White --- test/parallel/test-fs-read-stream-fd.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-fs-read-stream-fd.js b/test/parallel/test-fs-read-stream-fd.js index 3ac432be32f375..a9ff56ee93fd91 100644 --- a/test/parallel/test-fs-read-stream-fd.js +++ b/test/parallel/test-fs-read-stream-fd.js @@ -3,21 +3,20 @@ const common = require('../common'); const fs = require('fs'); const assert = require('assert'); const path = require('path'); -var file = path.join(common.tmpDir, '/read_stream_fd_test.txt'); -var input = 'hello world'; -var output = ''; -var fd, stream; +const file = path.join(common.tmpDir, '/read_stream_fd_test.txt'); +const input = 'hello world'; +let output = ''; common.refreshTmpDir(); fs.writeFileSync(file, input); -fd = fs.openSync(file, 'r'); -stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' }); -stream.on('data', function(data) { +const fd = fs.openSync(file, 'r'); +const stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' }); + +stream.on('data', (data) => { output += data; }); -process.on('exit', function() { - fs.unlinkSync(file); - assert.equal(output, input); +process.on('exit', () => { + assert.strictEqual(output, input); });