Skip to content
Closed
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
9 changes: 4 additions & 5 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const {
ObjectDefineProperties,
ObjectDefineProperty,
ObjectFreeze,
ObjectGetPrototypeOf,
ObjectKeys,
ObjectSetPrototypeOf,
ReflectApply,
Expand All @@ -60,7 +59,8 @@ const {
} = require('internal/util');
const {
isArrayBufferView,
isAnyArrayBuffer
isAnyArrayBuffer,
isUint8Array,
} = require('internal/util/types');
const binding = internalBinding('zlib');
const assert = require('internal/assert');
Expand Down Expand Up @@ -112,10 +112,9 @@ for (const ckey of ObjectKeys(codes)) {

function zlibBuffer(engine, buffer, callback) {
validateFunction(callback, 'callback');
// Streams do not support non-Buffer ArrayBufferViews yet. Convert it to a
// Streams do not support non-Uint8Array ArrayBufferViews yet. Convert it to a
// Buffer without copying.
if (isArrayBufferView(buffer) &&
ObjectGetPrototypeOf(buffer) !== Buffer.prototype) {
if (isArrayBufferView(buffer) && !isUint8Array(buffer)) {
buffer = Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
} else if (isAnyArrayBuffer(buffer)) {
buffer = Buffer.from(buffer);
Expand Down