node/test/parallel/test-fs-ready-event-stream.js
Sameer Srivastava 1c8149417a
fs,net: emit 'ready' for fs streams and sockets
... in addition to the event names they currently use.

Currently, various internal streams have different events that
indicate that the underlying resource has successfully been
established. This commit adds ready event for fs and net
sockets to standardize on emitting ready for all of these streams.

PR-URL: https://github.com/nodejs/node/pull/19408
Fixes: https://github.com/nodejs/node/issues/19304
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-23 13:33:55 +01:00

14 lines
474 B
JavaScript

'use strict';
const common = require('../common');
const fs = require('fs');
const path = require('path');
const tmpdir = require('../common/tmpdir');
const readStream = fs.createReadStream(__filename);
readStream.on('ready', common.mustCall(() => {}, 1));
const writeFile = path.join(tmpdir.path, 'write-fsreadyevent.txt');
tmpdir.refresh();
const writeStream = fs.createWriteStream(writeFile, { autoClose: true });
writeStream.on('ready', common.mustCall(() => {}, 1));