lib/decompress.js
function decompress( buffer ) {

  var chunks = []
  var chunkType = ADC.CHUNK_UNKNOWN
  var position = 0
  var length = 0

  windowOffset = 0

  while( position < buffer.length ) {
    chunkType = ADC.getChunkType( buffer[ position ] )
    length = ADC.getSequenceLength( buffer[ position ] )
    switch( chunkType ) {
      case ADC.CHUNK_DATA:
        chunks.push( decodeData( window, buffer, position ) )
        break
      case ADC.CHUNK_THREE:
        chunks.push( decodeRunlength( window, buffer, position ) )
        break
      case ADC.CHUNK_TWO:
        chunks.push( decodeRunlength( window, buffer, position ) )
        break
      default:
        throw new Error( 'Unknown chunk type 0x' + buffer[ position ].toString(16) + ' at ' + position )
    }
    position += length
  }

  return Buffer.concat( chunks )

}
function decompress( buffer ) {

  var chunks = []
  var chunkType = ADC.CHUNK_UNKNOWN
  var position = 0
  var length = 0

  windowOffset = 0

  while( position < buffer.length ) {
    chunkType = ADC.getChunkType( buffer[ position ] )
    length = ADC.getSequenceLength( buffer[ position ] )
    switch( chunkType ) {
      case ADC.CHUNK_DATA:
        chunks.push( decodeData( window, buffer, position ) )
        break
      case ADC.CHUNK_THREE:
        chunks.push( decodeRunlength( window, buffer, position ) )
        break
      case ADC.CHUNK_TWO:
        chunks.push( decodeRunlength( window, buffer, position ) )
        break
      default:
        throw new Error( 'Unknown chunk type 0x' + buffer[ position ].toString(16) + ' at ' + position )
    }
    position += length
  }

  return Buffer.concat( chunks )

}
function decompress ( buffer ) { var chunks = [ ] var chunkType = ADC . CHUNK_UNKNOWN var position = 0 var length = 0 windowOffset = 0 while ( position < buffer . length ) { chunkType = ADC . getChunkType ( buffer [ position ] ) length = ADC . getSequenceLength ( buffer [ position ] ) switch ( chunkType ) { case ADC . CHUNK_DATA : chunks . push ( decodeData ( window , buffer , position ) ) break case ADC . CHUNK_THREE : chunks . push ( decodeRunlength ( window , buffer , position ) ) break case ADC . CHUNK_TWO : chunks . push ( decodeRunlength ( window , buffer , position ) ) break default : throw new Error ( 'Unknown chunk type 0x' + buffer [ position ] . toString ( 16 ) + ' at ' + position ) } position += length } return Buffer . concat ( chunks ) }
Decompress an ADC compressed buffer
@param {Buffer} buffer
@returns {Buffer}
Decompress an ADC compressed buffer