From d8b9808ae0481f26e1c6ffef7d03012084de34f6 Mon Sep 17 00:00:00 2001 From: dexterleng <thequicklab@gmail.com> Date: Fri, 16 Nov 2018 10:28:06 +0800 Subject: [PATCH 1/2] fs: flip value of isOpen --- lib/internal/fs/streams.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index a2ae1c9787d288..bb3a8fd8a62e13 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -204,8 +204,8 @@ ReadStream.prototype._read = function(n) { }; ReadStream.prototype._destroy = function(err, cb) { - const isOpen = typeof this.fd !== 'number'; - if (isOpen) { + const isOpen = typeof this.fd === 'number'; + if (!isOpen) { this.once('open', closeFsStream.bind(null, this, cb, err)); return; } From 9392d6733f38170da428b044402fa58ad8f1e053 Mon Sep 17 00:00:00 2001 From: dexterleng <thequicklab@gmail.com> Date: Sat, 17 Nov 2018 00:20:55 +0800 Subject: [PATCH 2/2] fs: inline typeof check --- lib/internal/fs/streams.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index bb3a8fd8a62e13..cd4331de3026cb 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -204,8 +204,7 @@ ReadStream.prototype._read = function(n) { }; ReadStream.prototype._destroy = function(err, cb) { - const isOpen = typeof this.fd === 'number'; - if (!isOpen) { + if (typeof this.fd !== 'number') { this.once('open', closeFsStream.bind(null, this, cb, err)); return; }