Skip to content

Commit 72ebad2

Browse files
committed
f
1 parent 1ac8dc7 commit 72ebad2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/_stream_readable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ Readable.prototype.setEncoding = function(enc) {
327327
if (!StringDecoder)
328328
StringDecoder = require('string_decoder').StringDecoder;
329329
this._readableState.decoder = new StringDecoder(enc);
330-
// if setEncoding(null), decoder.encoding = 'utf8'
330+
// if setEncoding(null), decoder.encoding equals utf8
331331
this._readableState.encoding = this._readableState.decoder.encoding;
332332
return this;
333333
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const { Readable } = require('stream');
6+
7+
8+
{
9+
const readable = new Readable({ encoding: 'hex' });
10+
assert.strictEqual(readable._readableState.encoding, 'hex');
11+
12+
readable.setEncoding(null);
13+
14+
assert.strictEqual(readable._readableState.encoding, 'utf8');
15+
}

0 commit comments

Comments
 (0)