How to use the pako.ungzip function in pako

To help you get started, we’ve selected a few pako examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pd4d10 / npmview / src / app.js View on Github external
unzip = async () => {
    const res = await fetch(
      'https://cors-anywhere.herokuapp.com/https://registry.npmjs.org/tiza/download/tiza-2.1.0.tgz',
    )
    const data = await res.arrayBuffer()
    const buffer = await pako.ungzip(data)
    // console.log(buffer)
    untar(buffer.buffer).then(console.log, console.log, console.log)
    // console.log(t)
  }
github openworm / org.geppetto.frontend / src / main / webapp / js / communication / MessageSocket.js View on Github external
function processBinaryMessage(message) {

            var messageBytes = new Uint8Array(message);

            // if it's a binary message and first byte it's zero then assume it's a compressed json string
            //otherwise is a file and a 'save as' dialog is opened
            if (messageBytes[0] == 0) {
                var message = pako.ungzip(messageBytes.subarray(1), {to: "string"});
                parseAndNotify(message);
            }
            else {
                var fileNameLength = messageBytes[1];
                var fileName = String.fromCharCode.apply(null, messageBytes.subarray(2, 2 + fileNameLength));
                var blob = new Blob([message]);
                FileSaver.saveAs(blob.slice(2 + fileNameLength), fileName);
            }
        }
    }
github naptha / tesseract.js / src / worker.js View on Github external
db.get(lang, function (err, value) {

						// err = true

						if (err) {
							downloadlang(true)
						}
						else {

							while(value[0] == 0x1f && value[1] == 0x8b){
								value = pako.ungzip(value)
							}

							postMessage({
								index: index,
								'progress': {
									loaded_lang_model:1,
									cached: true
								}
							})

							Module.FS_createDataFile('tessdata', lang +".traineddata", value, true, false);
							loaded_langs.push(lang)
							cb(null, lang)
						}
					})
				}
github Cirrus-Link / Sparkplug / client_libraries / javascript / sparkplug-client / index.js View on Github external
logger.debug("Decompressing payload");

        if (metrics !== undefined && metrics !== null) {
            for (var i = 0; i < metrics.length; i++) {
                if (metrics[i].name === "algorithm") {
                    algorithm = metrics[i].value;
                }
            }
        }

        if (algorithm === null || algorithm.toUpperCase() === "DEFLATE") {
            logger.debug("Decompressing with DEFLATE!");
            return pako.inflate(payload.body);
        } else if (algorithm.toUpperCase() === "GZIP") {
            logger.debug("Decompressing with GZIP");
            return pako.ungzip(payload.body);
        } else {
            throw new Error("Unknown or unsupported algorithm " + algorithm);
        }

    },
github Leko / type-puzzle / packages / playground / src / lib / share.ts View on Github external
async decode(queryParamStr: string): Promise {
    const base64String = decodeURIComponent(queryParamStr);
    const gziped = Uint8Array.from(atob(base64String), c => c.charCodeAt(0));
    const configStr = ungzip(gziped, { to: "string" });
    const config = JSON.parse(configStr);

    return config;
  }
github naptha / tesseract.js / src / worker / loadLanguage.js View on Github external
db.get(lang, (err, data) => {

			if (err) return getLanguageData(lang, progressMessage, createDataFileCached)

			while(data[0] == 0x1f && data[1] == 0x8b) data = ungzip(data);

			progressMessage({ loaded_lang_model: lang, from_cache: true })

			cb(null, data)
		})
	})
github eclipse / tahu / client_libraries / javascript / sparkplug-client / index.js View on Github external
logger.debug("Decompressing payload");

        if (metrics !== undefined && metrics !== null) {
            for (var i = 0; i < metrics.length; i++) {
                if (metrics[i].name === "algorithm") {
                    algorithm = metrics[i].value;
                }
            }
        }

        if (algorithm === null || algorithm.toUpperCase() === "DEFLATE") {
            logger.debug("Decompressing with DEFLATE!");
            return pako.inflate(payload.body);
        } else if (algorithm.toUpperCase() === "GZIP") {
            logger.debug("Decompressing with GZIP");
            return pako.ungzip(payload.body);
        } else {
            throw new Error("Unknown or unsupported algorithm " + algorithm);
        }

    },
github openworm / org.geppetto.frontend / src / main / webapp / js / communication / MessageSocket.js View on Github external
function gzipUncompress(compressedMessage) {
            var messageBytes = new Uint8Array(compressedMessage);
            var message = pako.ungzip(messageBytes, {to: "string"});
            return message;
        }
github zerobias / telegram-mtproto / lib / net / encrypted-rpc-channel.js View on Github external
function checkIfGzipped(obj) {
  if (typeof obj !== 'boolean' && obj.instanceOf('mtproto.type.Gzip_packed')) {
    const packedData = obj.packed_data
    const buffer = pako.ungzip(packedData)
    Object.setPrototypeOf(buffer, packedData.__proto__)
    const Type = tl.TypeBuilder.requireTypeFromBuffer(buffer)
    return new Type({ buffer: buffer }).deserialize()
  }
  else return obj
}