From 33e7ed4f6567be1a26e8e5943d868c6925a05dcc Mon Sep 17 00:00:00 2001 From: Frank Bennett Date: Sat, 6 Sep 2014 16:00:01 +0900 Subject: [PATCH] Collect batched data incrementally --- pandoc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandoc.js b/pandoc.js index ac92861..eddf173 100644 --- a/pandoc.js +++ b/pandoc.js @@ -112,9 +112,12 @@ exports.convert = function(type, input, types, callback) { //so that we have the target type in scope on('data') - love ya some asynch pandoc.stdout.targetType = types[i]; + // Data may be batched. Ensure an empty placeholder is available for incremental collection. + res[types[i]] = ''; + pandoc.stdout.on('data', function(data) { //data will be a binary stream if you don't cast it to a string - res[this.targetType] = data + ''; + res[this.targetType] += data + ''; }); pandoc.on('error', function(err) {