From 7170ded47a5314805b0bf7630ccdd9fe42375ab6 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 5 Dec 2022 09:52:40 +0200 Subject: [PATCH] Only check if ancient when not in browser --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c15059f..c80c82a 100644 --- a/index.js +++ b/index.js @@ -3,15 +3,17 @@ var eos = require('end-of-stream') var fs = require('fs') // we only need fs to get the ReadStream and WriteStream prototypes var noop = function () {} -var ancient = /^v?\.0/.test(process.version) var isFn = function (fn) { return typeof fn === 'function' } var isFS = function (stream) { - if (!ancient) return false // newer node version do not need to care about fs is a special way if (!fs) return false // browser + + var ancient = /^v?\.0/.test(process.version) + if (!ancient) return false // newer node version do not need to care about fs is a special way + return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close) }