How to use the lzma-native.compress function in lzma-native

To help you get started, we’ve selected a few lzma-native 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 DefinitelyTyped / DefinitelyTyped / types / lzma-native / lzma-native-tests.ts View on Github external
import * as lzma from "lzma-native";
import * as fs from "fs";

const compressor = lzma.createCompressor();
const input = fs.createReadStream("tsconfig.json");
const output = fs.createWriteStream("tsconfig.json.xz");

input.pipe(compressor).pipe(output);

lzma.compress("Banana", undefined, result => {
    console.log(result); // 
});

lzma.compress("Bananas", 6, result => {
    lzma.decompress(result, undefined, decompressedResult => {
        console.log(decompressedResult.toString() === "Bananas");
    });
});

lzma.LZMA().compress("Bananas", 4, result => {
    lzma.LZMA().decompress(result, decompressedResult => {
        console.log("Bananas" === decompressedResult.toString());
    });
});

const comp = lzma.Compressor();
github DefinitelyTyped / DefinitelyTyped / types / lzma-native / lzma-native-tests.ts View on Github external
import * as lzma from "lzma-native";
import * as fs from "fs";

const compressor = lzma.createCompressor();
const input = fs.createReadStream("tsconfig.json");
const output = fs.createWriteStream("tsconfig.json.xz");

input.pipe(compressor).pipe(output);

lzma.compress("Banana", undefined, result => {
    console.log(result); // 
});

lzma.compress("Bananas", 6, result => {
    lzma.decompress(result, undefined, decompressedResult => {
        console.log(decompressedResult.toString() === "Bananas");
    });
});

lzma.LZMA().compress("Bananas", 4, result => {
    lzma.LZMA().decompress(result, decompressedResult => {
        console.log("Bananas" === decompressedResult.toString());
    });
});

const comp = lzma.Compressor();

process.stdin.pipe(comp).pipe(process.stdout);
lzma.crc32("Banana"); // => 69690105
lzma.checkSize("CHECK_SHA256"); // => 16
github soruly / sola / src / lib / hash.js View on Github external
timeCodeList[thumbnailList.indexOf(p1)]
              }`
          )
      )
      .sort(
        (a, b) =>
          parseFloat(a.match(/(.*?)<\/field>/)[1]) -
          parseFloat(b.match(/(.*?)<\/field>/)[1])
      )
      .join("\n"),
    ""
  ].join("\n");
  // fs.writeFileSync("debug.xml", parsedXML);

  console.log("Compressing XML");
  const compressedXML = await lzma.compress(parsedXML, { preset: 6 });
  console.log("Writing output XML");
  fs.ensureFileSync(xmlZipFilePath);
  fs.writeFileSync(xmlZipFilePath, compressedXML, "binary");

  console.log("Removing temp files");
  fs.removeSync(tempPath);

  console.log("Completed");
};