summaryrefslogtreecommitdiff
path: root/lib/fs.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-09-16 19:04:09 -0700
committerRyan Dahl <ry@tinyclouds.org>2010-09-16 19:04:09 -0700
commitbbbcd1fee0a85fb21c6a3206760f4b24d545746e (patch)
tree327880c6dd620f5c48c1e38369a93259395c1089 /lib/fs.js
parent6da0593162dbc861d32c83b38e083dbfd2df870d (diff)
downloadnode-new-bbbcd1fee0a85fb21c6a3206760f4b24d545746e.tar.gz
Safe constructors for fs.ReadStream and fs.WriteStream
Diffstat (limited to 'lib/fs.js')
-rw-r--r--lib/fs.js4
1 files changed, 4 insertions, 0 deletions
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;