diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-09-16 19:04:09 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-09-16 19:04:09 -0700 |
commit | bbbcd1fee0a85fb21c6a3206760f4b24d545746e (patch) | |
tree | 327880c6dd620f5c48c1e38369a93259395c1089 /lib/fs.js | |
parent | 6da0593162dbc861d32c83b38e083dbfd2df870d (diff) | |
download | node-new-bbbcd1fee0a85fb21c6a3206760f4b24d545746e.tar.gz |
Safe constructors for fs.ReadStream and fs.WriteStream
Diffstat (limited to 'lib/fs.js')
-rw-r--r-- | lib/fs.js | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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; |