Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
fix encoding option on ReadStream, updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
polotek authored and ry committed Oct 1, 2010
1 parent 2fb393a commit b5dc54c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/fs.js
Expand Up @@ -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',
Expand Down
3 changes: 1 addition & 2 deletions test/simple/test-fs-read-stream.js
Expand Up @@ -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;
Expand Down

0 comments on commit b5dc54c

Please sign in to comment.