mirror of https://github.com/nodejs/node.git
fix encoding option on ReadStream, updated test
parent
c9627e0a0d
commit
4a7562d28f
|
@ -635,6 +635,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;
|
||||
|
|
Loading…
Reference in New Issue