Support compressed data packets with algorithm=uncompressed (#1085)

This commit is contained in:
Ilya Chesnokov 2020-04-21 21:00:38 +07:00 committed by GitHub
parent c4a7455cb5
commit 674e0217fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,6 +132,10 @@ export default Compressed;
const nodeZlib = util.getNodeZlib();
function uncompressed(data) {
return data;
}
function node_zlib(func, options = {}) {
return function (data) {
return stream.nodeToWeb(stream.webToNode(data).pipe(func(options)));
@ -170,6 +174,7 @@ if (nodeZlib) { // Use Node native zlib for DEFLATE compression/decompression
};
decompress_fns = {
uncompressed: uncompressed,
zip: node_zlib(nodeZlib.createInflateRaw),
zlib: node_zlib(nodeZlib.createInflate),
bzip2: bzip2(Bunzip.decode)
@ -181,6 +186,7 @@ if (nodeZlib) { // Use Node native zlib for DEFLATE compression/decompression
};
decompress_fns = {
uncompressed: uncompressed,
zip: pako_zlib(pako.Inflate, { raw: true }),
zlib: pako_zlib(pako.Inflate),
bzip2: bzip2(Bunzip.decode)