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.
30 lines (29 loc) • 698 B
JavaScript
import stream from "node:stream";
import zlib from "node:zlib";
class UncompressedTransform extends stream.Transform {
size = 0;
crc32 = 0;
/**
* Increment the size and update the CRC32, then passthrough the data.
*/
_transform(chunk, _encoding, callback) {
this.size += chunk.length;
try {
this.crc32 = zlib.crc32(chunk, this.crc32);
} catch (error) {
callback(error instanceof Error ? error : new Error(String(error)));
return;
}
callback(null, chunk);
}
getSize() {
return this.size;
}
getCrc32() {
return this.crc32 >>> 0;
}
}
export {
UncompressedTransform as default
};
//# sourceMappingURL=uncompressedTransform.js.map