Skip to content

Commit 7391983

Browse files
ruggertechMylesBorins
authored andcommitted
test: implemented es6 conventions
implemented arrow functions and changed var to const where appropriate. PR-URL: #9669 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 50ce3f9 commit 7391983

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var fs = require('fs');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const fs = require('fs');
55

6-
var stream = fs.createReadStream(__filename, {
6+
const stream = fs.createReadStream(__filename, {
77
bufferSize: 64
88
});
9-
var err = new Error('BAM');
9+
const err = new Error('BAM');
1010

11-
stream.on('error', common.mustCall(function errorHandler(err_) {
12-
console.error('error event');
13-
process.nextTick(function() {
14-
assert.equal(stream.fd, null);
15-
assert.equal(err_, err);
16-
});
11+
stream.on('error', common.mustCall((err_) => {
12+
process.nextTick(common.mustCall(() => {
13+
assert.strictEqual(stream.fd, null);
14+
assert.strictEqual(err_, err);
15+
}));
1716
}));
1817

19-
fs.close = common.mustCall(function(fd_, cb) {
20-
assert.equal(fd_, stream.fd);
18+
fs.close = common.mustCall((fd_, cb) => {
19+
assert.strictEqual(fd_, stream.fd);
2120
process.nextTick(cb);
2221
});
2322

24-
var read = fs.read;
23+
const read = fs.read;
2524
fs.read = function() {
2625
// first time is ok.
2726
read.apply(fs, arguments);
2827
// then it breaks
29-
fs.read = function() {
30-
var cb = arguments[arguments.length - 1];
31-
process.nextTick(function() {
28+
fs.read = common.mustCall(function() {
29+
const cb = arguments[arguments.length - 1];
30+
process.nextTick(() => {
3231
cb(err);
3332
});
3433
// and should not be called again!
35-
fs.read = function() {
34+
fs.read = () => {
3635
throw new Error('BOOM!');
3736
};
38-
};
37+
});
3938
};
4039

41-
stream.on('data', function(buf) {
42-
stream.on('data', common.fail); // no more 'data' events should follow
40+
stream.on('data', (buf) => {
41+
stream.on('data', () => common.fail("no more 'data' events should follow"));
4342
});

0 commit comments

Comments
 (0)