How to use the snappyjs.uncompress function in snappyjs

To help you get started, we’ve selected a few snappyjs 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 polkadot-js / apps / packages / app-js / src / Playground.tsx View on Github external
code: '',
    label: { basic: true, children: 'URL', size: 'tiny' },
    text: 'Shared code example (unsaved)',
    type: 'shared',
    value: `custom-${Date.now()}`
  };

  try {
    const compStr = atob(base64);
    const compU8a = new Uint8Array(compStr.length);

    compU8a.forEach((_, i): void => {
      compU8a[i] = compStr.charCodeAt(i);
    });

    const u8a = snappy.uncompress(compU8a);
    const code = util.u8aToString(u8a);

    sharedExample.code = code;
  } catch (error) {
    const errorMessage = 'ERROR: Unable to decode code example from URL';

    console.error(`${errorMessage}: \n${error}`);
    sharedExample.code = `// ${errorMessage}`;
  }

  return sharedExample;
}
github rai-project / mlmodelscope / src / components / InferenceResult / ReadRawImageResults.js View on Github external
function read_rawimage_results(features) {
  // ignore data for now and use results
  // const compressed_data = results.responses[0].features[0].raw_image.compressed_data;
  const compressed_data = features[0].raw_image.compressed_data;
  const binary_compressed_data = base64ToUint8Array(compressed_data);
  const jsonBuf = snappyjs.uncompress(binary_compressed_data);

  var enc = new TextDecoder("utf-8");
  const json = enc.decode(jsonBuf);

  var imagedata = JSON.parse(json);
  var width = results.responses[0].features[0].raw_image.width
  var height = results.responses[0].features[0].raw_image.height
  var img = new Image(width, height, imagedata, {kind: "RGB"})
  var rgbaimg = img.rgba8();
  return rgbaimg.toDataURL();
}
github demostf / demo.js / src / Parser / Packet / CreateStringTable.ts View on Github external
let data = stream.readBitStream(bitCount);

	if (isCompressed) {
		const decompressedByteSize = data.readUint32();
		const compressedByteSize = data.readUint32();

		const magic = data.readASCIIString(4);

		const compressedData = data.readArrayBuffer(compressedByteSize - 4); // 4 magic bytes

		if (magic !== 'SNAP') {
			throw new Error('Unknown compressed stringtable format');
		}

		const decompressedData = uncompress(compressedData);
		if (decompressedData.byteLength !== decompressedByteSize) {
			throw new Error('Incorrect length of decompressed stringtable');
		}

		data = new BitStream(decompressedData.buffer as ArrayBuffer);
	}

	const table: StringTable = {
		name: tableName,
		entries: [],
		maxEntries,
		fixedUserDataSize: userDataSize,
		fixedUserDataSizeBits: userDataSizeBits,
		compressed: isCompressed
	};
github hemerajs / hemera / packages / hemera-snappy / index.js View on Github external
function uncompress(msg) {
    try {
      return {
        value: SnappyJS.uncompress(msg)
      }
    } catch (error) {
      return {
        error
      }
    }
  }
github ironSource / parquetjs / lib / compression.js View on Github external
function inflate_snappy(value) {
  return snappy.uncompress(value);
}

snappyjs

JavaScript implementation of Google's Snappy compression library

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular snappyjs functions