browserify-zlib
browserify-zlib copied to clipboard
Node zlib inflateSync will take UInt8Array, browserify-zlib won't
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))
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