
module.exports = decode

function* decode(data) {

  this.position = 0
  this.encoding = encoding || null

  this.data = !( data instanceof Buffer )
    ? new Buffer( data )
    : data

  while(this.position + 1 < this.data.length) {
    switch( this.data[this.position] ) {
      case 0x64: yield this.dictionary(); break
      case 0x6C: yield this.list(); break
      case 0x69: yield this.integer(); break
      default:   yield this.bytes(); break
    }
  }
}
