From 1e1b4fcdbcd03eb301566d172d94efcd0e5eb83a Mon Sep 17 00:00:00 2001 From: Zach Bjornson Date: Fri, 8 Mar 2019 11:04:52 -0800 Subject: [PATCH] Don't copy chunks if they're already buffers --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f190c689..b4870587 100644 --- a/index.js +++ b/index.js @@ -85,7 +85,7 @@ function compression (options) { } return stream - ? stream.write(Buffer.from(chunk, encoding)) + ? stream.write(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding)) : _write.call(this, chunk, encoding) } @@ -112,7 +112,7 @@ function compression (options) { // write Buffer for Node.js 0.8 return chunk - ? stream.end(Buffer.from(chunk, encoding)) + ? stream.end(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding)) : stream.end() }