diff --git a/lib/fs.js b/lib/fs.js index 58704e529747b2..a17563038058b1 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1619,7 +1619,8 @@ function ReadStream(path, options) { options = {}; else if (typeof options === 'string') options = { encoding: options }; - else if (options === null || typeof options !== 'object') + else if (options === null || + typeof options !== 'object' && typeof options !== 'function') throw new TypeError('options must be a string or an object'); // a little bit bigger buffer and water marks by default @@ -1790,7 +1791,8 @@ function WriteStream(path, options) { options = {}; else if (typeof options === 'string') options = { encoding: options }; - else if (options === null || typeof options !== 'object') + else if (options === null || + typeof options !== 'object' && typeof options !== 'function') throw new TypeError('options must be a string or an object'); options = Object.create(options);