Compression level now dropdown.

This commit is contained in:
Leon Zandman 2026-05-10 01:04:21 +02:00
parent 4ba952e6e2
commit 5aeb8e61c2
2 changed files with 12 additions and 9 deletions

View File

@ -22,17 +22,20 @@ class ZstdCompress extends Operation {
this.name = "Zstd Compress";
this.module = "Compression";
this.description = "Compresses data using the Zstandard (Zstd) algorithm. Zstd offers high compression ratios at fast speeds and is widely used in Linux, databases, container images, and network protocols.";
this.description = "Compresses data using the Zstandard (Zstd) algorithm. Zstd offers high compression ratios at fast speeds and is widely used in Linux, databases, container images, and network protocols. Higher compression levels result in better compression but slower speed.";
this.infoURL = "https://wikipedia.org/wiki/Zstandard";
this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer";
this.args = [
{
name: "Compression level",
type: "number",
value: 3,
min: 1,
max: 22
type: "option",
value: [
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
"21", "22"
],
defaultIndex: 2
}
];
}
@ -43,7 +46,7 @@ class ZstdCompress extends Operation {
* @returns {ArrayBuffer}
*/
async run(input, args) {
const [level] = args;
const level = parseInt(args[0], 10);
if (input.byteLength === 0) throw new OperationError("Please provide an input.");
if (isWorkerEnvironment()) self.sendStatusMessage("Loading Zstd...");
await zstdInit();

View File

@ -15,7 +15,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "Zstd Compress",
args: [3]
args: ["3"]
},
{
op: "Zstd Decompress",
@ -31,7 +31,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "Zstd Compress",
args: [3]
args: ["3"]
},
{
op: "To Hex",
@ -62,7 +62,7 @@ TestRegister.addTests([
recipeConfig: [
{
op: "Zstd Compress",
args: [3]
args: ["3"]
}
]
},