Skip to content

Commit c6dfcbb

Browse files
committed
call setEncoding on native stream
1 parent 2b2fcc0 commit c6dfcbb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/devices/node._js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ require('../reader').decorate(streams.ReadableStream.prototype);
99
require('../writer').decorate(streams.WritableStream.prototype);
1010

1111
function fixOptions(options) {
12+
if (typeof options === "string") options = {
13+
encoding: options,
14+
};
1215
options = options || {};
1316
options.ez = true;
1417
return options;
@@ -25,7 +28,10 @@ module.exports = {
2528
/// For a full description of the options, see `ReadableStream` in
2629
/// https://github.com/Sage/streamline-streams/blob/master/lib/streams.md
2730
reader: function(emitter, options) {
28-
return new streams.ReadableStream(emitter, fixOptions(options));
31+
options = fixOptions(options);
32+
var reader = new streams.ReadableStream(emitter, options);
33+
if (options.encoding) reader.setEncoding(options.encoding);
34+
return reader;
2935
},
3036
/// * `writer = ez.devices.node.writer(stream, options)`
3137
/// wraps a node.js stream as an EZ writer.

0 commit comments

Comments
 (0)