mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
Replace anonymous functions with arrow functions. Replace throw new Error with common.fail. PR-URL: https://github.com/nodejs/node/pull/9700 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
42 lines
953 B
JavaScript
42 lines
953 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const emptyFile = path.join(common.fixturesDir, 'empty.txt');
|
|
|
|
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
|
|
|
assert.ifError(error);
|
|
|
|
const read = fs.createReadStream(emptyFile, { fd });
|
|
|
|
read.once('data', () => {
|
|
common.fail('data event should not emit');
|
|
});
|
|
|
|
read.once('end', common.mustCall(function endEvent1() {}));
|
|
}));
|
|
|
|
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
|
|
|
assert.ifError(error);
|
|
|
|
const read = fs.createReadStream(emptyFile, { fd });
|
|
|
|
read.pause();
|
|
|
|
read.once('data', () => {
|
|
common.fail('data event should not emit');
|
|
});
|
|
|
|
read.once('end', function endEvent2() {
|
|
common.fail('end event should not emit');
|
|
});
|
|
|
|
setTimeout(common.mustCall(() => {
|
|
assert.strictEqual(read.isPaused(), true);
|
|
}), common.platformTimeout(50));
|
|
}));
|