browserify-zlib icon indicating copy to clipboard operation
browserify-zlib copied to clipboard

Node zlib inflateSync will take UInt8Array, browserify-zlib won't

Open johnwhitington opened this issue 3 years ago • 1 comments

For example, this code is fine with node:

zlib.inflateSync(arr);

But with browserify-zlib we get TypeError: not a string or buffer and we must write instead:

zlib.inflateSync(Buffer.from(arr))

johnwhitington avatar Aug 12 '22 11:08 johnwhitington

Getting the same with deflateSync used with a buffer.

import Zlib from "browserify-zlib";

const byteArray = new TextEncoder().encode("foo");

Zlib.deflateSync(byteArray.buffer); // should work, throws TypeError: not a string or buffer

Zlib.deflateSync(Buffer.from(byteArray)); // works

charlieanstey avatar Oct 21 '22 10:10 charlieanstey