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.

23 lines (22 loc) • 611 B
import stream from 'node:stream'; import zstd from '../../zstd-1.5.5/index.js'; /** * A Transform stream that compresses data using zstd synchronous compression. */ export default class ZstdNonThreadedCompressTransform extends stream.Transform { chunks = []; /** * Buffer all read file data. */ _transform(chunk, _encoding, callback) { this.chunks.push(chunk); callback(); } /** * Compress all file data in a single call. */ _flush(callback) { this.push(zstd.compressNonThreaded(Buffer.concat(this.chunks), 19)); callback(); } }