From 0e501f4ec51602f14eb397b3c1bd29435cf65aad Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 8 Sep 2010 12:03:33 -0700 Subject: [PATCH] Fix style; undefined reference bug --- lib/fs.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index dcd41db628..f164a454fc 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -611,6 +611,8 @@ fs.createReadStream = function(path, options) { var ReadStream = fs.ReadStream = function(path, options) { events.EventEmitter.call(this); + var self = this; + this.path = path; this.fd = null; this.readable = true; @@ -629,11 +631,12 @@ var ReadStream = fs.ReadStream = function(path, options) { this[key] = options[key]; } - if(this.start || this.end) { - if(this.start === undefined || this.end === undefined) { - self.emit('error', new Error('Both start and end are needed for range streaming.')); - } else if(this.start > this.end) { - self.emit('error', new Error('start must be <= end')); + if (this.start || this.end) { + if (this.start === undefined || this.end === undefined) { + this.emit('error', + new Error('Both start and end are needed for range streaming.')); + } else if (this.start > this.end) { + this.emit('error', new Error('start must be <= end')); } else { this.firstRead = true; } @@ -643,7 +646,6 @@ var ReadStream = fs.ReadStream = function(path, options) { return; } - var self = this; fs.open(this.path, this.flags, this.mode, function(err, fd) { if (err) { self.emit('error', err);