lib/Bzip2.js
function(inStream, block, length, crc) {
  var pos = 0;
  var lastChar = -1;
  var runLength = 0;
  while (pos < length) {
    if (runLength===4) {
      block[pos++] = 0;
      if (pos >= length) { break; }
    }
    var ch = inStream.readByte();
    if (ch === EOF) {
      break;
    }
    crc.updateCRC(ch);
    if (ch !== lastChar) {
      lastChar = ch;
      runLength = 1;
    } else {
      runLength++;
      if (runLength > 4) {
        if (runLength < 256) {
          block[pos-1]++;
          continue;
        } else {
          runLength = 1;
        }
      }
    }
    block[pos++] = ch;
  }
  return pos;
}
function(inStream, block, length, crc) {
  var pos = 0;
  var lastChar = -1;
  var runLength = 0;
  while (pos < length) {
    if (runLength===4) {
      block[pos++] = 0;
      if (pos >= length) { break; }
    }
    var ch = inStream.readByte();
    if (ch === EOF) {
      break;
    }
    crc.updateCRC(ch);
    if (ch !== lastChar) {
      lastChar = ch;
      runLength = 1;
    } else {
      runLength++;
      if (runLength > 4) {
        if (runLength < 256) {
          block[pos-1]++;
          continue;
        } else {
          runLength = 1;
        }
      }
    }
    block[pos++] = ch;
  }
  return pos;
}
function ( inStream , block , length , crc ) { var pos = 0 ; var lastChar = - 1 ; var runLength = 0 ; while ( pos < length ) { if ( runLength === 4 ) { block [ pos ++ ] = 0 ; if ( pos >= length ) { break ; } } var ch = inStream . readByte ( ) ; if ( ch === EOF ) { break ; } crc . updateCRC ( ch ) ; if ( ch !== lastChar ) { lastChar = ch ; runLength = 1 ; } else { runLength ++ ; if ( runLength > 4 ) { if ( runLength < 256 ) { block [ pos - 1 ] ++ ; continue ; } else { runLength = 1 ; } } } block [ pos ++ ] = ch ; } return pos ; }
read a block for bzip2 compression.
read a block for bzip2 compression .