diff --git a/lib/fs.js b/lib/fs.js index 4e1d8b9f66..8f09235b56 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -598,6 +598,8 @@ fs.createReadStream = function(path, options) { }; var ReadStream = fs.ReadStream = function(path, options) { + if (!(this instanceof ReadStream)) return new ReadStream(path, options); + events.EventEmitter.call(this); var self = this; @@ -794,6 +796,8 @@ fs.createWriteStream = function(path, options) { }; var WriteStream = fs.WriteStream = function(path, options) { + if (!(this instanceof WriteStream)) return new WriteStream(path, options); + events.EventEmitter.call(this); this.path = path; diff --git a/test/simple/test-fs-read-stream.js b/test/simple/test-fs-read-stream.js index db1275a9a5..b008e9153c 100644 --- a/test/simple/test-fs-read-stream.js +++ b/test/simple/test-fs-read-stream.js @@ -15,7 +15,7 @@ callbacks = { open: 0, end: 0, close: 0, destroy: 0 }; paused = false; -file = fs.createReadStream(fn); +file = fs.ReadStream(fn); file.addListener('open', function(fd) { file.length = 0; diff --git a/test/simple/test-fs-write-stream.js b/test/simple/test-fs-write-stream.js index 6679536f50..14ad62e0ba 100644 --- a/test/simple/test-fs-write-stream.js +++ b/test/simple/test-fs-write-stream.js @@ -7,7 +7,7 @@ var path = require('path'), var file = path.join(common.fixturesDir, "write.txt"); (function() { - var stream = fs.createWriteStream(file), + var stream = fs.WriteStream(file), _fs_close = fs.close; fs.close = function(fd) {