browserify-zlib, which is the zlib shim used by default in webpacked code, does not properly uncompress bgzf chunks that contain more than one bgzf block, so export an unzip function that uses pako directly if we are running in a browser.
493433
async function pakoUnzip(inputData) {
  let strm
  let pos = 0
  let i = 0
  const chunks = []
  let inflator
  do {
    const remainingInput = inputData.slice(pos)
    inflator = new Inflate()
    strm = inflator.strm
    inflator.push(remainingInput, Z_SYNC_FLUSH)
    if (inflator.err) throw new Error(inflator.msg)

    pos += strm.next_in
    chunks[i] = Buffer.from(inflator.result)
    i += 1
  } while (strm.avail_in)

  const result = Buffer.concat(chunks)
  return result
}
245962
def _unpack_zipfile(filename, extract_dir):
    
    try:
        import zipfile
    except ImportError:
        raise ReadError('zlib not supported, cannot unpack this archive.')

    if not zipfile.is_zipfile(filename):
        raise ReadError("%s is not a zip file" % filename)

    zip = zipfile.ZipFile(filename)
    try:
        for info in zip.infolist():
            name = info.filename

            # don't extract absolute paths or ones with .. in them
            if name.startswith('/') or '..' in name:
                continue

            target = os.path.join(extract_dir, *name.split('/'))
            if not target:
                continue

            _ensure_directory(target)
            if not name.endswith('/'):
                # file
                data = zip.read(info.filename)
                f = open(target, 'wb')
                try:
                    f.write(data)
                finally:
                    f.close()
                    del data
    finally:
        zip.close()
955491
def to_zpl_line(self, compression=3, **kwargs):
        
        if compression == 3:
            data = base64.b64encode(zlib.compress(self.data.bytes))
            data = ':Z64:%s:%s' % (data.decode('ascii'), self._calc_crc(data))
        elif compression == 1:
            data = base64.b64encode(self.data.bytes)
            data = ':B64:%s:%s' % (data.decode('ascii'), self._calc_crc(data))
        else:
            lines = []
            last_unique_line = None

            for line in self.data.hex_rows:
                if line.endswith('00'):
                    line = line.rstrip('0')
                    if len(line) % 2:
                        line += '0'
                    line += ','
                if line == last_unique_line:
                    line = ':'
                else:
                    last_unique_line = line
                lines.append(line)

            data = '\n'.join(lines)
            to_compress = set(RE_UNCOMPRESSED.findall(data))
            to_compress = sorted(to_compress, reverse=True)
            for uncompressed in to_compress:
                uncompressed = uncompressed[0]
                repeat = len(uncompressed)
                compressed = ''
                while repeat >= 400:
                    compressed += 'z'
                    repeat -= 400
                if repeat >= 20:
                    value = repeat // 20
                    repeat -= value * 20
                    compressed += chr(value + 70).lower()
                if repeat > 0:
                    compressed += chr(repeat + 70)
                data = data.replace(uncompressed, compressed + uncompressed[0])

            data = data.replace('\n', '')

        zpl = '~DGR:%s.GRF,%s,%s,%s' % (
            self.filename,
            self.data.filesize,
            self.data.width // 8,
            data
        )

        return zpl
754404
def __unpack_zip(self, filename):
        """"""
        if isinstance(filename, string_types) and self.__isValidZIP(filename) and zipfile.is_zipfile(filename):
            with zipfile.ZipFile(filename) as z:
                for name in z.namelist():
                    z.extract(name, self.plugin_abspath)
        else:
            raise ZipError("Invalid Plugin Compressed File")
1034070
def deflate_write_block(fo, block_bytes):
    """"""
    # The first two characters and last character are zlib
    # wrappers around deflate data.
    data = compress(block_bytes)[2:-1]

    write_long(fo, len(data))
    fo.write(data)
1092644
def ungzipper(fh, blocksize=16384):
    
    import zlib
    uzip = zlib.decompressobj(16 + zlib.MAX_WBITS)
    data = uzip.decompress(fh.read(blocksize)).split("\n")

    while len(data[0]):
        # last chunk might not be a full line.
        save = data.pop()
        for line in data:
            yield line
        data = uzip.decompress(fh.read(blocksize)).split("\n")
        # first line is prepended with saved chunk from end of last set.
        data[0] = save + data[0]
265948
def pack(ctx, remove_lib=True):
    
    OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
    with ROOT.joinpath('Pipfile.lock').open() as f:
        lockfile = plette.Lockfile.load(f)

    libdir = OUTPUT_DIR.joinpath('lib')

    paths = {'purelib': libdir, 'platlib': libdir}
    sources = lockfile.meta.sources._data
    maker = distlib.scripts.ScriptMaker(None, None)

    # Install packages from Pipfile.lock.
    for name, package in lockfile.default._data.items():
        if name in DONT_PACKAGE:
            continue
        print(f'[pack] Installing {name}')
        package.pop('editable', None)   # Don't install things as editable.
        package.pop('markers', None)    # Always install everything.
        r = requirementslib.Requirement.from_pipfile(name, package)
        wheel = passa.internals._pip.build_wheel(
            r.as_ireq(), sources, r.hashes or None,
        )
        wheel.install(paths, maker, lib_only=True)

    for pattern in IGNORE_LIB_PATTERNS:
        for path in libdir.rglob(pattern):
            print(f'[pack] Removing {path}')
            path.unlink()

    # Pack everything into ZIP.
    zipname = OUTPUT_DIR.joinpath('passa.zip')
    with zipfile.ZipFile(zipname, 'w') as zf:
        _recursive_write_to_zip(zf, OUTPUT_DIR)
        _recursive_write_to_zip(zf, STUBFILES_DIR)
    print(f'[pack] Written archive {zipname}')

    if remove_lib and libdir.exists():
        print(f'[pack] Removing {libdir}')
        shutil.rmtree(str(libdir))
261649
function buildPack(webpackConfig, cb, spinnerText) {
  var spinner = ora(spinnerText || 'building for uncompressed files...')
  spinner.start()
  webpack(webpackConfig, function (err, stats) {
    spinner.stop()
    if (err) {
      throw err
    }
    process.stdout.write(stats.toString({
      colors: true,
      modules: false,
      children: false,
      chunks: false,
      chunkModules: false
    }) + '\n')
    cb && cb()
  })
}
1094180
public static byte[] zlib(InputStream in, int level, int length) {
		final ByteArrayOutputStream out = new ByteArrayOutputStream(length);
		deflater(in, out, level);
		return out.toByteArray();
	}
149125
function compressDistributionPackage() {
  const src = [
    path.join(__dirname, 'build/**'),
    path.join(__dirname, 'LICENSE'),
    path.join(__dirname, 'CHANGELOG.md'),
    path.join(__dirname, 'bindings/*/esm/**'),
    path.join(__dirname, 'bindings/*/dist/**'),
    '!' + path.join(__dirname, 'build/docs/**'),
    '!' + path.join(__dirname, 'build/docs'),
  ];

  return gulp.src(src)
    .pipe($.zip('onsenui.zip'))
    .pipe(gulp.dest(path.join(__dirname, 'build')));
}
129802
def uncompress_file(s3_object)
      result = ''

      if s3_object.exists?
        io = StringIO.new
        io.write(s3_object.read)
        io.rewind

        gz = Zlib::GzipReader.new(io)
        result = gz.read

        gz.close
      end

      result
    end
205230
def bzip_blocks_decompress_all(data):
    
    frames = bytearray()
    offset = 0
    while offset < len(data):
        size_bytes = data[offset:offset + 4]
        offset += 4
        block_cmp_bytes = abs(Struct('>l').unpack(size_bytes)[0])
        try:
            frames.extend(bz2.decompress(data[offset:offset + block_cmp_bytes]))
            offset += block_cmp_bytes
        except IOError:
            # If we've decompressed any frames, this is an error mid-stream, so warn, stop
            # trying to decompress and let processing proceed
            if frames:
                logging.warning('Error decompressing bz2 block stream at offset: %d',
                                offset - 4)
                break
            else:  # Otherwise, this isn't a bzip2 stream, so bail
                raise ValueError('Not a bz2 stream.')
    return frames
18543
def decompress(self, chunk):
        

        try:
            return self._decompressobj.decompress(chunk)
        except zlib.error:
            # ugly hack to work with raw deflate content that may
            # be sent by microsoft servers. For more information, see:
            # http://carsten.codimi.de/gzip.yaws/
            # http://www.port80software.com/200ok/archive/2005/10/31/868.aspx
            # http://www.gzip.org/zlib/zlib_faq.html#faq38
            if self._first_chunk:
                self._decompressobj = zlib.decompressobj(-zlib.MAX_WBITS)
                return self._decompressobj.decompress(chunk)

            raise
        finally:
            self._first_chunk = False
239592
function browserifyTransform(file) {
    var chunks = [];

    var write = function(buffer) {
      chunks.push(buffer);
    };

    var end = function() {
      var content = Buffer.concat(chunks).toString('utf8');
      // convention fileName == key for shim options
      var fileName = file.match(/([^\/]+)(?=\.\w+$)/)[0];
      this.queue(commonjsify(content, options[fileName]));
      this.queue(null);
    };

    return through(write, end);
  }
99450
function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
	var o = opts||{};
	var z = write_zip(wb, o);
	var oopts = {};
	if(o.compression) oopts.compression = 'DEFLATE';
	if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
	else switch(o.type) {
		case "base64": oopts.type = "base64"; break;
		case "binary": oopts.type = "string"; break;
		case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
		case "buffer":
		case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
		default: throw new Error("Unrecognized type " + o.type);
	}
	var out = z.generate(oopts);
	if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
	if(o.type === "file") return write_dl(o.file, out);
	return o.type == "string" ? utf8read(out) : out;
}
278345
def zlib_compression_level(value)
      if /\A-?\d+\z/ =~ value
        i = value.to_i

        if i >= -1 && i <= 9
          return i
        end
      end

      log_warn("#{value} is not a valid zlibCompressionLevel")
      nil
    end
909979
function createChunkSplits(extraConfig, dirName){

  // Only if there are libs to process
  if(!extraConfig.lib) return;

  // Notify about it
  console.log('Creating library splits');

  // Create a common loader
  var loader = function(config, cb){
    // This will tell webpack to create a new chunk
    rq.ensure(['INDEX_PATH'],function(rq){
      let library = rq('INDEX_PATH');
      library = library.default || library; // To preven issues between versions
      cb(
        // Expected to export an initializing function
        library(config)
      );
    },'NAME');
  }

  // For each lib in the config or for each app_module
  var
    loaders = []
    fileOut = extraConfig.libDir + '/libraries.websdk.js'
    names   = Object.keys(extraConfig.lib)
  ;
  if( !names.length ) return;
  names.forEach(function(it){
    var libPath = path.resolve(extraConfig.lib[it]).replace(/\\/g,'/');

    // Add the definition for this loader
    loaders.push(
      'Registry["' + it + '"] = ' + loader.toString()
        .replace(/INDEX_PATH/g, libPath)
        .replace(/NAME/g, it)
        .replace(/rq/g,'require') + ';'
    );
  });

  // Create the libraries file, this file can be committed if desired
  fs.writeFileSync( fileOut,
    'import Registry from "websdk/essential/ensure-import/registry";\n'
    + loaders.join("\n")
  );
  console.log('Created a library at: ' + fileOut);
  console.log('If you require this file from a runtime file, chunks will be generated for you');
}