Open this example in the interactive library
Source code
import * as z from "node:zlib";
const data = Buffer.from("sample sample sample");
console.log(
(() => {
try {
z.gunzipSync(z.gzipSync(data), { maxOutputLength: 4 });
} catch (error) {
return error.code;
}
})(),
);
Sample output
ERR_BUFFER_TOO_LARGE
