Merged esm branch into feature-magic. Ported FileType ops.

This commit is contained in:
n1474335 2018-05-20 16:49:42 +01:00
commit ee519c7352
385 changed files with 34205 additions and 39954 deletions

View file

@ -0,0 +1,50 @@
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
import Operation from "../Operation";
import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min";
const Zlib = zlibAndGzip.Zlib;
/**
* Gunzip operation
*/
class Gunzip extends Operation {
/**
* Gunzip constructor
*/
constructor() {
super();
this.name = "Gunzip";
this.module = "Compression";
this.description = "Decompresses data which has been compressed using the deflate algorithm with gzip headers.";
this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer";
this.args = [];
this.patterns = [
{
match: "^\\x1f\\x8b\\x08",
flags: "",
args: []
},
];
}
/**
* @param {ArrayBuffer} input
* @param {Object[]} args
* @returns {File}
*/
run(input, args) {
const gunzip = new Zlib.Gunzip(new Uint8Array(input));
return new Uint8Array(gunzip.decompress()).buffer;
}
}
export default Gunzip;