code: function(size, root, bitstream, max_weight) {
    var i;
    //  default: all alphabet symbols are used
  
    console.assert(size && typeof(size)==='number');
    if( !root || root > size )
        root = size;
  
    //  create the initial escape node
    //  at the tree root
  
    if ( root <<= 1 ) {
        root--;
    }
  
    // create root+1 htables (coding table)
    // XXX this could be views on a backing Uint32 array?
    this.table = [];
    for (i=0; i<=root; i++) {
      this.table[i] = new HTable(0,0,0,0);
    }
  
    // this.map => mapping for symbols to nodes
    this.map = [];
    // this.size => the alphabet size
    if( this.size = size ) {
      for (i=0; i<size; i++) {
        this.map[i] = 0;
      }
    }
  
    // this.esc  => the current tree height
    // this.root => the root of the tree
    this.esc = this.root = root;
  
    if (bitstream) {
      this.readBit = bitstream.readBit.bind(bitstream);
      this.writeBit = bitstream.writeBit.bind(bitstream);
    }
    this.max_weight = max_weight; // may be null or undefined
  }
docs: initialize an adaptive coder for alphabet size, and count of nodes to be used