Skip to content

Commit f91b047

Browse files
juliangruberisaacs
authored andcommitted
stream: make setEncoding chainable
1 parent 9ef9a9d commit f91b047

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/_stream_readable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Readable.prototype.setEncoding = function(enc) {
198198
StringDecoder = require('string_decoder').StringDecoder;
199199
this._readableState.decoder = new StringDecoder(enc);
200200
this._readableState.encoding = enc;
201+
return this;
201202
};
202203

203204
// Don't raise the hwm > 128MB

test/simple/test-stream2-set-encoding.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,9 @@ test('encoding: base64', function(t) {
359359
t.end();
360360
});
361361
});
362+
363+
test('chainable', function(t) {
364+
var tr = new TestReader(100);
365+
t.equal(tr.setEncoding('utf8'), tr);
366+
t.end();
367+
});

0 commit comments

Comments
 (0)