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) }