How to use deflateSyncUncompressed method in wpt

Best JavaScript code snippet using wpt

svg.js

Source:svg.js Github

copy

Full Screen

...83 return b << 16 | a;84 }85 function deflateSync(literals) {86 if (!(0, _util.isNodeJS)()) {87 return deflateSyncUncompressed(literals);88 }89 try {90 var input;91 if (parseInt(process.versions.node) >= 8) {92 input = literals;93 } else {94 input = new Buffer(literals);95 }96 var output = require('zlib').deflateSync(input, { level: 9 });97 return output instanceof Uint8Array ? output : new Uint8Array(output);98 } catch (e) {99 (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);100 }101 return deflateSyncUncompressed(literals);102 }103 function deflateSyncUncompressed(literals) {104 var len = literals.length;105 var maxBlockLength = 0xFFFF;106 var deflateBlocks = Math.ceil(len / maxBlockLength);107 var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);108 var pi = 0;109 idat[pi++] = 0x78;110 idat[pi++] = 0x9c;111 var pos = 0;112 while (len > maxBlockLength) {113 idat[pi++] = 0x00;114 idat[pi++] = 0xff;115 idat[pi++] = 0xff;116 idat[pi++] = 0x00;117 idat[pi++] = 0x00;...

Full Screen

Full Screen

pdfjs.js

Source:pdfjs.js Github

copy

Full Screen

...70 if (!isNodeJS()) {71 // zlib is certainly not available outside of Node.js. We can either use72 // the pako library for client-side DEFLATE compression, or use the canvas73 // API of the browser to obtain a more optimal PNG file.74 return deflateSyncUncompressed(literals);75 }76 try {77 // NOTE: This implementation is far from perfect, but already way better78 // than not applying any compression.79 //80 // A better algorithm will try to choose a good predictor/filter and81 // then choose a suitable zlib compression strategy (e.g. 3,Z_RLE).82 //83 // Node v0.11.12 zlib.deflateSync is introduced (and returns a Buffer).84 // Node v3.0.0 Buffer inherits from Uint8Array.85 // Node v8.0.0 zlib.deflateSync accepts Uint8Array as input.86 let input;87 // eslint-disable-next-line no-undef88 if (parseInt(process.versions.node) >= 8) {89 input = literals;90 } else {91 // eslint-disable-next-line no-undef92 // input = new Buffer(literals);93 input = Buffer.from(literals);94 }95 // const output = __non_webpack_require__('zlib')96 const output = zlib97 .deflateSync(input, { level: 9 });98 return output instanceof Uint8Array ? output : new Uint8Array(output);99 } catch (e) {100 console.warn('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);101 }102 return deflateSyncUncompressed(literals);103 }104 // An implementation of DEFLATE with compression level 0 (Z_NO_COMPRESSION).105 function deflateSyncUncompressed (literals) {106 let len = literals.length;107 const maxBlockLength = 0xFFFF;108 const deflateBlocks = Math.ceil(len / maxBlockLength);109 const idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);110 let pi = 0;111 idat[pi++] = 0x78; // compression method and flags112 idat[pi++] = 0x9c; // flags113 let pos = 0;114 while (len > maxBlockLength) {115 // writing non-final DEFLATE blocks type 0 and length of 65535116 idat[pi++] = 0x00;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful