import { decompress } from "../util.js";
import { unimplementedEncode } from "./_shared.js";

interface GzipCodecConfig {
	level: number;
}

export class GzipCodec {
	kind = "bytes_to_bytes";

	static fromConfig(_: GzipCodecConfig) {
		return new GzipCodec();
	}

	encode = unimplementedEncode("gzip");

	async decode(bytes: Uint8Array): Promise<Uint8Array> {
		const buffer = await decompress(bytes, { format: "gzip" });
		return new Uint8Array(buffer);
	}
}
