How to use the lzma-native.createDecompressor 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 kermitt2 / biblio-glutton / matching / main.js View on Github external
function index(options) {
    var readStream = fs.createReadStream(options.dump)
        .pipe(lzma.createDecompressor())
        .pipe(es.split())
        .pipe(es.map(function (data, cb) {
            // prepare/massage the data
            //console.log(data);
            data = massage(data);
            var obj = new Object();

            // - migrate id from '_id' to 'id'
            obj._id = data._id.$oid;
            delete data._id;

            // Just keep the fields we want to index

            // - Main fields (in the mapping)
            obj.title = data.title;
            obj.DOI = data.DOI;
github kermitt2 / biblio-glutton / matching / indexer.js View on Github external
function load_file(input) {
    var start = new Date();
    readStreamBao = fs.createReadStream(input)
        .pipe(lzma.createDecompressor())
        .pipe(es.split())
        .pipe(es.map(function (data, cb) {
            // prepare/massage the data

            // - migrate id from '_id' to 'id'
            var obj = JSON.parse(data);
            obj.id = obj._id.$oid;
            delete obj._id;

            // - remove citation data
            delete obj.reference;

            cb(null, obj)
        }));

    async.series([
github mediathekview / mediathekviewweb / server / src / http-filmliste.ts View on Github external
async pipe(destination: T, options?: { end?: boolean }): Promise {
    console.log('download');
    if (await this.streamIsCompressed) {
      let decompressor = LZMA.createDecompressor();
      return AsyncRequest.get(this.url).pipe(decompressor).pipe(destination, options);
    } else {
      return AsyncRequest.get(this.url).pipe(destination, options);
    }
  }
github mediathekview / mediathekviewweb / server / MediathekManager.ts View on Github external
fs.close(fd, () => {
          reject(err);
        });
      });

      req.on('progress', (state) => {
        this.stateEmitter.updateState({
          progress: state.percent,
          speed: utils.formatBytes(state.speed, 2) + '/s',
          transferred: utils.formatBytes(state.size.transferred, 2) + ' / ' + utils.formatBytes(state.size.total, 2),
          elapsed: state.time.elapsed + ' seconds',
          remaining: state.time.remaining + ' seconds'
        });
      });

      const decompressor = lzma.createDecompressor();
      req.pipe(decompressor).pipe(fileStream).on('finish', async () => {
        try {
          await close(fd);
        }
        catch (error) {
          console.error(error);
        }

        resolve(null);
      });
    });
  }
github mediathekview / mediathekviewweb / server / src / filmlist-importer / http-filmlist.ts View on Github external
getStream(): Readable {
    const httpStream = Needle.get(this.ressource);

    if (this.compressed) {
      const decompressor = LZMA.createDecompressor() as Duplex;
      return httpStream.pipe(decompressor);
    }

    const duplex = new Duplex();
    return httpStream.pipe(duplex);
  }
github mediathekview / mediathekviewweb / server / src / filmlist-importer / listing-filmlist.ts View on Github external
getStream(): Readable {
    const fileStream = this.listingFile.getStream();

    if (this.listingFile.name.endsWith('.xz')) {
      const decompressor = LZMA.createDecompressor() as Duplex;
      return fileStream.pipe(decompressor);
    }

    return fileStream;
  }
github mediathekview / mediathekviewweb / server / src / utils / decompressor.ts View on Github external
export function decompress(stream: Readable): Readable {
  const decompressor = LZMA.createDecompressor();
  const decompressedStream = stream.pipe(decompressor);

  const originalDestroy = decompressedStream.destroy.bind(decompressedStream);

  decompressedStream.destroy = () => {
    (decompressedStream as any).cleanup();
    originalDestroy();
  };

  return decompressedStream;
}