Handles de-/compression via #inflate() and #deflate(), calls you back via #deflatedReady() and #inflatedReady().
The chunk we get from deflater is actually a view of a 16kB arraybuffer, so we need to copy the relevant parts
memory to a new arraybuffer.
4306
function Compressor(inflatedReady, deflatedReady) {
  this.inflatedReady = inflatedReady;
  this.deflatedReady = deflatedReady;
  this._inflate = inflater(chunk => this.inflatedReady(chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.length)));
  this._deflate = deflater(chunk => this.deflatedReady(chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.length)));
}
152633
function readNextChunk() {

            // If no further chunks remain, inform of completion and stop
            if (offset >= blob.size) {

                // Fire completion event for completed blob
                if (guacWriter.oncomplete)
                    guacWriter.oncomplete(blob);

                // No further chunks to read
                return;

            }

            // Obtain reference to next chunk as a new blob
            var chunk = slice(blob, offset, offset + arrayBufferWriter.blobLength);
            offset += arrayBufferWriter.blobLength;

            // Attempt to read the blob contents represented by the blob into
            // a new array buffer
            reader.readAsArrayBuffer(chunk);

        }
526144
function decompress (bitmap) {
	var fName = null;
	switch (bitmap.bitsPerPixel.value) {
	case 15:
		fName = 'bitmap_decompress_15';
		break;
	case 16:
		fName = 'bitmap_decompress_16';
		break;
	case 24:
		fName = 'bitmap_decompress_24';
		break;
	case 32:
		fName = 'bitmap_decompress_32';
		break;
	default:
		throw 'invalid bitmap data format';
	}
	
	var input = new Uint8Array(bitmap.bitmapDataStream.value);
	var inputPtr = rle._malloc(input.length);
	var inputHeap = new Uint8Array(rle.HEAPU8.buffer, inputPtr, input.length);
	inputHeap.set(input);
	
	var ouputSize = bitmap.width.value * bitmap.height.value * 4;
	var outputPtr = rle._malloc(ouputSize);

	var outputHeap = new Uint8Array(rle.HEAPU8.buffer, outputPtr, ouputSize);

	var res = rle.ccall(fName,
		'number',
		['number', 'number', 'number', 'number', 'number', 'number', 'number', 'number'],
		[outputHeap.byteOffset, bitmap.width.value, bitmap.height.value, bitmap.width.value, bitmap.height.value, inputHeap.byteOffset, input.length]
	);
	
	var output = new Uint8ClampedArray(outputHeap.buffer, outputHeap.byteOffset, ouputSize);
	
	rle._free(inputPtr);
	rle._free(outputPtr);
	
	return output;
}
48315
private void compress() {
        if (sample.size() < 2) {
            return;
        }

        ListIterator<Item> it = sample.listIterator();
        int removed = 0;

        Item prev = null;
        Item next = it.next();

        while (it.hasNext()) {
            prev = next;
            next = it.next();

            if (prev.g + next.g + next.delta <= allowableError(it.previousIndex())) {
                next.g += prev.g;
                // Remove prev. it.remove() kills the last thing returned.
                it.previous();
                it.previous();
                it.remove();
                // it.next() is now equal to next, skip it back forward again
                it.next();
                removed++;
            }
        }
    }
389910
@Override
    synchronized public int encodeIntoCompressedByteBuffer(
            final ByteBuffer targetBuffer,
            final int compressionLevel) {
        int neededCapacity = getNeededByteBufferCapacity(countsArrayLength);
        if (intermediateUncompressedByteBuffer == null || intermediateUncompressedByteBuffer.capacity() < neededCapacity) {
            intermediateUncompressedByteBuffer = ByteBuffer.allocate(neededCapacity).order(BIG_ENDIAN);
        }
        intermediateUncompressedByteBuffer.clear();
        int initialTargetPosition = targetBuffer.position();

        final int uncompressedLength = encodeIntoByteBuffer(intermediateUncompressedByteBuffer);
        targetBuffer.putInt(getCompressedEncodingCookie());

        targetBuffer.putInt(0); // Placeholder for compressed contents length

        Deflater compressor = new Deflater(compressionLevel);
        compressor.setInput(intermediateUncompressedByteBuffer.array(), 0, uncompressedLength);
        compressor.finish();

        byte[] targetArray;

        if (targetBuffer.hasArray()) {
            targetArray = targetBuffer.array();
        } else {
            if (intermediateUncompressedByteArray == null ||
                intermediateUncompressedByteArray.length < targetBuffer.capacity()) {
                intermediateUncompressedByteArray = new byte[targetBuffer.capacity()];
            }
            targetArray = intermediateUncompressedByteArray;
        }

        int compressedTargetOffset = initialTargetPosition + 8;
        int compressedDataLength =
            compressor.deflate(
                targetArray,
                compressedTargetOffset,
                targetArray.length - compressedTargetOffset
            );
        compressor.end();

        if (!targetBuffer.hasArray()) {
            targetBuffer.put(targetArray, compressedTargetOffset, compressedDataLength);
        }

        targetBuffer.putInt(initialTargetPosition + 4, compressedDataLength); // Record the compressed length
        int bytesWritten = compressedDataLength + 8;
        targetBuffer.position(initialTargetPosition + bytesWritten);
        return bytesWritten;
    }
1096370
function LZ4_uncompress (input, options) {
	var output = []
	var decoder = new Decoder(options)

	decoder.on('data', function (chunk) {
		output.push(chunk)
	})

	decoder.end(input)

	return Buffer.concat(output)
}
173361
def inflate_object(object = nil)
      return false unless object.is_a?(Hash)
      filter_array = object[:Filter]
      if filter_array.is_a?(Hash) && filter_array[:is_reference_only]
        filter_array = filter_array[:referenced_object]
      end
      filter_array = [filter_array] if filter_array.is_a?(Symbol)
      filter_array = [] if filter_array.nil?
      params_array = object[:DecodeParms]
      if params_array.is_a?(Hash) && params_array[:is_reference_only]
        params_array = params_array[:referenced_object]
      end
      params_array = [params_array] unless params_array.is_a?(Array)
      object[:Filter] = filter_array
      object[:DecodeParms] = params_array
      while filter_array[0]
        case filter_array[0]
        when :FlateDecode
          raise_unsupported_error params_array[0] unless params_array[0].nil?
          if params_array[0] && params_array[0][:Predictor].to_i > 1
            predictor = params_array[0][:Predictor].to_i
            # bits = params_array[0][:BitsPerComponent] || 8
            # columns = params_array[0][:Columns] || 1
            if (2..9).cover? predictor
              ####
              # prepare TIFF group
              raise_unsupported_error params_array[0]
            elsif (10..15).cover? predictor
              ####
              # prepare PNG group
              raise_unsupported_error params_array[0]
            end
          else
            inflator = Zlib::Inflate.new

            object[:raw_stream_content] = inflator.inflate object[:raw_stream_content]
            begin
              inflator.finish
            rescue
            end
            inflator.close
            object[:Length] = object[:raw_stream_content].bytesize
          end
        when nil
          true
        else
          return false
        end
        params_array.shift
        filter_array.shift
      end
      object.delete :Filter
      object.delete :DecodeParms
      true
    end
36095
def _chunk_data(self, data):
        """"""

        assert data[-2:] == "\r\n", "CRLF"

        if self.gzip_decompressor:
            if not self.gzip_header_seen:
                assert data[:2] == '\x1f\x8b', "gzip header"
                self.gzip_header_seen = True

            self.process_input_buffer += self.gzip_decompressor.decompress(data[:-2])
        else:
            self.process_input_buffer += data[:-2]

        self.got_chunk = True

        if self.process_input_buffer:
            # since we now have data in the buffer, enable write events again
            logger.debug('Got data in buffer, interested in writing to process again')
            self.ioloop.update_handler(self.fd_stdin, self.ioloop.WRITE | self.ioloop.ERROR)

        # do NOT call read_chunks directly. This is to give git a chance to consume input.
        # we don't want to grow the buffer unnecessarily.
        # Additionally, this should mitigate the stack explosion mentioned in read_chunks
        self.ioloop.add_callback(self.read_chunks)
787549
static final byte[] deflate(final byte[] in, final int len) {
		byte[] defBuf = new byte[len << 1];
		int payloadLength;
		synchronized (deflater) {
			deflater.reset();
			deflater.setInput(in, 0, len);
			deflater.finish();
			payloadLength = deflater.deflate(defBuf);
		}
		return resizeBuffer(defBuf, payloadLength);
	}
315077
static final byte[] inflate(final byte[] in, final int offset, final int length)
			throws DataFormatException {
		byte[] infBuf = new byte[length << 1];
		int payloadLength;
		synchronized (inflater) {
			inflater.reset();
			inflater.setInput(in, offset, length);
			payloadLength = inflater.inflate(infBuf);
		}
		return resizeBuffer(infBuf, payloadLength);
	}
88576
function deflate_internal(buff, off, buff_size) {
		var n;

		if (!initflag) {
			init_deflate();
			initflag = true;
			if (lookahead === 0) { // empty
				complete = true;
				return 0;
			}
		}

		n = qcopy(buff, off, buff_size);
		if (n === buff_size) {
			return buff_size;
		}

		if (complete) {
			return n;
		}

		if (compr_level <= 3) {
			// optimized for speed
			deflate_fast();
		} else {
			deflate_better();
		}

		if (lookahead === 0) {
			if (match_available) {
				ct_tally(0, window[strstart - 1] & 0xff);
			}
			flush_block(1);
			complete = true;
		}

		return n + qcopy(buff, n + off, buff_size - n);
	}
438533
public int /* udword_ppt */decompress(
			final short[] /* const void* */source, int /* udword_ppt */size,
			final Decompressed decomp) {
		this.source = source;
		globalError = false; // assume no error

		readPtr = 0;

		if (!isCompressed(source, size)) {
			return 0;
		}

		// Uncompressed size is stored at end of source file.
		// Backwards decompression.
		readPtr += (size - 4);

		int /* udword_ppt */lastDword = readBEdword(source, readPtr);
		// Uncompressed length in bits 31-8 of last dword.
		int /* udword_ppt */outputLen = lastDword >> 8;

		// Allocate memory for output data.
		dest = new short /* ubyte_ppt */[outputLen];

		// Lowest dest. address for range-checks.
		// Put destptr to end of uncompressed data.
		writePtr = outputLen;

		// Read number of unused bits in 1st data dword
		// from lowest bits 7-0 of last dword.
		bits = 32 - (lastDword & 0xFF);

		// Main decompression loop.
		bytesTOdword();
		if (bits != 32)
			current >>= (32 - bits);
		do {
			if (readBits(1) == 0)
				bytes();
			if (writePtr > 0)
				sequence();
			if (globalError) {
				// statusString already set.
				outputLen = 0; // unsuccessful decompression
				break;
			}
		} while (writePtr > 0);

		// Finished.

		if (outputLen > 0) // successful
		{
			decomp.destBufRef = new short[dest.length];
			// Free any previously existing destination buffer.
			System.arraycopy(dest, 0, decomp.destBufRef, 0, dest.length);
		}

		return outputLen;
	}
70564
def inflate zstring=nil
    @zstring = zstring unless zstring.nil?
    #We can't use unpack, IronRuby doesn't have it yet.
    @zstring.each_byte {|b| @input_buffer << b}

     unless @rawdeflate then

    compression_method_and_flags = @input_buffer[@in_pos+=1]
    flags = @input_buffer[@in_pos+=1]

    #CMF and FLG, when viewed as a 16-bit unsigned integer stored inMSB order (CMF*256 + FLG), is a multiple of 31
    if ((compression_method_and_flags << 0x08) + flags) % 31 != 0 then raise Zlib::DataError.new("incorrect header check") end

    #CM = 8 denotes the ìdeflateî compression method with a window size up to 32K. (RFC's only specify CM 8)
    compression_method = compression_method_and_flags & 0x0F

    if compression_method != Z_DEFLATED then raise Zlib::DataError.new("unknown compression method") end

    #For CM = 8, CINFO is the base-2 logarithm of the LZ77 window size,minus eight (CINFO=7 indicates a 32K window size)
    compression_info = compression_method_and_flags >> 0x04

    if (compression_info + 8) > @w_bits then raise Zlib::DataError.new("invalid window size") end

    preset_dictionary_flag = ((flags & 0x20) >> 0x05) == 1
    compression_level = (flags & 0xC0) >> 0x06

    if preset_dictionary_flag and @dict.nil? then raise Zlib::NeedDict.new "Preset dictionary needed!" end

    #TODO:  Add Preset dictionary support
    if preset_dictionary_flag then
      @dict_crc = @input_buffer[@in_pos+=1] << 24 | @input_buffer[@in_pos+=1] << 16 | @input_buffer[@in_pos+=1] << 8 | @input_buffer[@in_pos+=1]
     end

    end
    last_block = false
    #Begin processing DEFLATE stream
    until last_block
      last_block = (get_bits(1) == 1)
      block_type = get_bits(2)
      case block_type
        when 0 then no_compression
        when 1 then fixed_codes
        when 2 then dynamic_codes
         when 3 then raise Zlib::DataError.new("invalid block type")
      end
    end
    finish
  end
960723
private void handleSnappyDecompression(final ChannelHandlerContext ctx, final FullBinaryMemcacheResponse response) {
        ByteBuf decompressed;
        if (response.content().readableBytes() > 0) {
            // we need to copy it on-heap...
            byte[] compressed = Unpooled.copiedBuffer(response.content()).array();
            try {
                decompressed = Unpooled.wrappedBuffer(Snappy.uncompress(compressed, 0, compressed.length));
            } catch (Exception ex) {
                throw new RuntimeException("Could not decode snappy-compressed value.", ex);
            }
        } else {
            decompressed = Unpooled.buffer(0);
        }


        response.content().release();
        response.setContent(decompressed);
        response.setTotalBodyLength(
            response.getExtrasLength()
                + response.getKeyLength()
                + decompressed.readableBytes()
        );
        response.setDataType((byte) (response.getDataType() & ~DATATYPE_SNAPPY));
    }
720777
function inflateOnData(chunk) {
  this[kTotalLength] += chunk.length;

  if (
    this[kPerMessageDeflate]._maxPayload < 1 ||
    this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload
  ) {
    this[kBuffers].push(chunk);
    return;
  }

  this[kError] = new RangeError('Max payload size exceeded');
  this[kError][kStatusCode] = 1009;
  this.removeListener('data', inflateOnData);
  this.reset();
}
365916
def uncompress_body(response)
      case response['content-encoding']
      when 'gzip'
        # ZLib::GzipReader has an associated encoding, by default Encoding.default_external
        return Zlib::GzipReader.new(StringIO.new(response.body), :encoding => Encoding::BINARY).read
      when 'deflate'
        return Zlib::Inflate.new.inflate(response.body)
      when nil, 'identity'
        return response.body
      else
        raise Net::HTTPError.new(_("Unknown content encoding - %{encoding}") % { encoding: response['content-encoding'] }, response)
      end
    end
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)