UNPKG

igir

Version:

🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.

25 lines (24 loc) • 633 B
import stream from "node:stream"; class ZipBombProtector extends stream.Transform { expectedBytes; readBytes = 0; constructor(expectedBytes) { super(); this.expectedBytes = expectedBytes; } /** * Throw an error if we've read more than the expected bytes. */ _transform(chunk, _encoding, callback) { this.readBytes += chunk.length; if (this.readBytes > this.expectedBytes) { callback(new Error(`stream exceeded expected size of ${this.expectedBytes}`)); return; } callback(null, chunk); } } export { ZipBombProtector as default }; //# sourceMappingURL=zipBombProtector.js.map