How to use the pako.Deflate 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 Pixpipe / pixpipejs / src / decoder / PixpEncoder.js View on Github external
console.warn("PixpEncoder can only encode Image2D and Image3D.");
      return;
    }

    var input = this._getInput();

    var arrayAndMeta = {
      dataType: input.getData().constructor.name, // typed array type
      data: Array.prototype.slice.call( input.getData() ),  // data of pixel/voxel
      metadata: input.getMetadataCopy(),  // Image2D/Image3D._metadata
      pixpipeType: input.constructor.name // most likely "Image2D", "Image3D", "LineString", etc.
    }

    var pixpString = JSON.stringify( arrayAndMeta );

    var deflator = new pako.Deflate({
      level: 6,
      //to: 'string',
      gzip: true,
      header: {
          text: true,
          time: + new Date(),
          comment: "This file was created by Pixpipe.js"
        }
    });

    deflator.push(pixpString, true);

    // making a blob to be saved
    this._output[0] = new Blob([deflator.result], {type: "application/gzip"} );
  }
github teamapps-org / teamapps / teamapps-client / ts / modules / communication / ReconnectingWebSocketConnection.ts View on Github external
constructor() {
		this.deflate = new Deflate();
		this.deflate.onData = (data: Uint8Array) => {
			this.currentInflatedData.set(data, this.currentInflatedDataFillSize);
			this.currentInflatedDataFillSize += data.length;
		}
	}
github neuroanatomy / BrainBox / view / atlasMaker / src / atlasmaker-io.js View on Github external
};
/*eslint-enable camelcase*/
        me.NiiHdrLE.allocate();
        const niihdr = me.NiiHdrLE.buffer();
        let i;
        for(i in newHdr) {
            if({}.hasOwnProperty.call(newHdr, i)) {
                me.NiiHdrLE.fields[i] = newHdr[i];
            }
        }
        const hdr = toArrayBuffer(niihdr);
        const {data} = me.atlas;
        var nii = new Uint8Array(vox_offset + data.length);
        for(i = 0; i
github jtorhoff / flier / src / tg / Gzip / Gzip.ts View on Github external
export const compress = (data: Uint8Array): Uint8Array | undefined => {
        const deflate = new pako.Deflate({
            level: 9,
            windowBits: 15 + 16,
            memLevel: 9,
        });
        deflate.push(data, true);
        if (deflate.err) {
            return undefined;
        }

        return deflate.result as Uint8Array;
    };
github pokemontrades / flairhq / api / services / Usernotes.js View on Github external
var compress = function(notesObject) {
  var deflate = new pako.Deflate({to: 'string'});
  deflate.push(JSON.stringify(notesObject), true);
  return (new Buffer(deflate.result.toString(), 'binary')).toString('base64');
};
exports.addUsernote = async function (redToken, modname, subreddit, user, noteText, type, link_index) {
github thenickdude / chickenpaint / js / engine / CPChibiFile.js View on Github external
return Promise.resolve().then(() => {
        const
            deflator = new pako.Deflate({
                level: 7
            }),
            /**
             * The fragments that make up the completed .chi file:
             * @type {Uint8Array[]}
             */
            blobParts = [],
            magic = new Uint8Array(CHI_MAGIC.length),
            layers = artwork.getLayersRoot().getLinearizedLayerList(false),
			version = options.forceOldVersion ? makeChibiVersion(0, 0) : minimumVersionForArtwork(artwork),
            versionString = chibiVersionToString(version);

        let
            layerWritePromise = Promise.resolve();

		deflator.onData = function(chunk) {