lib/encode.js
function encode (data, buffer, offset) {
  var buffers = []
  var result = null

  encode._encode(buffers, data)
  result = Buffer.concat(buffers)
  encode.bytes = result.length

  if (Buffer.isBuffer(buffer)) {
    result.copy(buffer, offset)
    return buffer
  }

  return result
}
function encode (data, buffer, offset) {
  var buffers = []
  var result = null

  encode._encode(buffers, data)
  result = Buffer.concat(buffers)
  encode.bytes = result.length

  if (Buffer.isBuffer(buffer)) {
    result.copy(buffer, offset)
    return buffer
  }

  return result
}
function encode ( data , buffer , offset ) { var buffers = [ ] var result = null encode . _encode ( buffers , data ) result = Buffer . concat ( buffers ) encode . bytes = result . length if ( Buffer . isBuffer ( buffer ) ) { result . copy ( buffer , offset ) return buffer } return result }
Encodes data in bencode.

@param  {Buffer|Array|String|Object|Number|Boolean} data
@return {Buffer}
Encodes data in bencode .