How to use the lzma-native.createCompressor 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 => {
github IMA-WorldHealth / bhima / server / lib / backup.js View on Github external
function xz(file) {
  const outfile = `${file}.xz`;

  debug(`#xz() compressing ${file} into ${outfile}.`);

  const compressor = lzma.createCompressor();
  const input = fs.createReadStream(file);
  const output = fs.createWriteStream(outfile);

  let beforeSizeInMegabytes;
  let afterSizeInMegabytes;

  return fs.promises.stat(file)
    .then(stats => {
      beforeSizeInMegabytes = stats.size / 1000000.0;
      debug(`#xz() ${file} is ${beforeSizeInMegabytes}MB`);

      // start the compresion
      const streams = input.pipe(compressor).pipe(output);
      return streamToPromise(streams);
    })
    .then(() => util.statp(outfile))
github arturock / basecamp-linux / scripts / build.js View on Github external
compress(appPath) {
    const basePath = path.dirname(appPath);
    const appDir = path.basename(appPath);
    const name = path.basename(appPath).replace(APP_NAME, `${APP_NAME}-${APP_VERSION}`);
    const filename = `${name}.tar.xz`;
    cp.execSync(`mkdir -p ${DIST_PATH}`, { stdio: 'inherit' });

    console.log(`\nGenerating ${filename}...`);

    tar
      .c({ sync: true, cwd: basePath }, [appDir])
      .pipe(lzma.createCompressor())
      .pipe(fs.createWriteStream(path.join(DIST_PATH, filename)))
      .on('finish', () => {
        console.log(` ${filename} ready`);
      });
  },
github heroku / cli / gulp / build.js View on Github external
return new Promise((ok, fail) => {
    mkdirp.sync(path.dirname(file))
    let packer = tar.Pack({noProprietary: true}).on('error', fail).on('end', ok)
    fstream.Reader({path: dir, type: 'Directory'}).on('error', fail)
      .pipe(packer)
      .pipe(lzma.createCompressor().on('error', fail))
      .pipe(fs.createWriteStream(file).on('error', fail))
  })
}