summaryrefslogtreecommitdiff
path: root/lib/internal/fs/streams.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-11-03 19:53:06 +0100
committerRich Trott <rtrott@gmail.com>2018-11-13 23:02:33 -0800
commit0e06b350b6d7c80875321531593efc6f273620e5 (patch)
tree1aac5d70f91b686e3cdac376ff6d40cb585e238d /lib/internal/fs/streams.js
parent9409883dc5f96fb5e9dc7ee34e005547df50418c (diff)
downloadandroid-node-v8-0e06b350b6d7c80875321531593efc6f273620e5.tar.gz
android-node-v8-0e06b350b6d7c80875321531593efc6f273620e5.tar.bz2
android-node-v8-0e06b350b6d7c80875321531593efc6f273620e5.zip
fs,net: standardize `pending` stream property
Use the same property name as http2 does to indicate that the stream is in the state before the `ready` event is emitted. PR-URL: https://github.com/nodejs/node/pull/24067 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/fs/streams.js')
-rw-r--r--lib/internal/fs/streams.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js
index a2ae1c9787..8c9ed35f81 100644
--- a/lib/internal/fs/streams.js
+++ b/lib/internal/fs/streams.js
@@ -228,6 +228,11 @@ ReadStream.prototype.close = function(cb) {
this.destroy(null, cb);
};
+Object.defineProperty(ReadStream.prototype, 'pending', {
+ get() { return this.fd === null; },
+ configurable: true
+});
+
function WriteStream(path, options) {
if (!(this instanceof WriteStream))
return new WriteStream(path, options);
@@ -394,6 +399,11 @@ WriteStream.prototype.close = function(cb) {
// There is no shutdown() for files.
WriteStream.prototype.destroySoon = WriteStream.prototype.end;
+Object.defineProperty(WriteStream.prototype, 'pending', {
+ get() { return this.fd === null; },
+ configurable: true
+});
+
module.exports = {
ReadStream,
WriteStream