Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function flush(stream) {
if (!stream._chunks)
return;
var chunk;
while (chunk = stream._chunks.shift()) {
stream.size -= chunk.length;
if (stream.encoding) {
stream.emit('data', bodec.toString(chunk, stream.encoding));
} else {
stream.emit('data', chunk);
}
// If the stream was paused in a data event handler, break.
if (stream.paused)
break;
}
if (stream.ended) {
if (!stream.paused) {
stream._chunks = null;
stream.emit('end');
}
} else if (stream._wasFull && !stream.full) {
stream._wasFull = false;
function stringifyData(data) {
return bodec.toString(bodec.join(data));
}
return this.bufferContent(maxLength).then(function (chunk) {
return bodec.toString(chunk, encoding);
});
}),
return this.bufferContent(maxLength).then(function (chunk) {
return bodec.toString(chunk, encoding);
});
}),