Comparing version 3.0.5 to 3.0.6
@@ -38,8 +38,6 @@ 'use strict'; | ||
if (this.decoder) { | ||
if (this.decoder.$reading) { | ||
this.decoder.$done = callback; | ||
return; | ||
} else { | ||
this.decoder.end(); | ||
} | ||
// emit an empty node just in case there is pending data to end | ||
return this.processIncoming({ | ||
type: 'none' | ||
}, callback); | ||
} | ||
@@ -52,3 +50,7 @@ return callback(); | ||
// data to parse | ||
this.decoder.write(data.value); | ||
if (!this.decoder.write(data.value)) { | ||
return this.decoder.once('drain', callback); | ||
} else { | ||
return callback(); | ||
} | ||
} else if (this.decoder && data.type !== 'body') { | ||
@@ -68,4 +70,4 @@ // stop decoding. | ||
// found matching node, create new handler | ||
this.emit('node', this.createDecoder(data)); | ||
} else if (this.readable) { | ||
this.emit('node', this.createDecodePair(data)); | ||
} else if (this.readable && data.type !== 'none') { | ||
// we don't care about this data, just pass it over to the joiner | ||
@@ -77,3 +79,3 @@ this.push(data); | ||
createDecoder(node) { | ||
createDecodePair(node) { | ||
this.decoder = node.getDecoder(); | ||
@@ -91,3 +93,2 @@ | ||
decoder.$reading = false; | ||
decoder.$done = false; | ||
@@ -100,6 +101,2 @@ let readFromEncoder = () => { | ||
decoder.$reading = false; | ||
if (typeof decoder.$done === 'function') { | ||
decoder.end(); | ||
decoder.$done(); | ||
} | ||
return; | ||
@@ -152,2 +149,6 @@ } | ||
if (/^text\//.test(node.contentType) && node.flowed) { | ||
// text/plain; format=flowed is a special case. Buffer everything | ||
// and decode. | ||
// For optimization we could use streams here as the format is very simple | ||
let chunks = []; | ||
@@ -170,7 +171,10 @@ let chunklen = 0; | ||
currentBody = Buffer.from(content, 'binary'); | ||
node.flowed = false; | ||
node.delSp = false; | ||
node.setContentType(); | ||
decoder.end(currentBody); | ||
}); | ||
// we don't know what kind of data we are going to get, does it comply with the | ||
// requirements of format=flowed, so we just cancel it | ||
node.flowed = false; | ||
node.delSp = false; | ||
node.setContentType(); | ||
} | ||
@@ -177,0 +181,0 @@ |
{ | ||
"name": "mailsplit", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Split email messages into an object stream", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
42675
851