Added File and JSON Dish types and updated types for compression ops.

This commit is contained in:
n1474335 2018-04-21 13:41:42 +01:00
parent 76a066ab74
commit a8aa1bc5e8
9 changed files with 94 additions and 59 deletions

View file

@ -24,8 +24,8 @@ class ZlibDeflate extends Operation {
this.name = "Zlib Deflate";
this.module = "Compression";
this.description = "Compresses data using the deflate algorithm adding zlib headers.";
this.inputType = "byteArray";
this.outputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer";
this.args = [
{
name: "Compression type",
@ -36,15 +36,15 @@ class ZlibDeflate extends Operation {
}
/**
* @param {byteArray} input
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {byteArray}
* @returns {ArrayBuffer}
*/
run(input, args) {
const deflate = new Zlib.Deflate(input, {
const deflate = new Zlib.Deflate(new Uint8Array(input), {
compressionType: ZLIB_COMPRESSION_TYPE_LOOKUP[args[0]]
});
return Array.prototype.slice.call(deflate.compress());
return new Uint8Array(deflate.compress()).buffer;
}
}