Work around incorrect 'encoding' parameter from upstream

master
Sven Slootweg 4 years ago
parent 9e1b2584b4
commit 131e1e643c

@ -17,11 +17,12 @@ module.exports = function createTransform(file, options) {
let buffer = new bl.BufferList();
function chunkHandler(chunk, encoding, callback) {
if (encoding === "buffer") {
// NOTE: We check the `chunk` here, not the `encoding`, because in at least one instance a Buffer was passed in claiming to be a "utf8" string according to the `encoding` argument
if (Buffer.isBuffer(chunk)) {
buffer.append(chunk);
callback();
} else {
throw new Error(`Expected Buffer, got ${encoding} string instead`);
throw new Error(`Expected Buffer, got string instead (encoding = ${encoding})`);
}
}

Loading…
Cancel
Save