docs: function ChannelStream(chan, encoding){
    if(!encoding) encoding = 'binary';
    if(typeof chan != 'object' || !chan.isChannel)
    {
      log.warn('invalid channel passed to streamize');
      return false;
    }
  
    var allowHalfOpen = (chan.type === "thtp") ? true : false;
  
    Duplex.call(this,{allowHalfOpen: allowHalfOpen, objectMode:true})
    this.on('finish',function(){
      chan.send({json:{end:true}});
    });
  
    this.on('error',function(err){
      if(err == chan.err) return; // ignore our own generated errors
      chan.send({json:{err:err.toString()}});
    });
    var stream = this
  
    this.on('pipe', function(from){
      from.on('end',function(){
        stream.end()
      })
    })
  
  
    chan.receiving = chan_to_stream(this);
  
    this._chan = chan;
    this._encoding = encoding;
  
    return this;
  }