Browse Source

fix encoding option on ReadStream, updated test

v0.7.4-release
Marco Rogers 14 years ago
committed by Ryan Dahl
parent
commit
4a7562d28f
  1. 2
      lib/fs.js
  2. 3
      test/simple/test-fs-read-stream.js

2
lib/fs.js

@ -635,6 +635,8 @@ var ReadStream = fs.ReadStream = function(path, options) {
this[key] = options[key]; 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) {
if (this.start === undefined || this.end === undefined) { if (this.start === undefined || this.end === undefined) {
this.emit('error', this.emit('error',

3
test/simple/test-fs-read-stream.js

@ -60,9 +60,8 @@ file2.destroy(function(err) {
callbacks.destroy++; callbacks.destroy++;
}); });
var file3 = fs.createReadStream(fn); var file3 = fs.createReadStream(fn, {encoding: 'utf8'});
file3.length = 0; file3.length = 0;
file3.setEncoding('utf8');
file3.addListener('data', function(data) { file3.addListener('data', function(data) {
assert.equal("string", typeof(data)); assert.equal("string", typeof(data));
file3.length += data.length; file3.length += data.length;

Loading…
Cancel
Save