Permalink
Browse files

fix encoding option on ReadStream, updated test

  • Loading branch information...
1 parent 2fb393a commit b5dc54c6edf9bf1a84bc930ff4843cfb52893293 @polotek polotek committed with ry Sep 27, 2010
Showing with 3 additions and 2 deletions.
  1. +2 −0 lib/fs.js
  2. +1 −2 test/simple/test-fs-read-stream.js
View
@@ -623,6 +623,8 @@ var ReadStream = fs.ReadStream = function(path, options) {
this[key] = options[key];
}
+ if(this.encoding) this.setEncoding(this.encoding);
+
if (this.start !== undefined || this.end !== undefined) {
if (this.start === undefined || this.end === undefined) {
this.emit('error',
@@ -60,9 +60,8 @@ file2.destroy(function(err) {
callbacks.destroy++;
});
-var file3 = fs.createReadStream(fn);
+var file3 = fs.createReadStream(fn, {encoding: 'utf8'});
file3.length = 0;
-file3.setEncoding('utf8');
file3.addListener('data', function(data) {
assert.equal("string", typeof(data));
file3.length += data.length;

0 comments on commit b5dc54c

Please sign in to comment.