index.js
function encode(buffer, extra) {
  if (!extra) extra = 0
  var blen = buffer.length
  var lenbytes = vencode(blen)
  var mb = new Buffer(extra + blen + lenbytes.length)
  for (var i = 0; i < lenbytes.length; i++) {
    mb.writeUInt8(lenbytes[i], extra + i)
  }
  buffer.copy(mb, lenbytes.length + extra, 0, blen)
  return mb
}
function encode(buffer, extra) {
  if (!extra) extra = 0
  var blen = buffer.length
  var lenbytes = vencode(blen)
  var mb = new Buffer(extra + blen + lenbytes.length)
  for (var i = 0; i < lenbytes.length; i++) {
    mb.writeUInt8(lenbytes[i], extra + i)
  }
  buffer.copy(mb, lenbytes.length + extra, 0, blen)
  return mb
}
function encode ( buffer , extra ) { if ( ! extra ) extra = 0 var blen = buffer . length var lenbytes = vencode ( blen ) var mb = new Buffer ( extra + blen + lenbytes . length ) for ( var i = 0 ; i < lenbytes . length ; i ++ ) { mb . writeUInt8 ( lenbytes [ i ] , extra + i ) } buffer . copy ( mb , lenbytes . length + extra , 0 , blen ) return mb }
Encode a buffer with a varint prefix containing the buffer's length.
@param  {Buffer} buffer The buffer to encode
@param  {int} extra How many extra empty leading bytes to put in the buffer
@return {Buffer}        An encoded buffer longer than before.
Encode a buffer with a varint prefix containing the buffer s length .