Skip to content

Commit

Permalink
Don't copy chunks if they're already buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
zbjornson committed Mar 8, 2019
1 parent becc1c0 commit 1e1b4fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -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)
}

Expand All @@ -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()
}

Expand Down

0 comments on commit 1e1b4fc

Please sign in to comment.