Skip to content

Commit

Permalink
call setEncoding on native stream
Browse files Browse the repository at this point in the history
  • Loading branch information
bjouhier committed Sep 9, 2014
1 parent 2b2fcc0 commit c6dfcbb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/devices/node._js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ require('../reader').decorate(streams.ReadableStream.prototype);
require('../writer').decorate(streams.WritableStream.prototype);

function fixOptions(options) {
if (typeof options === "string") options = {
encoding: options,
};
options = options || {};
options.ez = true;
return options;
Expand All @@ -25,7 +28,10 @@ module.exports = {
/// For a full description of the options, see `ReadableStream` in
/// https://github.com/Sage/streamline-streams/blob/master/lib/streams.md
reader: function(emitter, options) {
return new streams.ReadableStream(emitter, fixOptions(options));
options = fixOptions(options);
var reader = new streams.ReadableStream(emitter, options);
if (options.encoding) reader.setEncoding(options.encoding);
return reader;
},
/// * `writer = ez.devices.node.writer(stream, options)`
/// wraps a node.js stream as an EZ writer.
Expand Down

0 comments on commit c6dfcbb

Please sign in to comment.