Skip to content
This repository was archived by the owner on Feb 21, 2018. It is now read-only.

fix: Use Buffer.isBuffer to check buffer type #23

Merged
merged 1 commit into from
Jan 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ function zlibBuffer(engine, buffer, callback) {
function zlibBufferSync(engine, buffer) {
if (typeof buffer === 'string')
buffer = Buffer.from(buffer);
if (!(buffer instanceof Buffer))

if (!Buffer.isBuffer(buffer))
throw new TypeError('Not a string or buffer');

var flushFlag = engine._finishFlushFlag;
Expand Down Expand Up @@ -352,7 +353,7 @@ function Zlib(opts, mode) {
}

if (opts.dictionary) {
if (!(opts.dictionary instanceof Buffer)) {
if (!Buffer.isBuffer(opts.dictionary)) {
throw new Error('Invalid dictionary: it should be a Buffer instance');
}
}
Expand Down Expand Up @@ -492,7 +493,7 @@ Zlib.prototype._transform = function(chunk, encoding, cb) {
var ending = ws.ending || ws.ended;
var last = ending && (!chunk || ws.length === chunk.length);

if (chunk !== null && !(chunk instanceof Buffer))
if (chunk !== null && !Buffer.isBuffer(chunk))
return cb(new Error('invalid input'));

if (!this._handle)
Expand Down