How to use the lzma-native.createStream 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 mozilla / node-janus / lib / plugins / xz.js View on Github external
'content-encoding': false
  };

  if (util.matchHeaders(request.headers, { 'accept-encoding': /xz/ }) &&
      util.matchHeaders(source.headers, headerMatch)) {
    metrics.count('hit');

    // We are writing xz content
    source.headers['content-encoding'] = 'xz';

    // We do not know the length
    delete source.headers['content-length'];

    dest.writeHead(source.statusCode, source.headers);

    source.pipe(lzma.createStream('easyEncoder',
      { preset: CONFIG.xz.level })).pipe(dest);
  } else {
    // Do nothing
    metrics.count('miss');
    source.forward(dest);
  }

  source.resume();
};