From c6dfcbbd1f63d9e28656c05d5e2bdf00f400f2d5 Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Tue, 9 Sep 2014 13:55:21 +0200 Subject: [PATCH] call setEncoding on native stream --- lib/devices/node._js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/devices/node._js b/lib/devices/node._js index 7899e5a..4bdd686 100644 --- a/lib/devices/node._js +++ b/lib/devices/node._js @@ -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; @@ -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.